Compare commits

..

7 Commits
main ... stable

Author SHA1 Message Date
Markus Gans 54e4dec4a2
Merge pull request #83 from gansm/main
merge
2021-05-10 07:51:12 +02:00
Markus Gans c52b22b4a1
Merge pull request #80 from gansm/master
merge
2020-11-14 22:58:38 +01:00
Markus Gans 09d494cb65
Merge pull request #79 from gansm/master
merge
2020-11-07 21:56:51 +01:00
Markus Gans 5149301d29
Merge pull request #74 from gansm/master
Merge
2020-10-12 20:57:07 +02:00
Markus Gans 8784a4c925
Merge pull request #63 from gansm/master
Merge
2020-09-17 02:08:15 +02:00
Markus Gans cd5f7ae16e
Merge pull request #58 from gansm/master
merge
2020-06-03 21:29:52 +02:00
Markus Gans 9b6f0d5951
Merge pull request #55 from gansm/master
merged commit
2020-05-03 15:38:22 +02:00
117 changed files with 4108 additions and 4090 deletions

View File

@ -1,38 +0,0 @@
---
name: Bug report
about: Create a bug report
title: ''
labels: bug
assignees: ''
---
## Describe the bug
Give a detailed description of what the bug is.
## How to reproduce the bug?
Explain step-by-step the procedure to reproduce this behavior.
## What behavior did you expect?
Describe what you would expect instead.
## In which environment did the bug occur?
* Which operating system do you use?<br />
Linux, FreeBSD, NetBSD, OpenBSD, macOS, Cygwin, or Solaris
* Which distribution do you use?
* On which CPU architecture did you test?
* Which compiler in which version did you use?
* Which terminal do you use?
* What does the environment variable $TERM contain?

View File

@ -1,32 +0,0 @@
---
name: Feature request
about: Make a suggestion for this project
title: ''
labels: enhancement
assignees: ''
---
## Feature Request
**Do you want to solve a problem with your feature request? Please describe it.**
Describe clearly and precisely what the problem is.
Example: I have an issue when [...]
**Your desired solution**
Describe clearly and concisely what you want to reach.
**Alternatives you have considered**
Describe clearly and concisely the other solutions you considered.
**Additional context**
Add additional context or screenshots to your feature request here.

View File

@ -1,53 +0,0 @@
name: "ARM build"
on:
push:
branches: [ main, actions-test ]
pull_request:
branches: [ main, actions-test ]
schedule:
- cron: '0 7 * * 2'
jobs:
build:
runs-on: ubuntu-latest
name: Build on ${{ matrix.arch }}
# Run steps on a matrix of 3 arch/distro combinations
strategy:
matrix:
include:
- arch: aarch64
- arch: armv7
steps:
- name: Repository checkout
uses: actions/checkout@v2
- name: Before_install
run: |
lsb_release -a
uname -a
whoami
tty || echo
pwd
- name: Install dependencies via apt-get
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get -y install \
ca-certificates \
gcc \
g++ \
gpm \
libgpm-dev \
libcppunit-dev \
autoconf-archive
- name: Build
run: |
autoreconf -v --install --force
./configure --prefix=/usr
make -j10

View File

@ -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 analysis" name: "CodeQL"
on: on:
push: push:

View File

@ -1,57 +0,0 @@
name: "Code coverage"
on:
push:
branches: [ main, actions-test ]
pull_request:
branches: [ main, actions-test ]
schedule:
- cron: '0 7 * * 2'
jobs:
analyze:
runs-on: ubuntu-latest
env:
COVERALLS_REPO_TOKEN: "${{ secrets.COVERALLS_REPO_TOKEN }}"
steps:
- name: Repository checkout
uses: actions/checkout@v2
- name: Before_install
run: |
lsb_release -a
uname -a
whoami
tty || echo
pwd
- name: Install dependencies via apt-get
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get -y install \
ca-certificates \
gcc \
g++ \
gpm \
libgpm-dev \
libcppunit-dev \
autoconf-archive
- name: Download coderalls
run: pip install --user cpp-coveralls
- name: Download codecov
run: sudo pip install codecov
- name: Build with with gcov
run: script -e -c "./build.sh coverage"
- name: Coveralls
run: coveralls --gcov-options '\-lp' -e debian -e doc -e icon -e logo -e m4 -e scripts -e examples
- name: Codecov
run: bash <(curl -s https://codecov.io/bash)

View File

@ -1,86 +0,0 @@
name: "Coverity Scan"
on:
push:
branches: [ main, actions-test ]
pull_request:
branches: [ main, actions-test ]
schedule:
- cron: '0 7 * * 2'
jobs:
analyze:
# Ubuntu 16.04 LTS will be removed on September 20, 2021
runs-on: ubuntu-16.04
#runs-on: ubuntu-18.04
env:
COVERITY_SCAN_BRANCH_PATTERN: "${{ github.ref}}"
COVERITY_SCAN_NOTIFICATION_EMAIL: "guru.mail@muenster.de"
COVERITY_SCAN_PROJECT_NAME: "${{ github.repository }}"
# Set in repo settings -> secrets -> repository secrets
COVERITY_SCAN_TOKEN: "${{ secrets.COVERITY_SCAN_TOKEN }}"
CURRENT_REF: "${{ github.ref }}"
steps:
- name: Repository checkout
uses: actions/checkout@v2
- name: Before_install
run: |
lsb_release -a
uname -a
whoami
tty || echo
pwd
- name: Download coverity scan build tool
run: |
wget -q https://scan.coverity.com/download/cxx/linux64 \
--post-data "token=$COVERITY_SCAN_TOKEN&project=gansm%2Ffinalcut" \
-O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
- name: Install dependencies via apt-get
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get -y install \
ca-certificates \
gcc \
g++ \
gpm \
libgpm-dev \
libcppunit-dev \
autoconf-archive
- name: Build with cov-build
run: |
export PATH=`pwd`/cov-analysis-linux64/bin:$PATH
cat cov-int/scm_log.txt || echo
autoreconf -v --install --force
./configure --prefix=/usr \
CPPFLAGS="-DDEBUG" \
CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" \
--with-unit-test
cov-build --dir cov-int make V=1 -j10
- name: Submit the result to Coverity Scan
run: |
tar czvf finalcut.tgz cov-int
curl \
--form token=$COVERITY_SCAN_TOKEN \
--form email=$COVERITY_SCAN_NOTIFICATION_EMAIL \
--form file=@finalcut.tgz \
--form version="main" \
--form description="Build submitted via github action" \
https://scan.coverity.com/builds?project=gansm%2Ffinalcut
- name: Make unit test
run: |
script -e -c "make check" && RET=$? || RET=$?
cat test/*.log || echo
echo "Exit status: $RET"
exit "$RET"

View File

@ -1,45 +0,0 @@
name: "Cygwin build"
on:
push:
branches: [ main, actions-test ]
pull_request:
branches: [ main, actions-test ]
schedule:
- cron: '0 7 * * 2'
jobs:
build:
runs-on: windows-latest
name: Build on ${{ matrix.platform }}
strategy:
matrix:
platform: [x86, x64]
steps:
- name: Install Cygwin
uses: egor-tensin/setup-cygwin@v3
with:
platform: ${{ matrix.platform }}
install-dir: C:\cygwin
packages: git grep make libncurses-devel gcc-core gcc-g++ automake autoconf autoconf-archive libtool pkgconf cppunit
- name: Test on Cygwin environment
run: |
uname -a
whoami
pwd
cygcheck -c -d # Show installed Cygwin packages
g++ --version
mkdir src && cd src
git clone git://github.com/gansm/finalcut.git
cd finalcut || echo "The source code directory was not found!"
autoreconf --force --install --verbose --warnings=all
automake --add-missing --copy
./configure --prefix=/usr
make -j10
shell: C:\cygwin\bin\bash.exe --login '{0}'
env:
SHELLOPTS: igncr

View File

@ -1,36 +0,0 @@
name: "FreeBSD build"
on:
push:
branches: [ main, actions-test ]
pull_request:
branches: [ main, actions-test ]
schedule:
- cron: '0 7 * * 2'
jobs:
build:
runs-on: macos-10.15
steps:
- name: Repository checkout
uses: actions/checkout@v2
- name: Test on FreeBSD 12.2
uses: cross-platform-actions/action@v0.0.1
with:
operating_system: freebsd
version: 12.2
shell: bash
run: |
uname -a
freebsd-version
whoami
pwd
sudo pkg update
sudo pkg install -y lang/gcc devel/autotools autotools automake autoconf autoconf-archive libtool pkgconf devel/ncurses devel/cppunit cppunit
g++ --version
autoreconf -v --install --force
./configure --prefix=/usr
make -j10

View File

@ -1,37 +0,0 @@
name: "macOS build"
on:
push:
branches: [ main, actions-test ]
pull_request:
branches: [ main, actions-test ]
schedule:
- cron: '0 7 * * 2'
jobs:
build:
runs-on: macos-latest
steps:
- name: Repository checkout
uses: actions/checkout@v2
- name: Before_install
run: |
uname -a
g++ --version
whoami
pwd
- name: Install dependencies via homebrew
run: |
brew update
brew install automake
brew install autoconf-archive
- name: Build
run: |
autoreconf -v --install --force
./configure --prefix=/usr
make -j10

View File

@ -1,38 +0,0 @@
name: "OpenBSD build"
on:
push:
branches: [ main, actions-test ]
pull_request:
branches: [ main, actions-test ]
schedule:
- cron: '0 7 * * 2'
jobs:
build:
runs-on: macos-10.15
steps:
- name: Repository checkout
uses: actions/checkout@v2
- name: Test on OpenBSD 6.8
uses: cross-platform-actions/action@v0.0.1
with:
operating_system: openbsd
version: 6.8
shell: bash
run: |
uname -a
whoami
pwd
# http://ftp.openbsd.org/pub/OpenBSD/6.8/packages/amd64/
sudo pkg_add gcc-8.4.0 g++-8.4.0 automake-1.16.2 autoconf-2.69p3 autoconf-archive libtool pkgconf cppunit
export CXX=eg++
export AUTOCONF_VERSION=2.69
export AUTOMAKE_VERSION=1.16
eg++ --version
autoreconf -v --install --force
./configure --prefix=/usr
make -j10

View File

@ -1,33 +0,0 @@
name: "Solaris build"
on:
push:
branches: [ main, actions-test ]
pull_request:
branches: [ main, actions-test ]
schedule:
- cron: '0 7 * * 2'
jobs:
build:
runs-on: macos-latest
steps:
- name: Repository checkout
uses: actions/checkout@v2
- name: Test on Solaris 11.4
uses: vmactions/solaris-vm@v0.0.3
with:
prepare: pkgutil -y -i gcc5g++ automake autoconf autoconf_archive libtool pkgconfig libcppunit1_12_1 libcppunit_dev
run: |
uname -a
whoami
pwd
cat /etc/release
PATH=/opt/csw/bin:$PATH
export PATH
autoreconf -v --install --force
./configure --prefix=/usr
make

View File

@ -1,61 +0,0 @@
name: "SonarCloud analysis"
on:
push:
branches: [ main, actions-test ]
pull_request:
branches: [ main, actions-test ]
schedule:
- cron: '0 7 * * 2'
jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
SONAR_TOKEN: "${{ secrets.SONAR_TOKEN }}"
steps:
- name: Repository checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Before_install
run: |
lsb_release -a
uname -a
whoami
tty || echo
pwd
- name: Install dependencies via apt-get
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get -y install \
ca-certificates \
gcc \
g++ \
gpm \
wget \
unzip \
libgpm-dev \
libcppunit-dev \
autoconf-archive
- name: Build with SonarCloud
run: |
wget -q "https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip"
unzip -q "build-wrapper-linux-x86.zip" -d "/tmp" || echo
LATEST_VERSION=$(wget -O- https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/ 2>/dev/null | grep 'linux.zip"' | cut -d\" -f2 | tail -n1)
wget -q "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/$LATEST_VERSION"
unzip -q "$LATEST_VERSION" -d "/tmp" || echo
echo "sonar.host.url=https://sonarcloud.io" >> /tmp/sonar-scanner-*/conf/sonar-scanner.properties
mkdir /tmp/sonar-cache
autoreconf -v --install --force
./configure --prefix=/usr
/tmp/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make all
/tmp/sonar-scanner-4.6.2.2472-linux/bin/sonar-scanner

187
.travis.yml Normal file
View File

@ -0,0 +1,187 @@
language: cpp
dist: xenial
compiler:
- gcc
addons:
apt:
packages:
- g++
- autotools-dev
- automake
- autoconf
- autoconf-archive
- libtool
- pkg-config
- libglib2.0-dev
- libncurses5-dev
- gpm
- libgpm-dev
- gperf
- libcppunit-dev
homebrew:
packages:
- autoconf-archive
update: true
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: |-
wvCvMaIm7LoSyWHmpRXvJIetdMnJKsLLxuon6r6BSfpyimoz5FIMEhNhfSt2psv8tJHZgN
/FcMcLhnTuTMIjvtlEtb3syfHDaNs7S2q3rm6LCmuIUU4ECAwAorkMQbXcyh5rgPlDMDiw
CyBE8O1yFQebAFxRoP181+0uI2IiIP/8EW3P5PDSQzds+9fnnwrFS+OeBoUZfxT0F2kj2f
kMXZN4+KmeVIrkqtj8hlRcicLgBPm4hrK5IEUcFLtAbzPj72wkV1duiYG6kqDsATmzMK0m
5EuMhQ/nL/rbSjhrcRZzPFQ7P31ToSwg1I6cyhMjyXSbpwdppZ/RSwTpqDCdq9l4bDDmvI
qizdwYZKcDtyHxm4Zl/LZKwWDsGEelcmuJKfdu+QuTgInGNlqulmDykvbsrk9jTimIzHTb
F8TOn9IpANlTWmvunGeOarvR9qJReZcwSMq41hdMbsUdHiC1arZjKvINcPVuwikzaNq4iA
te6mtSdrfdx1wLxQ6ZYNgKd9hz+uUTlBYl80hkATmq0NPnPQw2KzyG9E6nLrKOy2M0ozO8
bL/epiiMBKJ37X1UcRU4WZYq+peLME8EefcPcXOSWNLwJtR7mtON8uMBrLL9CWmRMFD5Hy
lQYALW2DhCnDBROKB3gxB/VkBGFNE0IPGeDtBGbLqDtKWPQoL125I=
jobs:
include:
#
# Coverity Scan
#
- os: linux
env:
- TEST="Coverity Scan"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- ca-certificates
- gcc
- g++
- gpm
- libgpm-dev
- libcppunit-dev
- autoconf-archive
coverity_scan:
project:
name: gansm/finalcut
description: Build submitted via Travis CI
notification_email: guru.mail@muenster.de
build_command_prepend: "autoreconf -v --install --force && ./configure --prefix=/usr CPPFLAGS='-DDEBUG' CXXFLAGS='-g -O0 -DDEBUG -DUNIT_TEST' --with-unit-test && make clean"
build_command: "make V=1 -j10"
branch_pattern: main
before_install:
- lsb_release -a
- uname -a
- whoami
- echo -n | openssl s_client -CApath /etc/ssl/certs/ -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
script:
- cat /home/travis/build/gansm/finalcut/cov-int/scm_log.txt || echo
- autoreconf -v --install --force
- ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test
- make V=1 -j10
- make check
- cat test/*.log || echo
#
# Coveralls + Codecov
#
- os: linux
env:
- TEST="Coveralls"
before_install:
- lsb_release -a
- uname -a
- pip install --user cpp-coveralls
- sudo pip install codecov
script:
- ./build.sh coverage
after_success:
- coveralls --gcov-options '\-lp' -e debian -e doc -e icon -e logo -e m4 -e scripts -e examples
- bash <(curl -s https://codecov.io/bash)
#
# SonarCloud
#
- os: linux
env:
- TEST="sonarcloud"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- ca-certificates
- gcc
- g++
- gpm
- libgpm-dev
- libcppunit-dev
- autoconf-archive
sonarcloud:
organization: "gansm"
token:
secure: |-
Vai4Z9BoLsCdrtra5bP/xM8uZnMLKXWS3AH0Z6NnP6bBIa7o9i44Hg5b80P5yL3w
22NgZcX5BrPNhTFbbsulw+F8OdnDETV1bxrDkAVaLGlw+pVjBFNhwXZzyHTx7rsX
GQ/5ry1gIclRlyUO6atW5zQsImAPkTuMv6fFzjgiN1z5vheOTjOKpKqVZNWOURJT
kKgSqiPgHMlR8JLqlHJ/322YVjOOwTLNPrHV6/TrWFrIHI3nChYYX60394sTzKrv
XkU0uvoiJts0cEk97AWcWEfq5TkF1X9604UOZRifNps9kfNZOHjgUuFUvvo3WE8W
ek9LU/0Ec9kViJEASsSE6VzNXWDqu+VkqisJwchUkn6OxoDILSkJpceco/Rx4dAO
phMSgXjCCsvz5igniVyFUixoBvGo4D1bLO6zZPDVxXMDMhpzQKqwqkJo6FYcl109
rni9IuLvMFDAwUuzCbXlbjSPvdOoDiq+8NY1A0TOtTp4z4q9NCPr6TlCcKrazqnN
Xz4Nxo8xZCHxaH7CaXjBmh91Wp5aIzbwJS9fg6A7e2Is1HJm9YW1j3akBjzT//kE
GhOEiXesrPvH5c9XxyO8ZgnkYjNBAES/9aUn8NZBPgQqcUhWAAe1r9fH4iy3Zj+/
26IUvLfJ05uf1yEAzR9/xDIJFF7Heg1FRtzd6IiAdQ4=
script:
- autoreconf -v --install --force
- ./configure --prefix=/usr
- build-wrapper-linux-x86-64 --out-dir bw-output make all
- sonar-scanner
cache:
directories:
- '$HOME/.sonar/cache'
#
# macOS
#
- os: osx
osx_image: xcode11
env:
- TEST="macOS"
before_install:
- uname -a
- g++ --version
script:
- autoreconf -v --install --force
- ./configure --prefix=/usr
- make -j10
#
# FreeBSD
#
- os: freebsd
env:
- TEST="FreeBSD"
before_install:
- uname -a
- g++ --version
- sudo pkg install -y autoconf-archive
script:
- autoreconf -v --install --force
- ./configure --prefix=/usr
- make -j10
#
# Linux ARM64 build
#
- arch: arm64
os: linux
env:
- TEST="ARM64"
before_install:
- uname -a
- g++ --version
script:
- autoreconf -v --install --force
- ./configure --prefix=/usr
- make -j10

View File

@ -1,11 +0,0 @@
# Code of Conduct
The FINAL CUT Project aims to be a welcoming place and we ask that everyone
who interacts with the project and the larger community treat each other
with dignity and respect. Individuals who do not behave in this manner will
be warned and asked to adjust their behavior; in extreme cases, individuals
could get excluded from the project.
Examples of inappropriate behavior include profane, offensive, or
prejudicial language directed at another person, vandalism, or spam.

View File

@ -1,33 +1,3 @@
2021-06-26 Markus Gans <guru.mail@muenster.de>
* Global non-constant variables are now encapsulated in classes
2021-06-19 Markus Gans <guru.mail@muenster.de>
* Moving the creator methods from FTerm to its own class
2021-06-16 Markus Gans <guru.mail@muenster.de>
* Converted the internal timer from timeval
to std::chrono::time_point<system_clock>
2021-06-06 Markus Gans <guru.mail@muenster.de>
* Bug fixing in FString and FTermDetection
* FTermDetection now has clean code by using FString instead of char*
* Replace std::strlen with stringLength
2021-06-03 Markus Gans <guru.mail@muenster.de>
* Some FString optimizations
2021-05-30 Markus Gans <guru.mail@muenster.de>
* FString internally changed from wchar_t* to std::wstring
2021-05-24 Markus Gans <guru.mail@muenster.de>
* Using std::string for the attribute buffer
2021-05-22 Markus Gans <guru.mail@muenster.de>
* Convert FOptiMove from char[] to std::string
2021-05-13 Markus Gans <guru.mail@muenster.de>
* Prevent duplicate widget in the close widget list
2021-05-07 Markus Gans <guru.mail@muenster.de> 2021-05-07 Markus Gans <guru.mail@muenster.de>
* Some pointers were replaced by references * Some pointers were replaced by references

View File

@ -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.com/gansm/finalcut.svg?branch=main)](https://travis-ci.com/gansm/finalcut) | *Travis CI* | [![Build Status](https://travis-ci.org/gansm/finalcut.svg?branch=main)](https://travis-ci.org/gansm/finalcut)
| *Coverity Scan* | [![Coverity Scan Status](https://img.shields.io/coverity/scan/6508.svg)](https://scan.coverity.com/projects/6508 )| | *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) |

View File

@ -1,12 +0,0 @@
# Security policy
## Dealing with security vulnerabilities
There is no separate process for handling security vulnerabilities in FINAL CUT. Security vulnerabilities are fixed and published like all other bugs. Nevertheless, from the moment they are brought to our attention, we try to close them as soon as possible.
## Reporting a security vulnerability
Preferably report a vulnerability via email to "guru.mail" + "@" + "muenster.de" or open an issue in the GitHub repository, the latter meaning that you made the vulnerability public before it was fixed.
If you already have a solution for the security problem, please submit a pull request.

View File

@ -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" # "-flto -fno-rtti" if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O3" # "-fno-rtti"
then then
echo "${RED}Configure failed!${NORMAL}" 1>&2 echo "${RED}Configure failed!${NORMAL}" 1>&2
exit 255 exit 255

View File

@ -1,5 +0,0 @@
coverage:
status:
project: on
patch: off

View File

@ -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();

View File

@ -385,7 +385,7 @@ void Calc::drawDispay()
{ {
finalcut::FString display{input}; finalcut::FString display{input};
if ( display.isEmpty() ) if ( display.isNull() || display.isEmpty() )
display = L'0'; display = L'0';
if ( display.right(3) == L"-0." ) if ( display.right(3) == L"-0." )
@ -651,6 +651,7 @@ 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 += '.';

View File

@ -24,6 +24,7 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <vector>
#include <final/final.h> #include <final/final.h>

View File

@ -25,6 +25,7 @@
#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;
@ -60,16 +61,10 @@ 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};
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -105,11 +100,10 @@ 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
( (
@ -124,24 +118,6 @@ 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
);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -205,10 +181,7 @@ 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{30, 16}, FSize{10, 1}); quit.setGeometry(FPoint{24, 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();
} }
@ -218,16 +191,6 @@ 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()
{ {
@ -243,18 +206,7 @@ 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

View File

@ -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::getInstance(); auto& start_options = finalcut::FStartOptions::getFStartOptions();
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::FOptiMove::getInstance(); const auto& opti_move = finalcut::FTerm::getFOptiMove();
finalcut::printDurations(opti_move); finalcut::printDurations(opti_move);
// Waiting for keypress // Waiting for keypress

View File

@ -190,7 +190,7 @@ void RotoZoomer::generateReport()
finalcut::FStringStream rep; finalcut::FStringStream rep;
dimension_str << getDesktopWidth() dimension_str << getDesktopWidth()
<< "x" << getDesktopHeight(); << "x" << getDesktopHeight();
auto elapsed_ms = int(duration_cast<milliseconds>(end - start).count()); int elapsed_ms = int(duration_cast<milliseconds>(end - start).count());
time_str << double(elapsed_ms) / 1000 << "s"; 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::getInstance(); auto& start_options = finalcut::FStartOptions::getFStartOptions();
start_options.terminal_data_request = false; start_options.terminal_data_request = false;
} }

View File

@ -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 )
{ {

View File

@ -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(); void debug (const finalcut::FApplication&);
void booleans(); void booleans();
void numeric(); void numeric();
void string(); void string();
@ -167,21 +167,22 @@ void tcapNumeric (const std::string& name, int cap_num)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void tcapString (const std::string& name, const char cap_string[]) void tcapString (const std::string& name, const char cap_str[])
{ {
std::string sequence{}; std::string sequence{};
std::string cap_str{cap_string ? cap_string : std::string{}};
std::cout << name << ": "; std::cout << name << ": ";
if ( cap_str.empty() ) if ( cap_str == nullptr )
{ {
std::cout << "\r\n"; std::cout << "\r\n";
return; return;
} }
for (auto&& ch : cap_str) const auto len = uInt(std::strlen(cap_str));
for (uInt i{0}; i < len; i++)
{ {
const auto c = uChar(ch); const auto c = uChar(cap_str[i]);
if ( c > 127 ) if ( c > 127 )
{ {
@ -210,9 +211,10 @@ void tcapString (const std::string& name, const char cap_string[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#if DEBUG #if DEBUG
void showDebug() void debug (const finalcut::FApplication& TermApp)
{ {
auto& debug_data = finalcut::FTermDebugData::getInstance(); const auto& fterm = TermApp.getFTerm();
auto& debug_data = fterm.getFTermDebugData();
const auto& ab_s = debug_data.getAnswerbackString(); const auto& 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";
@ -238,14 +240,14 @@ void showDebug()
std::cout << "`------------------- debug -------------------\r\n"; std::cout << "`------------------- debug -------------------\r\n";
} }
#else #else
void showDebug() void debug (const finalcut::FApplication&)
{ {
// FINAL CUT was compiled without debug option // FINAL CUT was compiled without debug option
} }
#endif #endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void showBooleans() void booleans()
{ {
std::cout << "\r\n[Booleans]\r\n"; std::cout << "\r\n[Booleans]\r\n";
tcapBoolean ( "background_color_erase" tcapBoolean ( "background_color_erase"
@ -273,7 +275,7 @@ void showBooleans()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void showNumeric() void numeric()
{ {
std::cout << "\r\n[Numeric]\r\n"; std::cout << "\r\n[Numeric]\r\n";
tcapNumeric ("max_color" tcapNumeric ("max_color"
@ -287,7 +289,7 @@ void showNumeric()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void showString() void string()
{ {
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;
@ -309,7 +311,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::getInstance(); auto& start_options = finalcut::FStartOptions::getFStartOptions();
start_options.color_change = false; start_options.color_change = false;
start_options.terminal_data_request = false; start_options.terminal_data_request = false;
@ -325,9 +327,10 @@ int main (int argc, char* argv[])
std::cout << "--------\r\nFTermcap\r\n--------\r\n\n"; std::cout << "--------\r\nFTermcap\r\n--------\r\n\n";
std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n"; std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n";
showDebug(); debug (term_app);
showBooleans();
showNumeric(); booleans();
showString(); numeric();
string();
return 0; return 0;
} }

View File

@ -427,7 +427,7 @@ void MyDialog::initMenu()
Drive.setStatusbarMessage ("Show drive symbols"); Drive.setStatusbarMessage ("Show drive symbols");
Line3.setSeparator(); Line3.setSeparator();
if ( finalcut::FStartOptions::getInstance().dark_theme ) if ( finalcut::FStartOptions::getFStartOptions().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.isEmpty() ) if ( file.isNull() )
return; return;
const auto& view = new TextWindow(this); const auto& view = new TextWindow(this);

View File

@ -110,15 +110,15 @@ Watch::Watch (FWidget* parent)
void Watch::printTime() void Watch::printTime()
{ {
finalcut::FString str{}; finalcut::FString str{};
struct tm local_tm; std::tm now{};
using namespace std::chrono;
auto now = system_clock::to_time_t(system_clock::now()); const std::time_t t = std::time(nullptr); // get current time
auto lt = *localtime_r(&now, &local_tm); localtime_r(&t, &now);
if ( sec ) if ( sec )
str.sprintf("%02d:%02d:%02d", lt.tm_hour, lt.tm_min, lt.tm_sec); str.sprintf("%02d:%02d:%02d", now.tm_hour, now.tm_min, now.tm_sec);
else else
str.sprintf("%02d:%02d ", lt.tm_hour, lt.tm_min); str.sprintf("%02d:%02d ", now.tm_hour, now.tm_min);
time_str = str; time_str = str;
time_str.redraw(); time_str.redraw();

View File

@ -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 -flto" export CPPFLAGS="%{optflags} -Wall -Wextra -Wpedantic"
%ifnarch %ix86 x86_64 %ifnarch %ix86 x86_64
export CPPFLAGS="$CPPFLAGS -Wno-error=unused-parameter" export CPPFLAGS="$CPPFLAGS -Wno-error=unused-parameter"
%endif %endif

View File

@ -1,4 +1,3 @@
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
@ -17,9 +16,6 @@ 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=**/**

View File

@ -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)
TimeValue FApplication::time_last_event {}; struct timeval FApplication::time_last_event {};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -90,7 +90,7 @@ FApplication::FApplication (const int& arg_c, char* arg_v[])
if ( internal::var::app_object ) if ( internal::var::app_object )
{ {
auto& fterm_data = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
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 = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
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,10 +392,11 @@ void FApplication::init()
setMaxChildren(1); setMaxChildren(1);
// Initialize the last event time // Initialize the last event time
time_last_event = TimeValue{}; time_last_event.tv_sec = 0;
time_last_event.tv_usec = 0;
// Initialize keyboard // Initialize keyboard
auto& keyboard = FKeyboard::getInstance(); auto& keyboard = FTerm::getFKeyboard();
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(); };
@ -412,7 +413,7 @@ void FApplication::init()
keyboard.setKeypressTimeout (key_timeout); keyboard.setKeypressTimeout (key_timeout);
// Initialize mouse control // Initialize mouse control
auto& mouse = FMouseControl::getInstance(); auto& mouse = FTerm::getFMouseControl();
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);
@ -443,7 +444,7 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
showParameterUsage(); showParameterUsage();
else else
{ {
auto& fterm_data = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
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)" );
@ -562,7 +563,7 @@ void FApplication::cmdOptions (const Args& args)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FStartOptions& FApplication::getStartOptions() inline FStartOptions& FApplication::getStartOptions()
{ {
return FStartOptions::getInstance(); return FStartOptions::getFStartOptions();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -657,8 +658,8 @@ inline void FApplication::findKeyboardWidget() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FApplication::isKeyPressed() const inline bool FApplication::isKeyPressed() const
{ {
auto& mouse = FMouseControl::getInstance(); auto& mouse = FTerm::getFMouseControl();
auto& keyboard = FKeyboard::getInstance(); auto& keyboard = FTerm::getFKeyboard();
if ( mouse.isGpmMouseEnabled() ) if ( mouse.isGpmMouseEnabled() )
return mouse.getGpmKeyPressed(keyboard.hasUnprocessedInput()); return mouse.getGpmKeyPressed(keyboard.hasUnprocessedInput());
@ -693,7 +694,7 @@ void FApplication::mouseTracking() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::performKeyboardAction() inline void FApplication::performKeyboardAction()
{ {
const auto& keyboard = FKeyboard::getInstance(); const auto& keyboard = FTerm::getFKeyboard();
if ( keyboard.getKey() == FKey::Ctrl_l ) // Ctrl-L (redraw the screen) if ( keyboard.getKey() == FKey::Ctrl_l ) // Ctrl-L (redraw the screen)
{ {
@ -712,8 +713,8 @@ inline void FApplication::performKeyboardAction()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::performMouseAction() const inline void FApplication::performMouseAction() const
{ {
auto& mouse = FMouseControl::getInstance(); auto& mouse = FTerm::getFMouseControl();
auto& keyboard = FKeyboard::getInstance(); auto& keyboard = FTerm::getFKeyboard();
const auto key = keyboard.getKey(); const auto key = keyboard.getKey();
auto& buffer = keyboard.getKeyBuffer(); auto& buffer = keyboard.getKeyBuffer();
@ -760,7 +761,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 = FKeyboard::getInstance(); const auto& keyboard = FTerm::getFKeyboard();
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();
@ -770,7 +771,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 = FKeyboard::getInstance(); const auto& keyboard = FTerm::getFKeyboard();
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();
@ -780,7 +781,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 = FKeyboard::getInstance(); const auto& keyboard = FTerm::getFKeyboard();
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();
@ -817,8 +818,8 @@ inline void FApplication::sendKeyboardAccelerator()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FApplication::hasDataInQueue() const inline bool FApplication::hasDataInQueue() const
{ {
const auto& keyboard = FKeyboard::getInstance(); const auto& keyboard = FTerm::getFKeyboard();
const auto& mouse = FMouseControl::getInstance(); const auto& mouse = FTerm::getFMouseControl();
if ( keyboard.hasDataInQueue() if ( keyboard.hasDataInQueue()
|| mouse.hasDataInQueue() || mouse.hasDataInQueue()
@ -837,7 +838,7 @@ void FApplication::queuingKeyboardInput() const
return; return;
findKeyboardWidget(); findKeyboardWidget();
auto& keyboard = FKeyboard::getInstance(); auto& keyboard = FTerm::getFKeyboard();
keyboard.escapeKeyHandling(); // special case: Esc key keyboard.escapeKeyHandling(); // special case: Esc key
keyboard.clearKeyBufferOnTimeout(); keyboard.clearKeyBufferOnTimeout();
@ -848,7 +849,7 @@ void FApplication::queuingKeyboardInput() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::queuingMouseInput() const void FApplication::queuingMouseInput() const
{ {
auto& mouse = FMouseControl::getInstance(); auto& mouse = FTerm::getFMouseControl();
if ( quit_now if ( quit_now
|| internal::var::exit_loop || internal::var::exit_loop
@ -856,8 +857,8 @@ void FApplication::queuingMouseInput() const
|| FTerm::hasChangedTermSize() ) || FTerm::hasChangedTermSize() )
return; return;
auto& keyboard = FKeyboard::getInstance(); auto& keyboard = FTerm::getFKeyboard();
auto time_keypressed = keyboard.getKeyPressedTime(); struct timeval* time_keypressed = keyboard.getKeyPressedTime();
mouse.processEvent (time_keypressed); mouse.processEvent (time_keypressed);
keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput(); keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput();
mouse.clearEvent(); mouse.clearEvent();
@ -871,7 +872,7 @@ void FApplication::processKeyboardEvent() const
|| FTerm::hasChangedTermSize() ) || FTerm::hasChangedTermSize() )
return; return;
auto& keyboard = FKeyboard::getInstance(); auto& keyboard = FTerm::getFKeyboard();
keyboard.processQueuedInput(); keyboard.processQueuedInput();
} }
@ -883,13 +884,13 @@ void FApplication::processMouseEvent() const
|| FTerm::hasChangedTermSize() ) || FTerm::hasChangedTermSize() )
return; return;
FMouseControl::getInstance().processQueuedInput(); FTerm::getFMouseControl().processQueuedInput();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FApplication::processDialogSwitchAccelerator() const bool FApplication::processDialogSwitchAccelerator() const
{ {
const auto& keyboard = FKeyboard::getInstance(); const auto& keyboard = FTerm::getFKeyboard();
if ( keyboard.getKey() >= FKey::Meta_1 if ( keyboard.getKey() >= FKey::Meta_1
&& keyboard.getKey() <= FKey::Meta_9 ) && keyboard.getKey() <= FKey::Meta_9 )
@ -927,7 +928,7 @@ bool FApplication::processAccelerator (const FWidget& widget) const
for (auto&& item : widget.getAcceleratorList()) for (auto&& item : widget.getAcceleratorList())
{ {
if ( item.key == FKeyboard::getInstance().getKey() ) if ( item.key == FTerm::getFKeyboard().getKey() )
{ {
// unset the move/size mode // unset the move/size mode
auto move_size = getMoveSizeWidget(); auto move_size = getMoveSizeWidget();
@ -1257,7 +1258,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 = FMouseControl::getInstance(); auto& mouse = FTerm::getFMouseControl();
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);
@ -1307,7 +1308,7 @@ bool FApplication::processNextEvent()
if ( is_timeout || hasDataInQueue() ) if ( is_timeout || hasDataInQueue() )
{ {
time_last_event = FObject::getCurrentTime(); FObject::getCurrentTime (&time_last_event);
queuingKeyboardInput(); queuingKeyboardInput();
queuingMouseInput(); queuingMouseInput();
processKeyboardEvent(); processKeyboardEvent();
@ -1400,7 +1401,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);
} }

View File

@ -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-2021 Markus Gans * * Copyright 2012-2020 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,7 +209,11 @@ 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();
} }
@ -319,12 +323,6 @@ void FButton::onMouseMove (FMouseEvent* ev)
} }
} }
//----------------------------------------------------------------------
void FButton::onWheel (FWheelEvent*)
{
setUp();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButton::onTimer (FTimerEvent* ev) void FButton::onTimer (FTimerEvent* ev)
{ {

View File

@ -361,7 +361,7 @@ void FButtonGroup::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::drawLabel() void FButtonGroup::drawLabel()
{ {
if ( text.isEmpty() ) if ( text.isNull() || text.isEmpty() )
return; return;
FString label_text{}; FString label_text{};

View File

@ -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-2021 Markus Gans * * Copyright 2015-2020 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,47 +29,10 @@
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
@ -198,8 +161,8 @@ FCharMap::CharEncodeType FCharMap::character =
* (2) Only supported in use with newfont * (2) Only supported in use with newfont
*/ */
//----------------------------------------------------------------------
constexpr FCharMap::DECGraphicsType FCharMap::dec_special_graphics = constexpr std::array<DECSpecialGraphics, 39> dec_special_graphics =
{{ {{
{VT100Key::rarrow , UniChar::BlackRightPointingPointer}, // ► {VT100Key::rarrow , UniChar::BlackRightPointingPointer}, // ►
{VT100Key::larrow , UniChar::BlackLeftPointingPointer}, // ◄ {VT100Key::larrow , UniChar::BlackLeftPointingPointer}, // ◄
@ -242,8 +205,7 @@ constexpr FCharMap::DECGraphicsType FCharMap::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
@ -503,9 +465,8 @@ constexpr FCharMap::Cp437UcsType FCharMap::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 FCharMap::HalfFullWidthType FCharMap::halfwidth_fullwidth = constexpr std::array<std::array<wchar_t, 2>, 227> halfwidth_fullwidth =
{{ {{
// Fullwidth ASCII variants // Fullwidth ASCII variants
{{0x0020, 0x3000}}, // ' ' -> ' ' {{0x0020, 0x3000}}, // ' ' -> ' '
@ -743,4 +704,7 @@ constexpr FCharMap::HalfFullWidthType FCharMap::halfwidth_fullwidth =
{{0xffee, 0x25cb}} // ○ -> ○ {{0xffee, 0x25cb}} // ○ -> ○
}}; }};
} // namespace fc
} // namespace finalcut } // namespace finalcut

View File

@ -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-2021 Markus Gans * * Copyright 2020 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,15 +39,6 @@ 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

View File

@ -611,7 +611,7 @@ void FComboBox::cb_closeComboBox()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FComboBox::cb_inputFieldSwitch() void FComboBox::cb_inputFieldSwitch()
{ {
auto& mouse = FMouseControl::getInstance(); auto& mouse = FTerm::getFMouseControl();
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 = FMouseControl::getInstance(); auto& mouse = FTerm::getFMouseControl();
if ( list_window.isHidden() ) if ( list_window.isHidden() )
return; return;

View File

@ -100,7 +100,7 @@ bool FDialog::setModal (bool enable)
if ( enable ) if ( enable )
{ {
setModalDialogCounter()++; setModalDialogCounter()++;
FKeyboard::getInstance().clearKeyBuffer(); FTerm::getFKeyboard().clearKeyBuffer();
} }
else else
setModalDialogCounter()--; setModalDialogCounter()--;

View File

@ -65,15 +65,15 @@ FString fileChooser ( FWidget* parent
FString path{dirname}; FString path{dirname};
FString file_filter{filter}; FString file_filter{filter};
if ( path.isEmpty() ) if ( path.isNull() || path.isEmpty() )
{ {
path.setString(FFileDialog::getHomeDir()); path.setString(FFileDialog::getHomeDir());
if ( path.isEmpty() ) if ( path.isNull() || path.isEmpty() )
path.setString("/"); path.setString("/");
} }
if ( file_filter.isEmpty() ) if ( file_filter.isNull() || 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.isEmpty() ) if ( ! dirname.isNull() )
setPath(dirname); setPath(dirname);
init(); init();
@ -162,7 +162,7 @@ void FFileDialog::setPath (const FString& dir)
return; return;
} }
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
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,16 +372,18 @@ 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::string search{}; std::array<char, 128> 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 = "."; search[0] = '.';
search.append(pattern); search[1] = '\0';
std::strncat(search.data(), pattern, search.size() - std::strlen(search.data()) - 1);
} }
else else
search = pattern; std::strncpy(search.data(), pattern, search.size() - 1);
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;
@ -478,13 +480,15 @@ int FFileDialog::readDir()
getEntry(dir, next); getEntry(dir, next);
} }
else else if ( errno != 0 )
{ {
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 )
@ -546,11 +550,16 @@ 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::string symLink{}; std::array<char, MAXPATHLEN> symLink{};
symLink.reserve(MAXPATHLEN);
struct stat sb{}; struct stat sb{};
const auto& fsystem = FSystem::getInstance();
symLink = dir + entry.name; const auto& fsystem = FTerm::getFSystem();
std::strncpy (symLink.data(), dir, symLink.size() - 1);
symLink[symLink.size() - 1] = '\0';
std::strncat ( symLink.data()
, entry.name.c_str()
, symLink.size() - std::strlen(symLink.data()) - 1);
symLink[symLink.size() - 1] = '\0';
if ( fsystem->realpath(symLink.data(), resolved_path.data()) == nullptr ) if ( fsystem->realpath(symLink.data(), resolved_path.data()) == nullptr )
return; // Cannot follow the symlink return; // Cannot follow the symlink
@ -682,7 +691,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
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) )
@ -726,7 +735,7 @@ void FFileDialog::cb_processActivate()
{ {
return ! entry.name.empty() return ! entry.name.empty()
&& input && input
&& ! input.isEmpty() && ! input.isNull()
&& std::strcmp(entry.name.c_str(), input.c_str()) == 0 && std::strcmp(entry.name.c_str(), input.c_str()) == 0
&& entry.directory; && entry.directory;
} }

View File

@ -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-2021 Markus Gans * * Copyright 2018-2020 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,33 +28,10 @@
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
@ -251,8 +228,7 @@ FKeyMap::KeyCapMapType FKeyMap::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
@ -488,8 +464,7 @@ constexpr FKeyMap::KeyMapType FKeyMap::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" },
@ -881,4 +856,6 @@ constexpr FKeyMap::KeyNameType FKeyMap::fkeyname =
{ FKey::Incomplete , "incomplete key string" } { FKey::Incomplete , "incomplete key string" }
}}; }};
} // namespace fc
} // namespace finalcut } // namespace finalcut

View File

@ -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};
TimeValue FKeyboard::time_keypressed{}; struct timeval FKeyboard::time_keypressed{};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -63,7 +63,8 @@ TimeValue FKeyboard::time_keypressed{};
FKeyboard::FKeyboard() FKeyboard::FKeyboard()
{ {
// Initialize keyboard values // Initialize keyboard values
time_keypressed = TimeValue{}; // Set to epoch time time_keypressed.tv_sec = 0;
time_keypressed.tv_usec = 0;
// Get the stdin file status flags // Get the stdin file status flags
stdin_status_flags = fcntl(FTermios::getStdIn(), F_GETFL); stdin_status_flags = fcntl(FTermios::getStdIn(), F_GETFL);
@ -74,13 +75,6 @@ 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()
{ {
@ -91,18 +85,17 @@ 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
( (
fkeyname.cbegin(), fc::fkeyname.cbegin(),
fkeyname.cend(), fc::fkeyname.cend(),
[&keynum] (const FKeyMap::KeyName& kn) [&keynum] (const fc::FKeyName& kn)
{ {
return ( kn.num != FKey::None && kn.num == keynum ); return ( kn.num != FKey::None && kn.num == keynum );
} }
); );
if ( found_key != fkeyname.end() ) if ( found_key != fc::fkeyname.end() )
return {found_key->string}; return {found_key->string};
if ( keynum > 32 && keynum < 127 ) if ( keynum > 32 && keynum < 127 )
@ -256,7 +249,7 @@ inline FKey FKeyboard::getMouseProtocolKey() const
if ( ! mouse_support ) if ( ! mouse_support )
return NOT_SET; return NOT_SET;
const std::size_t buf_len = stringLength(fifo_buf); const std::size_t buf_len = std::strlen(fifo_buf);
// x11 mouse tracking // 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' )
@ -289,7 +282,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 ? stringLength(kstr) : 0; const std::size_t len = kstr ? std::strlen(kstr) : 0;
if ( kstr && std::strncmp(kstr, fifo_buf, len) == 0 ) // found if ( kstr && std::strncmp(kstr, fifo_buf, len) == 0 ) // found
{ {
@ -316,10 +309,10 @@ inline FKey FKeyboard::getKnownKey()
assert ( FIFO_BUF_SIZE > 0 ); assert ( FIFO_BUF_SIZE > 0 );
for (auto&& entry : FKeyMap::getKeyMap()) for (auto&& entry : fc::fkey_table)
{ {
const char* kstr = entry.string; // The string is never null const char* kstr = entry.string; // The string is never null
const std::size_t len = stringLength(kstr); const std::size_t len = std::strlen(kstr);
if ( std::strncmp(kstr, fifo_buf, len) == 0 ) // found if ( std::strncmp(kstr, fifo_buf, len) == 0 ) // found
{ {
@ -362,7 +355,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 = stringLength(fifo_buf); const std::size_t buf_len = std::strlen(fifo_buf);
if ( (firstchar & 0xe0) == 0xc0 ) if ( (firstchar & 0xe0) == 0xc0 )
len = 2; len = 2;
@ -399,22 +392,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 std::string& utf8) const FKey FKeyboard::UTF8decode (const char utf8[]) const
{ {
using distance_type = std::string::difference_type;
FKey ucs{FKey::None}; // Universal coded character FKey ucs{FKey::None}; // Universal coded character
constexpr std::size_t max = 4; constexpr std::size_t max = 4;
const auto len = utf8.length(); std::size_t len = std::strlen(utf8);
auto end = utf8.begin()
+ static_cast<distance_type>(std::min(len, max));
for (auto iter{utf8.begin()}; iter < end; ++iter) if ( len > max )
len = max;
for (std::size_t i{0}; i < len; ++i)
{ {
const auto ch = uChar(*iter); const auto ch = uChar(utf8[i]);
if ( (ch & 0xc0) == 0x80 ) if ( (ch & 0xc0) == 0x80 )
{ {
@ -464,7 +457,7 @@ inline ssize_t FKeyboard::readKey()
void FKeyboard::parseKeyBuffer() void FKeyboard::parseKeyBuffer()
{ {
ssize_t bytesread{}; ssize_t bytesread{};
time_keypressed = FObject::getCurrentTime(); FObject::getCurrentTime (&time_keypressed);
while ( (bytesread = readKey()) > 0 ) while ( (bytesread = readKey()) > 0 )
{ {
@ -489,14 +482,14 @@ void FKeyboard::parseKeyBuffer()
{ {
key = fkey; key = fkey;
mouseTracking(); mouseTracking();
fifo_offset = int(stringLength(fifo_buf)); fifo_offset = int(std::strlen(fifo_buf));
break; break;
} }
if ( fkey != FKey::Incomplete ) if ( fkey != FKey::Incomplete )
{ {
fkey_queue.push(fkey); fkey_queue.push(fkey);
fifo_offset = int(stringLength(fifo_buf)); fifo_offset = int(std::strlen(fifo_buf));
} }
} }
@ -544,7 +537,7 @@ FKey FKeyboard::keyCorrection (const FKey& keycode) const
#if defined(__linux__) #if defined(__linux__)
if ( FTerm::isLinuxTerm() ) if ( FTerm::isLinuxTerm() )
{ {
auto& linux_console = FTermLinux::getInstance(); auto& linux_console = FTerm::getFTermLinux();
key_correction = linux_console.modifierKeyCorrection(keycode); key_correction = linux_console.modifierKeyCorrection(keycode);
} }
else else

View File

@ -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("\n"); multiline_text = text.split("\r\n");
if ( int(multiline_text.size()) > 1 ) if ( int(multiline_text.size()) > 1 )
multiline = true; multiline = true;

View File

@ -749,7 +749,7 @@ void FListBox::drawScrollbars() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::drawHeadline() void FListBox::drawHeadline()
{ {
if ( text.isEmpty() ) if ( text.isNull() || 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().isEmpty() ) if ( conv_type != ConvertType::Lazy || ! iter->getText().isNull() )
return; return;
lazy_inserter (*iter, source_container, y + std::size_t(yoffset)); lazy_inserter (*iter, source_container, y + std::size_t(yoffset));

View File

@ -910,7 +910,6 @@ 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);
@ -1428,60 +1427,6 @@ 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)
{ {
@ -1663,14 +1608,6 @@ 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;
@ -1678,7 +1615,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, is_current_mark, is_current_selected); drawListLine (item, getFlags().focus, is_current_line);
if ( getFlags().focus && is_current_line ) if ( getFlags().focus && is_current_line )
{ {
@ -1714,10 +1651,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_mark, bool is_selected ) , bool is_current )
{ {
// Set line color and attributes // Set line color and attributes
setLineAttributes (is_current, is_focus, is_mark, is_selected); setLineAttributes (is_current, is_focus);
// 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
@ -1821,13 +1758,12 @@ void FListView::clearList()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FListView::setLineAttributes ( bool is_current inline void FListView::setLineAttributes ( bool is_current
, bool is_focus, bool is_mark, bool is_selected ) const , bool is_focus ) const
{ {
const auto& wc = getColorTheme(); const auto& wc = getColorTheme();
setColor (wc->list_fg, wc->list_bg); setColor (wc->list_fg, wc->list_bg);
if ( is_mark )
setColor ( FColor::White, FColor::Red ); if ( is_current )
else if ( is_current )
{ {
if ( is_focus && FTerm::getMaxColor() < 16 ) if ( is_focus && FTerm::getMaxColor() < 16 )
setBold(); setBold();
@ -1847,8 +1783,6 @@ 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() )

View File

@ -281,7 +281,7 @@ void FMessageBox::calculateDimensions()
if ( text_num_lines == 0 ) if ( text_num_lines == 0 )
return; return;
if ( ! headline_text.isEmpty() ) if ( ! headline_text.isNull() )
headline_height = 2; headline_height = 2;
for (auto&& line : text_components) for (auto&& line : text_components)

View File

@ -196,37 +196,37 @@ FString FMouse::getClassName() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouse::clearEvent() inline void FMouse::clearEvent()
{ {
mouse_event_occurred = false; mouse_event_occurred = false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouse::setMaxWidth (uInt16 x_max) inline void FMouse::setMaxWidth (uInt16 x_max)
{ {
max_width = x_max; max_width = x_max;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouse::setMaxHeight (uInt16 y_max) inline void FMouse::setMaxHeight (uInt16 y_max)
{ {
max_height = y_max; max_height = y_max;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouse::setDblclickInterval (const uInt64 timeout) inline void FMouse::setDblclickInterval (const uInt64 timeout)
{ {
dblclick_interval = timeout; dblclick_interval = timeout;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouse::hasEvent() const inline bool FMouse::hasEvent() const
{ {
return mouse_event_occurred; return mouse_event_occurred;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouse::hasUnprocessedInput() const inline bool FMouse::hasUnprocessedInput() const
{ {
return unprocessed_buffer_data; return unprocessed_buffer_data;
} }
@ -234,7 +234,7 @@ bool FMouse::hasUnprocessedInput() const
// protected methods of FMouse // protected methods of FMouse
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FPoint& FMouse::getNewPos() const inline const FPoint& FMouse::getNewPos() const
{ {
return new_mouse_position; return new_mouse_position;
} }
@ -258,9 +258,9 @@ uInt64 FMouse::getDblclickInterval() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
TimeValue FMouse::getMousePressedTime() const timeval* FMouse::getMousePressedTime()
{ {
return time_mousepressed; return &time_mousepressed;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -276,15 +276,16 @@ void FMouse::setPending (bool is_pending)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouse::setMousePressedTime (const TimeValue& time) void FMouse::setMousePressedTime (const timeval* time)
{ {
time_mousepressed = time; time_mousepressed = *time;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouse::resetMousePressedTime() void FMouse::resetMousePressedTime()
{ {
time_mousepressed = TimeValue{}; // Set to epoch time time_mousepressed.tv_sec = 0;
time_mousepressed.tv_usec = 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -294,7 +295,7 @@ void FMouse::setEvent()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouse::isDblclickTimeout (const TimeValue& time) const bool FMouse::isDblclickTimeout (const timeval* time) const
{ {
return FObject::isTimeout (time, dblclick_interval); return FObject::isTimeout (time, dblclick_interval);
} }
@ -340,7 +341,7 @@ void FMouseGPM::setRawData (FKeyboard::keybuffer&)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseGPM::processEvent (const TimeValue&) void FMouseGPM::processEvent (struct timeval*)
{ {
clearButtonState(); clearButtonState();
@ -581,7 +582,7 @@ void FMouseX11::setRawData (FKeyboard::keybuffer& fifo_buf)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseX11::processEvent (const TimeValue& time) void FMouseX11::processEvent (struct timeval* time)
{ {
// Parse and interpret the X11 xterm mouse string // Parse and interpret the X11 xterm mouse string
@ -640,7 +641,7 @@ void FMouseX11::setMoveState (const FPoint& mouse_position, int btn)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseX11::setButtonState (const int btn, const TimeValue& time) void FMouseX11::setButtonState (const int btn, const struct timeval* time)
{ {
// Get the x11 mouse button state // Get the x11 mouse button state
@ -738,7 +739,7 @@ void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
// Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data // 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 = stringLength(fifo_buf); std::size_t len = std::strlen(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 )
@ -764,7 +765,7 @@ void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseSGR::processEvent (const TimeValue& time) void FMouseSGR::processEvent (struct timeval* time)
{ {
const auto& mouse_position = getPos(); const auto& mouse_position = getPos();
uInt16 x{0}; uInt16 x{0};
@ -866,7 +867,7 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseSGR::setPressedButtonState ( const int btn void FMouseSGR::setPressedButtonState ( const int btn
, const TimeValue& time ) , const struct timeval* time )
{ {
// Gets the extended x11 mouse mode (SGR) status for pressed buttons // Gets the extended x11 mouse mode (SGR) status for pressed buttons
@ -968,7 +969,7 @@ void FMouseUrxvt::setRawData (FKeyboard::keybuffer& fifo_buf)
// Import the X11 xterm mouse protocol (Urxvt-Mode) raw mouse data // 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 = stringLength(fifo_buf); std::size_t len = std::strlen(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 )
@ -994,7 +995,7 @@ void FMouseUrxvt::setRawData (FKeyboard::keybuffer& fifo_buf)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseUrxvt::processEvent (const TimeValue& time) void FMouseUrxvt::processEvent (struct timeval* time)
{ {
// Parse and interpret the X11 xterm mouse string (Urxvt-Mode) // Parse and interpret the X11 xterm mouse string (Urxvt-Mode)
@ -1121,7 +1122,7 @@ void FMouseUrxvt::setMoveState (const FPoint& mouse_position, int btn)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseUrxvt::setButtonState (const int btn, const TimeValue& time) void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
{ {
// Get the urxvt mouse button state // Get the urxvt mouse button state
@ -1204,16 +1205,14 @@ void FMouseUrxvt::setButtonState (const int btn, const TimeValue& 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[mt::Gpm].reset(FMouse::createMouseObject<FMouseGPM>()); mouse_protocol[FMouse::MouseType::Gpm].reset(FMouse::createMouseObject<FMouseGPM>());
#endif #endif
mouse_protocol[mt::X11].reset(FMouse::createMouseObject<FMouseX11>()); mouse_protocol[FMouse::MouseType::X11].reset(FMouse::createMouseObject<FMouseX11>());
mouse_protocol[mt::Sgr].reset(FMouse::createMouseObject<FMouseSGR>()); mouse_protocol[FMouse::MouseType::Sgr].reset(FMouse::createMouseObject<FMouseSGR>());
mouse_protocol[mt::Urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>()); mouse_protocol[FMouse::MouseType::Urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1221,13 +1220,6 @@ 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()
{ {
@ -1569,7 +1561,7 @@ void FMouseControl::processQueuedInput()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::processEvent (const TimeValue& time) void FMouseControl::processEvent (struct timeval* time)
{ {
auto mtype = getMouseWithData(); auto mtype = getMouseWithData();
auto mouse_object = mouse_protocol[mtype].get(); auto mouse_object = mouse_protocol[mtype].get();

View File

@ -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-2021 Markus Gans * * Copyright 2015-2020 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,7 +21,6 @@
***********************************************************************/ ***********************************************************************/
#include <memory> #include <memory>
#include <mutex>
#include "final/fevent.h" #include "final/fevent.h"
#include "final/fc.h" #include "final/fc.h"
@ -30,17 +29,8 @@
namespace finalcut namespace finalcut
{ {
namespace internal // static class attributes
{ bool FObject::timer_modify_lock;
struct var
{
static std::mutex timer_mutex;
};
std::mutex var::timer_mutex{};
} // namespace internal
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -54,6 +44,8 @@ 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;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -187,24 +179,54 @@ bool FObject::event (FEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
TimeValue FObject::getCurrentTime() void FObject::getCurrentTime (timeval* time)
{ {
return system_clock::now(); // Get the current time // Get the current time as timeval struct
gettimeofday(time, nullptr);
// NTP fix
while ( time->tv_usec >= 1000000 )
{
time->tv_usec -= 1000000;
time->tv_sec++;
}
while ( time->tv_usec < 0 )
{
if ( time->tv_sec > 0 )
{
time->tv_usec += 1000000;
time->tv_sec--;
}
else
{
time->tv_usec = 0;
break;
}
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FObject::isTimeout (const TimeValue& time, uInt64 timeout) bool FObject::isTimeout (const timeval* time, uInt64 timeout)
{ {
// Checks whether the specified time span (timeout in µs) has elapsed // Checks whether the specified time span (timeout in µs) has elapse
const auto now = getCurrentTime(); struct timeval now{};
struct timeval diff{};
if ( now < time ) FObject::getCurrentTime(&now);
return false; diff.tv_sec = now.tv_sec - time->tv_sec;
diff.tv_usec = now.tv_usec - time->tv_usec;
const auto diff = now - time; if ( diff.tv_usec < 0 )
const auto diff_usec = uInt64(duration_cast<microseconds>(diff).count()); {
return diff_usec > timeout; diff.tv_sec--;
diff.tv_usec += 1000000;
}
const auto diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec);
return ( diff_usec > timeout );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -213,8 +235,10 @@ int FObject::addTimer (int interval)
// Create a timer and returns the timer identifier number // 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};
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex); timer_modify_lock = true;
auto& timer_list = globalTimerList(); auto& timer_list = globalTimerList();
// find an unused timer id // find an unused timer id
@ -238,8 +262,10 @@ 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;
const auto time_interval = milliseconds(interval); time_interval.tv_sec = interval / 1000;
const auto timeout = getCurrentTime() + time_interval; time_interval.tv_usec = (interval % 1000) * 1000;
getCurrentTime (&currentTime);
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
@ -250,6 +276,7 @@ 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;
} }
@ -261,7 +288,7 @@ bool FObject::delTimer (int id) const
if ( id <= 0 ) if ( id <= 0 )
return false; return false;
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex); timer_modify_lock = true;
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();
@ -272,9 +299,11 @@ 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;
} }
@ -283,7 +312,6 @@ 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 )
@ -292,6 +320,7 @@ 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() )
@ -302,6 +331,7 @@ bool FObject::delOwnTimers() const
++iter; ++iter;
} }
timer_modify_lock = false;
return true; return true;
} }
@ -310,7 +340,6 @@ 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 )
@ -319,8 +348,10 @@ 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;
} }
@ -343,17 +374,20 @@ 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 );
if ( ! unique_lock.try_lock() ) getCurrentTime (&currentTime);
if ( isTimerInUpdating() )
return 0; return 0;
auto currentTime = getCurrentTime();
auto& timer_list = globalTimerList(); auto& timer_list = globalTimerList();
if ( ! timer_list || timer_list->empty() ) if ( ! timer_list )
return 0;
if ( timer_list->empty() )
return 0; return 0;
for (auto&& timer : *timer_list) for (auto&& timer : *timer_list)
@ -368,7 +402,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 > microseconds(0) ) if ( timer.interval.tv_usec > 0 || timer.interval.tv_sec > 0 )
activated++; activated++;
FTimerEvent t_ev(Event::Timer, timer.id); FTimerEvent t_ev(Event::Timer, timer.id);

View File

@ -39,8 +39,6 @@ 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;
@ -51,13 +49,6 @@ 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)
{ {
@ -552,11 +543,11 @@ FColor FOptiAttr::vga2ansi (FColor color)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::string FOptiAttr::changeAttribute (FChar& term, FChar& next) const char* FOptiAttr::changeAttribute (FChar& term, FChar& next)
{ {
const bool next_has_color = hasColor(next); const bool next_has_color = hasColor(next);
fake_reverse = false; fake_reverse = false;
attr_buf.clear(); attr_buf[0] = '\0';
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);
@ -568,7 +559,7 @@ std::string 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 {}; return nullptr;
if ( hasNoAttribute(next) ) if ( hasNoAttribute(next) )
{ {
@ -584,10 +575,10 @@ std::string FOptiAttr::changeAttribute (FChar& term, FChar& next)
changeAttributeSeparately (term, next); changeAttributeSeparately (term, next);
} }
if ( FStartOptions::getInstance().sgr_optimizer ) if ( FStartOptions::getFStartOptions().sgr_optimizer )
sgr_optimizer.optimize(); sgr_optimizer.optimize();
return attr_buf; return attr_buf.data();
} }
@ -888,31 +879,34 @@ inline bool FOptiAttr::unsetTermDoubleUnderline (FChar& term)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FOptiAttr::setTermAttributes (FChar& term, const TCapAttributes& attr) bool FOptiAttr::setTermAttributes ( FChar& term
, bool p1, bool p2, bool p3
, bool p4, bool p5, bool p6
, bool p7, bool p8, bool p9 )
{ {
if ( F_set_attributes.cap ) if ( F_set_attributes.cap )
{ {
const auto sgr = FTermcap::encodeParameter ( F_set_attributes.cap const auto sgr = FTermcap::encodeParameter ( F_set_attributes.cap
, attr.p1 && ! fake_reverse , p1 && ! fake_reverse
, attr.p2 , p2
, attr.p3 && ! fake_reverse , p3 && ! fake_reverse
, attr.p4 , p4
, attr.p5 , p5
, attr.p6 , p6
, attr.p7 , p7
, attr.p8 , p8
, attr.p9 ); , p9 );
append_sequence (sgr.data()); append_sequence (sgr.data());
resetColor(term); resetColor(term);
term.attr.bit.standout = attr.p1; term.attr.bit.standout = p1;
term.attr.bit.underline = attr.p2; term.attr.bit.underline = p2;
term.attr.bit.reverse = attr.p3; term.attr.bit.reverse = p3;
term.attr.bit.blink = attr.p4; term.attr.bit.blink = p4;
term.attr.bit.dim = attr.p5; term.attr.bit.dim = p5;
term.attr.bit.bold = attr.p6; term.attr.bit.bold = p6;
term.attr.bit.invisible = attr.p7; term.attr.bit.invisible = p7;
term.attr.bit.protect = attr.p8; term.attr.bit.protect = p8;
term.attr.bit.alt_charset = attr.p9; term.attr.bit.alt_charset = 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;
@ -1240,7 +1234,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
@ -1248,7 +1242,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
@ -1543,7 +1537,9 @@ inline bool FOptiAttr::append_sequence (const char seq[])
if ( ! seq ) if ( ! seq )
return false; return false;
attr_buf.append(seq); char* attr_ptr{attr_buf.data()};
std::strncat (attr_ptr, seq, attr_buf.size() - std::strlen(attr_ptr));
attr_buf[attr_buf.size() - 1] = '\0';
return true; return true;
} }

View File

@ -42,7 +42,6 @@ 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
@ -55,13 +54,6 @@ 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)
{ {
@ -489,7 +481,7 @@ void FOptiMove::check_boundaries ( int& xold, int& yold
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::string FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew) const char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
{ {
int method{0}; int method{0};
int move_time{LONG_DURATION}; int move_time{LONG_DURATION};
@ -502,7 +494,7 @@ std::string 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 : std::string{}; return ( move_time < LONG_DURATION ) ? move_buf : nullptr;
} }
// Method 1: local movement // Method 1: local movement
@ -531,7 +523,7 @@ std::string FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
if ( move_time < LONG_DURATION ) if ( move_time < LONG_DURATION )
return move_buf; return move_buf;
else else
return {}; return nullptr;
} }
@ -611,23 +603,30 @@ int FOptiMove::capDurationToLength (int duration) const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FOptiMove::repeatedAppend ( std::string& dst int FOptiMove::repeatedAppend ( const Capability& o
, const Capability& o , int count
, int count ) const , char* dst ) const
{ {
const std::size_t src_len = stringLength(o.cap); const std::size_t src_len = std::strlen(o.cap);
const std::size_t dst_len = dst.length(); const std::size_t dst_len = ( dst != nullptr ) ? std::strlen(dst) : 0;
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 )
{ {
cnt--; std::strncpy (dst, o.cap, free);
dst.append(o.cap); dst += src_len;
free -= src_len;
}
} }
} }
else else
@ -637,15 +636,15 @@ int FOptiMove::repeatedAppend ( std::string& dst
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FOptiMove::relativeMove ( std::string& move int FOptiMove::relativeMove ( char move[]
, int from_x, int from_y , int 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.empty() ) if ( move )
move.clear(); move[0] = '\0';
if ( to_y != from_y ) // vertical move if ( to_y != from_y ) // vertical move
{ {
@ -657,30 +656,41 @@ int FOptiMove::relativeMove ( std::string& move
if ( to_x != from_x ) // horizontal move if ( to_x != from_x ) // horizontal move
{ {
std::string hmove{}; char hmove[BUF_SIZE]{};
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.empty() ) if ( move )
move.append(hmove); {
if ( *move )
std::strncat (move, hmove, BUF_SIZE - std::strlen(move));
else else
move = hmove; std::strncpy (move, hmove, BUF_SIZE);
move[BUF_SIZE - 1] = '\0';
}
} }
return vtime + htime; return vtime + htime;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FOptiMove::verticalMove (std::string& move, int from_y, int to_y) const inline int FOptiMove::verticalMove (char move[], int from_y, int to_y) const
{ {
int vtime{LONG_DURATION}; int vtime{LONG_DURATION};
if ( F_row_address.cap ) if ( F_row_address.cap )
{ {
// Move to fixed row position if ( move )
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;
} }
@ -693,56 +703,73 @@ inline int FOptiMove::verticalMove (std::string& move, int from_y, int to_y) con
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::downMove ( std::string& move, int& vtime inline void FOptiMove::downMove ( char move[], int& vtime
, int from_y, int to_y ) const , 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 )
{ {
move = FTermcap::encodeParameter(F_parm_down_cursor.cap, num); if ( move )
{
std::strncpy ( move
, FTermcap::encodeParameter(F_parm_down_cursor.cap, num).data()
, BUF_SIZE );
move[BUF_SIZE - 1] = '\0';
}
vtime = F_parm_down_cursor.duration; 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.empty() ) if ( move )
move.clear(); move[0] = '\0';
vtime = repeatedAppend (move, F_cursor_down, num); vtime = repeatedAppend (F_cursor_down, num, move);
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::upMove ( std::string& move, int& vtime inline void FOptiMove::upMove ( char move[], int& vtime
, int from_y, int to_y ) const , 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 )
{ {
move = FTermcap::encodeParameter(F_parm_up_cursor.cap, num); if ( move )
{
std::strncpy ( move
, FTermcap::encodeParameter(F_parm_up_cursor.cap, num).data()
, BUF_SIZE );
move[BUF_SIZE - 1] = '\0';
}
vtime = F_parm_up_cursor.duration; 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.empty() ) if ( move )
move.clear(); move[0] = '\0';
vtime = repeatedAppend (move, F_cursor_up, num); vtime = repeatedAppend (F_cursor_up, num, move);
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FOptiMove::horizontalMove (std::string& hmove, int from_x, int to_x) const inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x) const
{ {
int htime{LONG_DURATION}; int htime{LONG_DURATION};
if ( F_column_address.cap ) if ( F_column_address.cap )
{ {
// Move to fixed column position // Move to fixed column position1
hmove = FTermcap::encodeParameter(F_column_address.cap, to_x); std::strncat ( hmove
, FTermcap::encodeParameter(F_column_address.cap, to_x).data()
, BUF_SIZE - std::strlen(hmove) - 1 );
hmove[BUF_SIZE - 1] = '\0';
htime = F_column_address.duration; htime = F_column_address.duration;
} }
@ -755,21 +782,25 @@ inline int FOptiMove::horizontalMove (std::string& hmove, int from_x, int to_x)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::rightMove ( std::string& hmove, int& htime inline void FOptiMove::rightMove ( char hmove[], int& htime
, int from_x, int to_x ) const , int 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 )
{ {
hmove = FTermcap::encodeParameter(F_parm_right_cursor.cap, num); std::strncpy ( hmove
, FTermcap::encodeParameter(F_parm_right_cursor.cap, num).data()
, BUF_SIZE - 1);
hmove[BUF_SIZE - 1] = '\0';
htime = F_parm_right_cursor.duration; htime = F_parm_right_cursor.duration;
} }
if ( F_cursor_right.cap ) if ( F_cursor_right.cap )
{ {
std::string str{}; std::array<char, BUF_SIZE> 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 )
@ -783,7 +814,7 @@ inline void FOptiMove::rightMove ( std::string& hmove, int& htime
if ( tab_pos > to_x ) if ( tab_pos > to_x )
break; break;
htime_r += repeatedAppend (str, F_tab, 1); htime_r += repeatedAppend (F_tab, 1, str.data());
if ( htime_r >= LONG_DURATION ) if ( htime_r >= LONG_DURATION )
break; break;
@ -794,32 +825,37 @@ inline void FOptiMove::rightMove ( std::string& hmove, int& htime
num = to_x - pos; num = to_x - pos;
} }
htime_r += repeatedAppend (str, F_cursor_right, num); htime_r += repeatedAppend (F_cursor_right, num, str.data());
if ( htime_r < htime ) if ( htime_r < htime )
{ {
hmove = str; std::strncpy (hmove, str.data(), BUF_SIZE);
hmove[BUF_SIZE - 1] = '\0';
htime = htime_r; htime = htime_r;
} }
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::leftMove ( std::string& hmove, int& htime inline void FOptiMove::leftMove ( char hmove[], int& htime
, int from_x, int to_x ) const , int 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 )
{ {
hmove = FTermcap::encodeParameter(F_parm_left_cursor.cap, num); std::strncpy ( hmove
, FTermcap::encodeParameter(F_parm_left_cursor.cap, num).data()
, BUF_SIZE - 1);
hmove[BUF_SIZE - 1] = '\0';
htime = F_parm_left_cursor.duration; htime = F_parm_left_cursor.duration;
} }
if ( F_cursor_left.cap ) if ( F_cursor_left.cap )
{ {
std::string str{}; std::array<char, BUF_SIZE> 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 )
@ -833,7 +869,7 @@ inline void FOptiMove::leftMove ( std::string& hmove, int& htime
if ( tab_pos < to_x ) if ( tab_pos < to_x )
break; break;
htime_l += repeatedAppend (str, F_back_tab, 1); htime_l += repeatedAppend (F_back_tab, 1, str.data());
if ( htime_l >= LONG_DURATION ) if ( htime_l >= LONG_DURATION )
break; break;
@ -844,11 +880,12 @@ inline void FOptiMove::leftMove ( std::string& hmove, int& htime
num = pos - to_x; num = pos - to_x;
} }
htime_l += repeatedAppend (str, F_cursor_left, num); htime_l += repeatedAppend (F_cursor_left, num, str.data());
if ( htime_l < htime ) if ( htime_l < htime )
{ {
hmove = str; std::strncpy (hmove, str.data(), BUF_SIZE);
hmove[BUF_SIZE - 1] = '\0';
htime = htime_l; htime = htime_l;
} }
} }
@ -877,7 +914,9 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time
if ( ! move_xy.empty() ) if ( ! move_xy.empty() )
{ {
move_buf = move_xy; std::strncpy ( static_cast<char*>(move_buf)
, move_xy.data(), BUF_SIZE - 1 );
move_buf[BUF_SIZE - 1] = '\0';
move_time = F_cursor_address.duration; move_time = F_cursor_address.duration;
return true; return true;
} }
@ -894,8 +933,8 @@ inline bool FOptiMove::isMethod1Faster ( int& move_time
if ( xold >= 0 && yold >= 0 ) if ( xold >= 0 && yold >= 0 )
{ {
std::string null_result{}; std::array<char, BUF_SIZE> null_result{};
const int new_time = relativeMove (null_result, xold, yold, xnew, ynew); const int new_time = relativeMove (null_result.data(), xold, yold, xnew, ynew);
if ( new_time < LONG_DURATION && new_time < move_time ) if ( new_time < LONG_DURATION && new_time < move_time )
{ {
@ -916,8 +955,8 @@ inline bool FOptiMove::isMethod2Faster ( int& move_time
if ( yold >= 0 && F_carriage_return.cap ) if ( yold >= 0 && F_carriage_return.cap )
{ {
std::string null_result{}; std::array<char, BUF_SIZE> null_result{};
const int new_time = relativeMove (null_result, 0, yold, xnew, ynew); const int new_time = relativeMove (null_result.data(), 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 )
@ -938,8 +977,8 @@ inline bool FOptiMove::isMethod3Faster ( int& move_time
if ( F_cursor_home.cap ) if ( F_cursor_home.cap )
{ {
std::string null_result{}; std::array<char, BUF_SIZE> null_result{};
const int new_time = relativeMove (null_result, 0, 0, xnew, ynew); const int new_time = relativeMove (null_result.data(), 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 )
@ -959,9 +998,10 @@ 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::string null_result{}; std::array<char, BUF_SIZE> null_result{};
int down = int(screen_height) - 1; const int new_time = relativeMove ( null_result.data()
const int new_time = relativeMove (null_result, 0, down, xnew, ynew); , 0, int(screen_height) - 1
, 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 )
@ -985,10 +1025,10 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
&& yold > 0 && yold > 0
&& F_cursor_left.cap ) && F_cursor_left.cap )
{ {
std::string null_result{}; std::array<char, BUF_SIZE> null_result{};
int x = int(screen_width) - 1; const int new_time = relativeMove ( null_result.data()
int y = yold - 1; , int(screen_width) - 1, yold - 1
const int new_time = relativeMove (null_result, x, y, xnew, ynew); , xnew, ynew );
if ( new_time < LONG_DURATION if ( new_time < LONG_DURATION
&& F_carriage_return.cap && F_carriage_return.cap
@ -997,6 +1037,7 @@ 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;
} }
} }
@ -1009,55 +1050,52 @@ 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_buf, xold, yold, xnew, ynew); relativeMove (move_ptr, xold, yold, xnew, ynew);
break; break;
case 2: case 2:
if ( F_carriage_return.cap ) if ( F_carriage_return.cap )
{ {
move_buf = F_carriage_return.cap; std::strncpy (move_ptr, F_carriage_return.cap, BUF_SIZE - 1);
std::string s{}; move_ptr[BUF_SIZE - 1] ='\0';
relativeMove (s, 0, yold, xnew, ynew); move_ptr += F_carriage_return.length;
move_buf.append(s); relativeMove (move_ptr, 0, yold, xnew, ynew);
} }
break; break;
case 3: case 3:
move_buf = F_cursor_home.cap; std::strncpy (move_ptr, F_cursor_home.cap, BUF_SIZE - 1);
{ move_ptr[BUF_SIZE - 1] ='\0';
std::string s{}; move_ptr += F_cursor_home.length;
relativeMove (s, 0, 0, xnew, ynew); relativeMove (move_ptr, 0, 0, xnew, ynew);
move_buf.append(s);
}
break; break;
case 4: case 4:
move_buf = F_cursor_to_ll.cap; std::strncpy (move_ptr, F_cursor_to_ll.cap, BUF_SIZE - 1);
{ move_ptr[BUF_SIZE - 1] ='\0';
std::string s{}; move_ptr += F_cursor_to_ll.length;
int down = int(screen_height) - 1; relativeMove (move_ptr, 0, int(screen_height) - 1, xnew, ynew);
relativeMove (s, 0, down, xnew, ynew);
move_buf.append(s);
}
break; break;
case 5: case 5:
if ( xold >= 0 ) move_buf[0] = '\0';
move_buf = F_carriage_return.cap;
else
move_buf.clear();
move_buf.append(F_cursor_left.cap); if ( xold >= 0 )
{ std::strncat ( move_ptr
std::string s{}; , F_carriage_return.cap
int x = int(screen_width) - 1; , BUF_SIZE - std::strlen(move_ptr) - 1 );
int y = yold - 1;
relativeMove (s, x, y, xnew, ynew); std::strncat ( move_ptr
move_buf.append(s); , F_cursor_left.cap
} , BUF_SIZE - std::strlen(move_ptr) - 1);
move_ptr[BUF_SIZE - 1] ='\0';
move_ptr += std::strlen(move_buf);
relativeMove (move_ptr, int(screen_width) - 1, yold - 1, xnew, ynew);
break; break;
default: default:

View File

@ -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-2021 Markus Gans * * Copyright 2019-2020 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
//---------------------------------------------------------------------- //----------------------------------------------------------------------
auto FStartOptions::getInstance() -> FStartOptions& FStartOptions& FStartOptions::getFStartOptions()
{ {
static const auto& start_options = make_unique<FStartOptions>(); static const auto& start_options = make_unique<FStartOptions>();
return *start_options; return *start_options;

File diff suppressed because it is too large Load Diff

View File

@ -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-2021 Markus Gans * * Copyright 2019-2020 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,7 +21,6 @@
***********************************************************************/ ***********************************************************************/
#include "final/fsystem.h" #include "final/fsystem.h"
#include "final/fsystemimpl.h"
namespace finalcut namespace finalcut
{ {
@ -34,14 +33,5 @@ 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

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,9 @@ 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);
@ -196,9 +199,9 @@ constexpr std::array<UniChar, 20> reverse_newfont_list =
// FTerm non-member functions // FTerm non-member functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uInt env2uint (const std::string& env) uInt env2uint (const char* env)
{ {
const FString str{getenv(env.data())}; const FString str{getenv(env)};
if ( str.isEmpty() ) if ( str.isEmpty() )
return 0; return 0;
@ -256,9 +259,6 @@ 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,16 +284,15 @@ 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 ( cp437_ucs.begin() auto found = std::find_if ( fc::cp437_ucs.begin()
, cp437_ucs.end() , fc::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 != cp437_ucs.end() ) if ( found != fc::cp437_ucs.end() )
ucs = (*found)[UNICODE]; ucs = (*found)[UNICODE];
return ucs; return ucs;
@ -304,16 +303,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()
, cp437_ucs.end() auto found = std::find_if ( fc::cp437_ucs.begin()
, 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 != cp437_ucs.end() ) if ( found != fc::cp437_ucs.end() )
c = static_cast<uChar>((*found)[CP437]); c = static_cast<uChar>((*found)[CP437]);
return c; return c;
@ -327,17 +326,16 @@ 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 ( halfwidth_fullwidth.begin() auto found = std::find_if ( fc::halfwidth_fullwidth.begin()
, halfwidth_fullwidth.end() , fc::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 != halfwidth_fullwidth.end() ) if ( found != fc::halfwidth_fullwidth.end() )
c = (*found)[FULL]; c = (*found)[FULL];
}; };
@ -360,17 +358,16 @@ 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 ( halfwidth_fullwidth.begin() auto found = std::find_if ( fc::halfwidth_fullwidth.begin()
, halfwidth_fullwidth.end() , fc::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 != halfwidth_fullwidth.end() ) if ( found != fc::halfwidth_fullwidth.end() )
c = (*found)[HALF]; c = (*found)[HALF];
}; };
@ -692,10 +689,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{};
const std::string DECXCPR{ESC "[6n"}; constexpr auto& DECXCPR{ESC "[6n"};
// Report Cursor Position (DECXCPR) // Report Cursor Position (DECXCPR)
if ( write(stdout_no, DECXCPR.data(), DECXCPR.length()) < 1 ) if ( write(stdout_no, DECXCPR, std::strlen(DECXCPR)) < 1 )
return {x, y}; return {x, y};
std::fflush(stdout); std::fflush(stdout);

View File

@ -66,6 +66,7 @@ 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();
@ -151,7 +152,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
, const FString::const_iterator& end , FString::const_iterator& end
, int& char_width ) , int& char_width )
{ {
if ( begin == end ) if ( begin == end )

View File

@ -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 = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
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 = FTermData::getInstance().getTermType(); const auto& termtype = FTerm::getFTermData().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 = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
// 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 : FKeyMap::getKeyCapMap()) for (auto&& entry : fc::fkey_cap_table)
{ {
if ( entry.string != nullptr ) // String is already set if ( entry.string != nullptr ) // String is already set
break; break;
@ -437,8 +437,10 @@ void FTermcap::termcapKeys()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::string FTermcap::encodeParams ( const std::string& cap std::string FTermcap::encodeParams ( const std::string& cap
, const std::array<int, 9>& params ) , const std::vector<int>& param_vec )
{ {
std::array<int, 9> params{{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
std::copy (param_vec.begin(), param_vec.end(), params.begin());
auto str = ::tparm ( C_STR(cap.data()), params[0], params[1] 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] );

View File

@ -42,7 +42,7 @@ namespace finalcut
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapQuirks::terminalFixup() void FTermcapQuirks::terminalFixup()
{ {
const auto& td = FTermDetection::getInstance(); const auto& td = FTerm::getFTermDetection();
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 = FTermData::getInstance().getTermType(); const auto& termtype = FTerm::getFTermData().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 ( ! FTermDetection::getInstance().isUrxvtTerminal() ) if ( ! FTerm::getFTermDetection().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 = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
// 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,74 +370,73 @@ 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}; fkey_cap_table[i].tname[0] != 0; i++) for (std::size_t i{0}; fc::fkey_cap_table[i].tname[0] != 0; i++)
{ {
if ( std::strncmp(fkey_cap_table[i].tname, "K2", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "K2", 2) == 0 )
fkey_cap_table[i].string = CSI "218z"; // center of keypad fc::fkey_cap_table[i].string = CSI "218z"; // center of keypad
if ( std::strncmp(fkey_cap_table[i].tname, "kb", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "kb", 2) == 0 )
fkey_cap_table[i].string = "\b"; // backspace key fc::fkey_cap_table[i].string = "\b"; // backspace key
if ( std::strncmp(fkey_cap_table[i].tname, "kD", 2) == 0 if ( std::strncmp(fc::fkey_cap_table[i].tname, "kD", 2) == 0
&& stringLength(fkey_cap_table[i].tname) == 2 ) && std::strlen(fc::fkey_cap_table[i].tname) == 2 )
fkey_cap_table[i].string = "\177"; // delete-character key fc::fkey_cap_table[i].string = "\177"; // delete-character key
if ( std::strncmp(fkey_cap_table[i].tname, "@7", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "@7", 2) == 0 )
fkey_cap_table[i].string = CSI "220z"; // end key fc::fkey_cap_table[i].string = CSI "220z"; // end key
if ( std::strncmp(fkey_cap_table[i].tname, "k;", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "k;", 2) == 0 )
fkey_cap_table[i].string = CSI "233z"; // F10 function key fc::fkey_cap_table[i].string = CSI "233z"; // F10 function key
if ( std::strncmp(fkey_cap_table[i].tname, "F1", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "F1", 2) == 0 )
fkey_cap_table[i].string = CSI "234z"; // F11 function key fc::fkey_cap_table[i].string = CSI "234z"; // F11 function key
if ( std::strncmp(fkey_cap_table[i].tname, "F2", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "F2", 2) == 0 )
fkey_cap_table[i].string = CSI "235z"; // F12 function key fc::fkey_cap_table[i].string = CSI "235z"; // F12 function key
if ( std::strncmp(fkey_cap_table[i].tname, "kh", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "kh", 2) == 0 )
fkey_cap_table[i].string = CSI "214z"; // home key fc::fkey_cap_table[i].string = CSI "214z"; // home key
if ( std::strncmp(fkey_cap_table[i].tname, "kI", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "kI", 2) == 0 )
fkey_cap_table[i].string = CSI "247z"; // insert-character key fc::fkey_cap_table[i].string = CSI "247z"; // insert-character key
if ( std::strncmp(fkey_cap_table[i].tname, "kN", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "kN", 2) == 0 )
fkey_cap_table[i].string = CSI "222z"; // next-page key fc::fkey_cap_table[i].string = CSI "222z"; // next-page key
if ( std::strncmp(fkey_cap_table[i].tname, "%7", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "%7", 2) == 0 )
fkey_cap_table[i].string = CSI "194z"; // options key fc::fkey_cap_table[i].string = CSI "194z"; // options key
if ( std::strncmp(fkey_cap_table[i].tname, "kP", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "kP", 2) == 0 )
fkey_cap_table[i].string = CSI "216z"; // prev-page key fc::fkey_cap_table[i].string = CSI "216z"; // prev-page key
if ( std::strncmp(fkey_cap_table[i].tname, "&5", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "&5", 2) == 0 )
fkey_cap_table[i].string = CSI "193z"; // resume key fc::fkey_cap_table[i].string = CSI "193z"; // resume key
if ( std::strncmp(fkey_cap_table[i].tname, "&8", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "&8", 2) == 0 )
fkey_cap_table[i].string = CSI "195z"; // undo key fc::fkey_cap_table[i].string = CSI "195z"; // undo key
if ( std::strncmp(fkey_cap_table[i].tname, "K2", 2) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "K2", 2) == 0 )
fkey_cap_table[i].string = CSI "218z"; // center of keypad fc::fkey_cap_table[i].string = CSI "218z"; // center of keypad
if ( std::strncmp(fkey_cap_table[i].tname, "kDx", 3) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "kDx", 3) == 0 )
fkey_cap_table[i].string = CSI "249z"; // keypad delete fc::fkey_cap_table[i].string = CSI "249z"; // keypad delete
if ( std::strncmp(fkey_cap_table[i].tname, "@8x", 3) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "@8x", 3) == 0 )
fkey_cap_table[i].string = CSI "250z"; // enter/send key fc::fkey_cap_table[i].string = CSI "250z"; // enter/send key
if ( std::strncmp(fkey_cap_table[i].tname, "KP1", 3) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP1", 3) == 0 )
fkey_cap_table[i].string = CSI "212z"; // keypad slash fc::fkey_cap_table[i].string = CSI "212z"; // keypad slash
if ( std::strncmp(fkey_cap_table[i].tname, "KP2", 3) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP2", 3) == 0 )
fkey_cap_table[i].string = CSI "213z"; // keypad asterisk fc::fkey_cap_table[i].string = CSI "213z"; // keypad asterisk
if ( std::strncmp(fkey_cap_table[i].tname, "KP3", 3) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP3", 3) == 0 )
fkey_cap_table[i].string = CSI "254z"; // keypad minus sign fc::fkey_cap_table[i].string = CSI "254z"; // keypad minus sign
if ( std::strncmp(fkey_cap_table[i].tname, "KP4", 3) == 0 ) if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP4", 3) == 0 )
fkey_cap_table[i].string = CSI "253z"; // keypad plus sign fc::fkey_cap_table[i].string = CSI "253z"; // keypad plus sign
} }
} }
@ -449,7 +448,7 @@ void FTermcapQuirks::screen()
{ {
FTermcap::can_change_color_palette = true; FTermcap::can_change_color_palette = true;
if ( FTermDetection::getInstance().isTmuxTerm() ) if ( FTerm::getFTermDetection().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:"

View File

@ -36,45 +36,38 @@ 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 = FTermDetection::getInstance(); auto& term_detection = FTerm::getFTermDetection();
return term_detection.getAnswerbackString(); return term_detection.getAnswerbackString();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDebugData::getSecDAString() const FString& FTermDebugData::getSecDAString()
{ {
auto& term_detection = FTermDetection::getInstance(); auto& term_detection = FTerm::getFTermDetection();
return term_detection.getSecDAString(); return term_detection.getSecDAString();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDebugData::getTermType_256color() const char* FTermDebugData::getTermType_256color()
{ {
auto& term_detection = FTermDetection::getInstance(); auto& term_detection = FTerm::getFTermDetection();
return term_detection.getTermType_256color(); return term_detection.getTermType_256color();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDebugData::getTermType_Answerback() const char* FTermDebugData::getTermType_Answerback()
{ {
auto& term_detection = FTermDetection::getInstance(); auto& term_detection = FTerm::getFTermDetection();
return term_detection.getTermType_Answerback(); return term_detection.getTermType_Answerback();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDebugData::getTermType_SecDA() const char* FTermDebugData::getTermType_SecDA()
{ {
auto& term_detection = FTermDetection::getInstance(); auto& term_detection = FTerm::getFTermDetection();
return term_detection.getTermType_SecDA(); return term_detection.getTermType_SecDA();
} }
@ -82,7 +75,7 @@ const FString& FTermDebugData::getTermType_SecDA()
#if defined(__linux__) #if defined(__linux__)
int FTermDebugData::getFramebufferBpp() int FTermDebugData::getFramebufferBpp()
{ {
auto& fterm_data = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
return fterm_data.getFramebufferBpp(); return fterm_data.getFramebufferBpp();
} }
#endif // defined(__linux__) #endif // defined(__linux__)

View File

@ -50,52 +50,88 @@
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() = default; FTermDetection::FTermDetection()
{
// Preset to true
terminal_detection = true;
// Preset to false
decscusr_support = false;
// Gnome terminal id from SecDA
// Example: vte version 0.40.0 = 0 * 100 + 40 * 100 + 0 = 4000
// a.b.c = a * 100 + b * 100 + c
gnome_terminal_id = 0;
// Set default ttytype file
std::strncpy (ttytypename, "/etc/ttytype", sizeof(ttytypename));
ttytypename[sizeof(ttytypename) - 1] = '\0';
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTermDetection::~FTermDetection() = default; // destructor FTermDetection::~FTermDetection() // destructor
{
deallocation();
}
// public methods of FTermDetection // public methods of FTermDetection
//----------------------------------------------------------------------
auto FTermDetection::getInstance() -> FTermDetection&
{
static const auto& term_detection = make_unique<FTermDetection>();
return *term_detection;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#if DEBUG #if DEBUG
const FString& FTermDetection::getAnswerbackString() const const FString& FTermDetection::getAnswerbackString()
{ {
return answer_back; return ( answer_back ) ? *answer_back : fc::emptyFString::get();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDetection::getSecDAString() const const FString& FTermDetection::getSecDAString()
{ {
return sec_da; return ( sec_da ) ? *sec_da : fc::emptyFString::get();
} }
#endif #endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetection::setTtyTypeFileName (const FString& ttytype_filename) void FTermDetection::setTtyTypeFileName (const char ttytype_filename[])
{ {
if ( ! ttytype_filename ) if ( ! ttytype_filename )
return; return;
ttytypename = ttytype_filename; std::strncpy (ttytypename, ttytype_filename, sizeof(ttytypename));
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();
@ -108,17 +144,28 @@ 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 = FTermData::getInstance().getTermFileName(); const auto& termfilename = FTerm::getFTermData().getTermFileName();
if ( term_env ) if ( term_env )
{ {
// Save name in termtype // Save name in termtype
termtype = term_env; std::strncpy (termtype, term_env, sizeof(termtype));
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
@ -133,7 +180,8 @@ void FTermDetection::getSystemTermType()
} }
// 2nd fallback: use vt100 if not found // 2nd fallback: use vt100 if not found
termtype = "vt100"; std::strncpy (termtype, "vt100", sizeof(termtype));
termtype[sizeof(termtype) - 1] = '\0';
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -149,7 +197,7 @@ bool FTermDetection::getTTYtype()
// vt100 ttys0 // vt100 ttys0
// Get term basename // Get term basename
const auto& termfilename = FTermData::getInstance().getTermFileName(); const auto& termfilename = FTerm::getFTermData().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 )
@ -159,9 +207,9 @@ bool FTermDetection::getTTYtype()
std::FILE* fp{}; std::FILE* fp{};
std::array<char, BUFSIZ> str{}; std::array<char, BUFSIZ> str{};
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
if ( (fp = fsystem->fopen(ttytypename.c_str(), "r")) == nullptr ) if ( (fp = fsystem->fopen(ttytypename, "r")) == nullptr )
return false; return false;
// Read and parse the file // Read and parse the file
@ -186,7 +234,8 @@ 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
termtype = type; std::strncpy (termtype, type, sizeof(termtype));
termtype[sizeof(termtype) - 1] = '\0';
fsystem->fclose(fp); fsystem->fclose(fp);
return true; return true;
} }
@ -203,7 +252,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 = FTermData::getInstance().getTermFileName(); const auto& termfilename = FTerm::getFTermData().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 )
@ -221,7 +270,8 @@ bool FTermDetection::getTTYSFileEntry()
if ( type != nullptr ) if ( type != nullptr )
{ {
// Save name in termtype // Save name in termtype
termtype = type; std::strncpy (termtype, type, sizeof(termtype));
termtype[sizeof(termtype) - 1] = '\0';
endttyent(); endttyent();
return true; return true;
} }
@ -236,67 +286,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 ( termtype == "rxvt-cygwin-native" ) if ( std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
terminal_type.rxvt = true; terminal_type.rxvt = true;
// Ansi terminal // Ansi terminal
if ( termtype.left(4) == "ansi" ) if ( std::strncmp(termtype, "ansi", 4) == 0 )
{ {
terminal_detection = false; terminal_detection = false;
terminal_type.ansi = true; terminal_type.ansi = true;
} }
// Sun Microsystems workstation console // Sun Microsystems workstation console
if ( termtype.left(3) == "sun" ) if ( std::strncmp(termtype, "sun", 3) == 0 )
{ {
terminal_detection = false; terminal_detection = false;
terminal_type.sun_con = true; terminal_type.sun_con = true;
} }
// Kterm // Kterm
if ( termtype.left(5) == "kterm" ) if ( std::strncmp(termtype, "kterm", 5) == 0 )
{ {
terminal_detection = false; terminal_detection = false;
terminal_type.kterm = true; terminal_type.kterm = true;
} }
// mlterm // mlterm
if ( termtype.left(6) == "mlterm" ) if ( std::strncmp(termtype, "mlterm", 6) == 0 )
terminal_type.mlterm = true; terminal_type.mlterm = true;
// rxvt // rxvt
if ( termtype.left(4) == "rxvt" ) if ( std::strncmp(termtype, "rxvt", 4) == 0 )
terminal_type.rxvt = true; terminal_type.rxvt = true;
// urxvt // urxvt
if ( termtype.left(12) == "rxvt-unicode" ) if ( std::strncmp(termtype, "rxvt-unicode", 12) == 0 )
terminal_type.urxvt = true; terminal_type.urxvt = true;
// screen/tmux // screen/tmux
if ( termtype.left(6) == "screen" ) if ( std::strncmp(termtype, "screen", 6) == 0 )
{ {
terminal_type.screen = true; terminal_type.screen = true;
auto tmux = std::getenv("TMUX"); const char* tmux = std::getenv("TMUX");
if ( tmux && tmux[0] != '\0' ) if ( tmux && std::strlen(tmux) != 0 )
terminal_type.tmux = true; terminal_type.tmux = true;
} }
// Linux console // Linux console
if ( termtype.left(5) == "linux" || termtype.left(3) == "con" ) if ( std::strncmp(termtype, "linux", 5) == 0
|| std::strncmp(termtype, "con", 3) == 0 )
terminal_type.linux_con = true; terminal_type.linux_con = true;
// NetBSD workstation console // NetBSD workstation console
if ( termtype.left(6) == "wsvt25" ) if ( std::strncmp(termtype, "wsvt25", 6) == 0 )
terminal_type.netbsd_con = true; terminal_type.netbsd_con = true;
// kitty // kitty
if ( termtype.left(11) == "xterm-kitty" ) if ( std::strncmp(termtype, "xterm-kitty", 11) == 0 )
terminal_type.kitty = true; terminal_type.kitty = true;
} }
@ -305,12 +355,12 @@ void FTermDetection::detectTerminal()
{ {
// Terminal detection // Terminal detection
FString new_termtype{}; const char* new_termtype{nullptr};
if ( terminal_detection ) if ( terminal_detection )
{ {
FTermios::setCaptureSendCharacters(); FTermios::setCaptureSendCharacters();
auto& keyboard = FKeyboard::getInstance(); auto& keyboard = FTerm::getFKeyboard();
keyboard.setNonBlockingInput(); keyboard.setNonBlockingInput();
// Initialize 256 colors terminals // Initialize 256 colors terminals
@ -334,26 +384,28 @@ void FTermDetection::detectTerminal()
// //
// Test if the terminal is a xterm // Test if the terminal is a xterm
if ( termtype.left(5) == "xterm" || termtype.left(5) == "Eterm" ) if ( std::strncmp(termtype, "xterm", 5) == 0
|| std::strncmp(termtype, "Eterm", 5) == 0 )
{ {
terminal_type.xterm = true; 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 && termtype.getLength() == 5 ) if ( ! new_termtype && std::strlen(termtype) == 5 )
new_termtype = "xterm-16color"; new_termtype = "xterm-16color";
} }
else if ( termtype.left(4) == "ansi" ) // ANSI detection else if ( std::strncmp(termtype, "ansi", 4) == 0 ) // ANSI detection
terminal_type.ansi = true; 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.c_str(), 1); setenv("TERM", new_termtype, 1);
termtype = new_termtype; std::strncpy (termtype, new_termtype, sizeof(termtype));
termtype[sizeof(termtype) - 1] = '\0';
} }
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
auto& fterm_data = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
const auto& termfilename = fterm_data.getTermFileName(); const auto& termfilename = fterm_data.getTermFileName();
// Fixes problem with mouse input // Fixes problem with mouse input
@ -363,13 +415,13 @@ void FTermDetection::detectTerminal()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermDetection::init_256colorTerminal() const char* FTermDetection::init_256colorTerminal()
{ {
FString new_termtype{}; const char* new_termtype{nullptr};
if ( get256colorEnvString() ) if ( get256colorEnvString() )
color256 = true; color256 = true;
else if ( termtype.includes("256color") ) else if ( std::strstr (termtype, "256color") )
color256 = true; color256 = true;
else else
color256 = false; color256 = false;
@ -377,8 +429,13 @@ FString FTermDetection::init_256colorTerminal()
new_termtype = termtype_256color_quirks(); new_termtype = termtype_256color_quirks();
#if DEBUG #if DEBUG
if ( ! new_termtype.isEmpty() ) if ( new_termtype )
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;
@ -395,28 +452,29 @@ 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.string8 = std::getenv("KITTY_WINDOW_ID"); color_env.string7 = std::getenv("KITTY_WINDOW_ID");
if ( ! color_env.string1.isEmpty() if ( color_env.string1 != nullptr
|| ! color_env.string2.isEmpty() || color_env.string2 != nullptr
|| ! color_env.string3.isEmpty() || color_env.string3 != nullptr
|| ! color_env.string4.isEmpty() || color_env.string4 != nullptr
|| ! color_env.string5.isEmpty() || color_env.string5 != nullptr
|| ! color_env.string6.isEmpty() || color_env.string6 != nullptr
|| ! color_env.string7.isEmpty() || color_env.string7 != nullptr
|| ! color_env.string8.isEmpty() ) || color_env.string8 != nullptr )
return true; return true;
return false; return false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermDetection::termtype_256color_quirks() const char* FTermDetection::termtype_256color_quirks()
{ {
FString new_termtype{}; const char* new_termtype{nullptr};
if ( ! color_env.string2.isEmpty() if ( color_env.string2
|| color_env.string1 == "gnome-terminal" ) || (color_env.string1
&& 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
@ -432,45 +490,46 @@ FString FTermDetection::termtype_256color_quirks()
if ( ! color256 ) if ( ! color256 )
return new_termtype; return new_termtype;
if ( termtype.left(5) == "xterm" ) if ( std::strncmp(termtype, "xterm", 5) == 0 )
new_termtype = "xterm-256color"; new_termtype = "xterm-256color";
if ( termtype.left(6) == "screen" ) if ( std::strncmp(termtype, "screen", 6) == 0 )
new_termtype = "screen-256color"; new_termtype = "screen-256color";
if ( termtype.left(5) == "Eterm" ) if ( std::strncmp(termtype, "Eterm", 5) == 0 )
new_termtype = "Eterm-256color"; new_termtype = "Eterm-256color";
if ( termtype.left(6) == "mlterm" ) if ( std::strncmp(termtype, "mlterm", 6) == 0 )
new_termtype = "mlterm-256color"; new_termtype = "mlterm-256color";
if ( termtype.left(4) == "rxvt" if ( std::strncmp(termtype, "rxvt", 4) != 0
&& color_env.string1.left(8) == "rxvt-xpm" ) && color_env.string1
&& 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.getLength() > 0 if ( (color_env.string5 && std::strlen(color_env.string5) > 0)
|| color_env.string6.getLength() > 0 ) || (color_env.string6 && std::strlen(color_env.string6) > 0) )
{ {
terminal_type.kde_konsole = true; terminal_type.kde_konsole = true;
new_termtype = "konsole-256color"; new_termtype = "konsole-256color";
} }
if ( color_env.string3.getLength() > 0 ) if ( color_env.string3 && std::strlen(color_env.string3) > 0 )
decscusr_support = true; decscusr_support = true;
return new_termtype; return new_termtype;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermDetection::determineMaxColor (const FString& current_termtype) const char* FTermDetection::determineMaxColor (const char current_termtype[])
{ {
// Determine xterm maximum number of colors via OSC 4 // Determine xterm maximum number of colors via OSC 4
FString new_termtype{current_termtype}; const char* new_termtype = current_termtype;
auto& keyboard = FKeyboard::getInstance(); auto& keyboard = FTerm::getFKeyboard();
keyboard.setNonBlockingInput(); keyboard.setNonBlockingInput();
if ( ! color256 if ( ! color256
@ -504,7 +563,7 @@ FString FTermDetection::determineMaxColor (const FString& current_termtype)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermDetection::getXTermColorName (FColor color) const FString FTermDetection::getXTermColorName (FColor color)
{ {
FString color_str{""}; FString color_str{""};
std::array<char, 30> buf{}; std::array<char, 30> buf{};
@ -543,7 +602,7 @@ FString FTermDetection::getXTermColorName (FColor color) const
if ( pos > 4 && std::sscanf(temp.data(), parse, &index, buf.data()) == 2 ) if ( pos > 4 && std::sscanf(temp.data(), parse, &index, buf.data()) == 2 )
{ {
auto n = stringLength(buf.data()); std::size_t n = std::strlen(buf.data());
// BEL + '\0' = string terminator // 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' )
@ -560,16 +619,26 @@ FString FTermDetection::getXTermColorName (FColor color) const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermDetection::parseAnswerbackMsg (const FString& current_termtype) const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
{ {
FString new_termtype{current_termtype}; const char* new_termtype = current_termtype;
auto& keyboard = FKeyboard::getInstance(); auto& keyboard = FTerm::getFKeyboard();
keyboard.setNonBlockingInput(); keyboard.setNonBlockingInput();
// send ENQ and read the answerback message // send ENQ and read the answerback message
answer_back = getAnswerbackMsg(); const auto& ans = getAnswerbackMsg();
keyboard.unsetNonBlockingInput(); keyboard.unsetNonBlockingInput();
if ( answer_back == "PuTTY" ) try
{
answer_back = new FString(ans);
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FString");
return nullptr;
}
if ( *answer_back == "PuTTY" )
{ {
terminal_type.putty = true; terminal_type.putty = true;
@ -585,15 +654,20 @@ FString FTermDetection::parseAnswerbackMsg (const FString& current_termtype)
std::fflush (stdout); std::fflush (stdout);
#if DEBUG #if DEBUG
if ( ! new_termtype.isEmpty() ) if ( new_termtype )
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() const FString FTermDetection::getAnswerbackMsg()
{ {
FString answerback{""}; FString answerback{""};
fd_set ifds{}; fd_set ifds{};
@ -633,31 +707,45 @@ FString FTermDetection::getAnswerbackMsg() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermDetection::parseSecDA (const FString& current_termtype) const char* FTermDetection::parseSecDA (const char current_termtype[])
{ {
// The Linux console and older cygwin terminals knows no Sec_DA // 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
sec_da = getSecDA(); const auto& ans = getSecDA();
if ( sec_da.getLength() < 6 ) try
{
// Secondary device attributes (SEC_DA) <- decTerminalID string
sec_da = new FString(ans);
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FString");
return current_termtype;
}
if ( sec_da->getLength() < 6 )
return current_termtype; 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 auto sec_da_components = temp.split(';'); const FStringList sec_da_list = 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;
@ -670,18 +758,21 @@ FString FTermDetection::parseSecDA (const FString& 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]);
FString new_termtype = secDA_Analysis(current_termtype); const char* new_termtype = secDA_Analysis(current_termtype);
#if DEBUG #if DEBUG
if ( ! new_termtype.isEmpty() ) if ( new_termtype )
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) const int FTermDetection::str2int (const FString& s)
{ {
// 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
@ -689,7 +780,7 @@ int FTermDetection::str2int (const FString& s) const
constexpr int ERROR = -1; constexpr int ERROR = -1;
if ( s.isEmpty() ) if ( ! s )
return ERROR; return ERROR;
try try
@ -711,7 +802,7 @@ int FTermDetection::str2int (const FString& s) const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermDetection::getSecDA() const FString FTermDetection::getSecDA()
{ {
FString sec_da_str{""}; FString sec_da_str{""};
@ -722,10 +813,10 @@ FString FTermDetection::getSecDA() const
const int stdout_no{FTermios::getStdOut()}; const int stdout_no{FTermios::getStdOut()};
fd_set ifds{}; fd_set ifds{};
struct timeval tv{}; struct timeval tv{};
const std::string SECDA{ESC "[>c"}; constexpr auto& SECDA{ESC "[>c"};
// Get the secondary device attributes // Get the secondary device attributes
if ( write(stdout_no, SECDA.data(), SECDA.length()) == -1 ) if ( write(stdout_no, SECDA, std::strlen(SECDA)) == -1 )
return sec_da_str; return sec_da_str;
std::fflush(stdout); std::fflush(stdout);
@ -761,9 +852,9 @@ FString FTermDetection::getSecDA() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermDetection::secDA_Analysis (const FString& current_termtype) const char* FTermDetection::secDA_Analysis (const char current_termtype[])
{ {
FString new_termtype{current_termtype}; const char* new_termtype = current_termtype;
switch ( secondary_da.terminal_id_type ) switch ( secondary_da.terminal_id_type )
{ {
@ -784,7 +875,7 @@ FString FTermDetection::secDA_Analysis (const FString& current_termtype)
break; break;
case 32: // Tera Term case 32: // Tera Term
new_termtype = secDA_Analysis_32(); new_termtype = secDA_Analysis_32(current_termtype);
break; break;
case 41: // DEC VT420 case 41: // DEC VT420
@ -797,11 +888,11 @@ FString FTermDetection::secDA_Analysis (const FString& current_termtype)
break; break;
case 67: // Cygwin case 67: // Cygwin
new_termtype = secDA_Analysis_67(); new_termtype = secDA_Analysis_67(current_termtype);
break; break;
case 77: // mintty case 77: // mintty
new_termtype = secDA_Analysis_77(); new_termtype = secDA_Analysis_77(current_termtype);
break; break;
case 82: // rxvt case 82: // rxvt
@ -837,11 +928,11 @@ FString FTermDetection::secDA_Analysis (const FString& current_termtype)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_0 (const FString& current_termtype) inline const char* FTermDetection::secDA_Analysis_0 (const char current_termtype[])
{ {
// Terminal ID 0 - DEC VT100 // Terminal ID 0 - DEC VT100
FString new_termtype{current_termtype}; const char* 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 )
@ -860,11 +951,11 @@ inline FString FTermDetection::secDA_Analysis_0 (const FString& current_termtype
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_1 (const FString& current_termtype) inline const char* FTermDetection::secDA_Analysis_1 (const char current_termtype[])
{ {
// Terminal ID 1 - DEC VT220 // Terminal ID 1 - DEC VT220
FString new_termtype{current_termtype}; const char* new_termtype = current_termtype;
if ( isKittyTerminal() ) if ( isKittyTerminal() )
new_termtype = secDA_Analysis_kitty(new_termtype); new_termtype = secDA_Analysis_kitty(new_termtype);
@ -875,11 +966,11 @@ inline FString FTermDetection::secDA_Analysis_1 (const FString& current_termtype
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_24 (const FString& current_termtype) inline const char* FTermDetection::secDA_Analysis_24 (const char current_termtype[])
{ {
// Terminal ID 24 - DEC VT320 // Terminal ID 24 - DEC VT320
FString new_termtype{current_termtype}; const char* new_termtype = current_termtype;
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
@ -887,9 +978,9 @@ inline FString FTermDetection::secDA_Analysis_24 (const FString& current_termtyp
&& FTermOpenBSD::isBSDConsole() ) && FTermOpenBSD::isBSDConsole() )
{ {
// NetBSD/OpenBSD workstation console // NetBSD/OpenBSD workstation console
if ( termtype.left(6) == "wsvt25" ) if ( std::strncmp(termtype, "wsvt25", 6) == 0 )
terminal_type.netbsd_con = true; terminal_type.netbsd_con = true;
else if ( termtype.left(5) == "vt220" ) else if ( std::strncmp(termtype, "vt220", 5) == 0 )
{ {
terminal_type.openbsd_con = true; terminal_type.openbsd_con = true;
new_termtype = "pccon"; new_termtype = "pccon";
@ -902,16 +993,17 @@ inline FString FTermDetection::secDA_Analysis_24 (const FString& current_termtyp
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_32() inline const char* FTermDetection::secDA_Analysis_32 (const char[])
{ {
// Terminal ID 32 - Tera Term // Terminal ID 32 - Tera Term
terminal_type.tera_term = true; terminal_type.tera_term = true;
return "teraterm"; const char* new_termtype = "teraterm";
return new_termtype;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_65 (const FString& current_termtype) inline const char* FTermDetection::secDA_Analysis_65 (const char current_termtype[])
{ {
// Terminal ID 65 - DEC VT525 and VTE >= 0.53.0 // Terminal ID 65 - DEC VT525 and VTE >= 0.53.0
@ -919,35 +1011,37 @@ inline FString FTermDetection::secDA_Analysis_65 (const FString& current_termtyp
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_67() inline const char* FTermDetection::secDA_Analysis_67 (const char[])
{ {
// Terminal ID 67 - cygwin // Terminal ID 67 - cygwin
terminal_type.cygwin = true; terminal_type.cygwin = true;
const char* new_termtype = "cygwin";
std::fflush(stdout); std::fflush(stdout);
return "cygwin"; return new_termtype;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_77() inline const char* FTermDetection::secDA_Analysis_77 (const char[])
{ {
// Terminal ID 77 - mintty // Terminal 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 "xterm-256color"; return new_termtype;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_82() inline const char* FTermDetection::secDA_Analysis_82()
{ {
// Terminal ID 82 - rxvt // Terminal ID 82 - rxvt
FString new_termtype{}; const char* new_termtype{};
terminal_type.rxvt = true; terminal_type.rxvt = true;
if ( termtype == "rxvt-cygwin-native" ) if ( std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
new_termtype = "rxvt-16color"; new_termtype = "rxvt-16color";
else else
new_termtype = "rxvt"; new_termtype = "rxvt";
@ -956,34 +1050,36 @@ inline FString FTermDetection::secDA_Analysis_82()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_83 (const FString& current_termtype) inline const char* FTermDetection::secDA_Analysis_83 (const char current_termtype[])
{ {
// Terminal ID 83 - screen // Terminal ID 83 - screen
const char* new_termtype = current_termtype;
terminal_type.screen = true; terminal_type.screen = true;
return current_termtype; return new_termtype;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_84 (const FString& current_termtype) inline const char* FTermDetection::secDA_Analysis_84 (const char current_termtype[])
{ {
// Terminal ID 84 - tmux // 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 current_termtype; return new_termtype;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_85() inline const char* FTermDetection::secDA_Analysis_85()
{ {
// Terminal ID 85 - rxvt-unicode // Terminal ID 85 - rxvt-unicode
FString new_termtype{}; const char* new_termtype{};
terminal_type.rxvt = true; terminal_type.rxvt = true;
terminal_type.urxvt = true; terminal_type.urxvt = true;
if ( termtype.left(5) == "rxvt-" ) if ( std::strncmp(termtype, "rxvt-", 5) != 0 )
{ {
if ( color256 ) if ( color256 )
new_termtype = "rxvt-256color"; new_termtype = "rxvt-256color";
@ -997,12 +1093,12 @@ inline FString FTermDetection::secDA_Analysis_85()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_vte (const FString& current_termtype) inline const char* FTermDetection::secDA_Analysis_vte (const char current_termtype[])
{ {
// VTE terminal library // 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)
FString new_termtype{current_termtype}; const char* new_termtype = current_termtype;
if ( secondary_da.terminal_id_version > 1000 ) if ( secondary_da.terminal_id_version > 1000 )
{ {
@ -1021,11 +1117,11 @@ inline FString FTermDetection::secDA_Analysis_vte (const FString& current_termty
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::secDA_Analysis_kitty (const FString& current_termtype) inline const char* FTermDetection::secDA_Analysis_kitty (const char current_termtype[])
{ {
// kitty // kitty
FString new_termtype{current_termtype}; const char* new_termtype = current_termtype;
if ( secondary_da.terminal_id_version > 3999 ) if ( secondary_da.terminal_id_version > 3999 )
{ {

View File

@ -46,13 +46,6 @@ 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()
{ {
@ -68,7 +61,7 @@ bool FTermFreeBSD::setCursorStyle (CursorStyle style)
return false; return false;
cursor_style = style; cursor_style = style;
auto& fterm_data = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
if ( fterm_data.isCursorHidden() ) if ( fterm_data.isCursorHidden() )
return false; return false;
@ -82,7 +75,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
if ( fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 ) if ( fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
return true; return true;
@ -155,7 +148,7 @@ void FTermFreeBSD::initCharMap()
if ( ! isFreeBSDConsole() ) if ( ! isFreeBSDConsole() )
return; return;
for (auto&& entry : FCharMap::getCharEncodeMap()) for (auto&& entry : fc::character)
if ( entry.pc < 0x1c ) if ( entry.pc < 0x1c )
entry.pc = entry.ascii; entry.pc = entry.ascii;
} }
@ -194,7 +187,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap); ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
if ( ret < 0 ) if ( ret < 0 )
@ -213,7 +206,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap); ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
if ( ret < 0 ) if ( ret < 0 )
@ -248,7 +241,7 @@ bool FTermFreeBSD::resetFreeBSDAlt2Meta()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style) bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style)
{ {
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 ) if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 )
return true; return true;

View File

@ -61,13 +61,6 @@ 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
{ {
@ -97,7 +90,7 @@ bool FTermLinux::setCursorStyle (CursorStyle style)
linux_console_cursor_style = style; linux_console_cursor_style = style;
if ( FTermData::getInstance().isCursorHidden() ) if ( FTerm::getFTermData().isCursorHidden() )
return false; return false;
setLinuxCursorStyle(style); setLinuxCursorStyle(style);
@ -141,7 +134,7 @@ bool FTermLinux::isLinuxConsole()
char arg{0}; char arg{0};
int fd_tty = FTerm::getTTYFileDescriptor(); int fd_tty = FTerm::getTTYFileDescriptor();
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
if ( fd_tty < 0 ) // Undefined tty file descriptor if ( fd_tty < 0 ) // Undefined tty file descriptor
fd_tty = 0; fd_tty = 0;
@ -157,7 +150,7 @@ void FTermLinux::init()
{ {
// Initialize Linux console // Initialize Linux console
auto& fterm_data = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
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);
@ -170,7 +163,7 @@ void FTermLinux::init()
if ( FTerm::openConsole() == 0 ) if ( FTerm::openConsole() == 0 )
{ {
FTermDetection::getInstance().setLinuxTerm(isLinuxConsole()); FTerm::getFTermDetection().setLinuxTerm (isLinuxConsole());
if ( FTerm::isLinuxTerm() ) if ( FTerm::isLinuxTerm() )
{ {
@ -215,7 +208,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 : FCharMap::getCharEncodeMap()) for (auto&& entry : fc::character)
{ {
const auto ucs = entry.unicode; const auto ucs = entry.unicode;
const sInt16 fontpos = getFontPos(ucs); const sInt16 fontpos = getFontPos(ucs);
@ -289,7 +282,7 @@ bool FTermLinux::loadVGAFont()
if ( vga_font ) if ( vga_font )
{ {
auto& fterm_data = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
fterm_data.supportShadowCharacter (true); fterm_data.supportShadowCharacter (true);
fterm_data.supportHalfBlockCharacter (true); fterm_data.supportHalfBlockCharacter (true);
} }
@ -337,7 +330,7 @@ bool FTermLinux::loadNewFont()
if ( new_font ) if ( new_font )
{ {
auto& fterm_data = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
fterm_data.supportShadowCharacter (true); fterm_data.supportShadowCharacter (true);
fterm_data.supportHalfBlockCharacter (true); fterm_data.supportHalfBlockCharacter (true);
} }
@ -469,7 +462,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
if ( (fd = fsystem->open(fb, O_RDWR)) < 0 ) if ( (fd = fsystem->open(fb, O_RDWR)) < 0 )
{ {
@ -528,7 +521,7 @@ bool FTermLinux::getScreenFont()
} }
// Font operation // Font operation
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font); ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
if ( ret != 0 ) if ( ret != 0 )
@ -559,7 +552,7 @@ bool FTermLinux::getUnicodeMap()
screen_unicode_map.entries = nullptr; screen_unicode_map.entries = nullptr;
// Get count // Get count
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
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 )
@ -599,7 +592,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
// TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE) // TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE)
if ( fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 ) if ( fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 )
@ -665,7 +658,7 @@ int FTermLinux::setScreenFont ( const uChar fontdata[], uInt count
} }
// Font operation // Font operation
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
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 )
@ -702,7 +695,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice); ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice);
if ( ret != 0 ) if ( ret != 0 )
@ -734,7 +727,7 @@ inline uInt16 FTermLinux::getInputStatusRegisterOne() const
{ {
// Gets the VGA input-status-register-1 // Gets the VGA input-status-register-1
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
// Miscellaneous output (read port) // Miscellaneous output (read port)
static constexpr uInt16 misc_read = 0x3cc; static constexpr uInt16 misc_read = 0x3cc;
@ -750,7 +743,7 @@ uChar FTermLinux::readAttributeController (uChar index) const
{ {
// Reads a byte from the attribute controller from a given index // Reads a byte from the attribute controller from a given index
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
// Attribute controller (write port) // Attribute controller (write port)
static constexpr uInt16 attrib_cntlr_write = 0x3c0; static constexpr uInt16 attrib_cntlr_write = 0x3c0;
@ -776,7 +769,7 @@ void FTermLinux::writeAttributeController (uChar index, uChar data) const
{ {
// Writes a byte from the attribute controller from a given index // Writes a byte from the attribute controller from a given index
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
// Attribute controller (write port) // Attribute controller (write port)
static constexpr uInt16 attrib_cntlr_write = 0x3c0; static constexpr uInt16 attrib_cntlr_write = 0x3c0;
@ -815,7 +808,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
const int fd_tty = FTerm::getTTYFileDescriptor(); const int fd_tty = FTerm::getTTYFileDescriptor();
@ -854,7 +847,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
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
@ -879,7 +872,7 @@ bool FTermLinux::has9BitCharacters() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermLinux::getVGAPalette() void FTermLinux::getVGAPalette()
{ {
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
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
@ -924,7 +917,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
if ( fsystem->ioctl(0, PIO_CMAP, cmap.color.data()) == 0 ) if ( fsystem->ioctl(0, PIO_CMAP, cmap.color.data()) == 0 )
return true; return true;
@ -937,7 +930,7 @@ bool FTermLinux::saveVGAPalette()
{ {
// Save the current vga color map // Save the current vga color map
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
if ( fsystem->ioctl(0, GIO_CMAP, saved_color_map.color.data()) == 0 ) if ( fsystem->ioctl(0, GIO_CMAP, saved_color_map.color.data()) == 0 )
has_saved_palette = true; has_saved_palette = true;
@ -952,7 +945,7 @@ bool FTermLinux::resetVGAPalette()
{ {
// Reset the vga color map // Reset the vga color map
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
if ( has_saved_palette ) if ( has_saved_palette )
{ {
@ -1135,7 +1128,7 @@ inline void FTermLinux::shiftCtrlAltKeyCorrection()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTermLinux::initSpecialCharacter() const inline void FTermLinux::initSpecialCharacter() const
{ {
auto& fterm_data = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
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); // █
@ -1176,7 +1169,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 = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
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] )

View File

@ -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-2021 Markus Gans * * Copyright 2018-2020 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,20 +41,13 @@ 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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
if ( fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 ) if ( fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
return true; return true;
@ -109,7 +102,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
if ( fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 ) if ( fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 )
return false; return false;
@ -121,7 +114,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 = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
// 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 )
@ -154,7 +147,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
static kbd_t k_encoding{}; static kbd_t k_encoding{};
int ret{-1}; int ret{-1};
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding); ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding);
if ( ret < 0 ) if ( ret < 0 )
@ -168,7 +161,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding) bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding)
{ {
const auto& fsystem = FSystem::getInstance(); const auto& fsystem = FTerm::getFSystem();
if ( fsystem->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 ) if ( fsystem->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 )
return false; return false;

View File

@ -51,13 +51,6 @@ 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)
{ {
@ -248,7 +241,7 @@ void FTermXTerminal::resetHighlightBackground()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::resetDefaults() void FTermXTerminal::resetDefaults()
{ {
if ( FTermDetection::getInstance().isPuttyTerminal() ) if ( FTerm::getFTermDetection().isPuttyTerminal() )
return; return;
// Redefines the cursor color if resetCursorColor() doesn't work // Redefines the cursor color if resetCursorColor() doesn't work
@ -279,14 +272,14 @@ void FTermXTerminal::resetTitle()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::captureFontAndTitle() void FTermXTerminal::captureFontAndTitle()
{ {
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
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 = FKeyboard::getInstance(); auto& keyboard = FTerm::getFKeyboard();
keyboard.setNonBlockingInput(); keyboard.setNonBlockingInput();
xterm_font = captureXTermFont(); xterm_font = captureXTermFont();
xterm_title = captureXTermTitle(); xterm_title = captureXTermTitle();
@ -317,7 +310,7 @@ void FTermXTerminal::setXTermCursorStyle()
return; return;
#endif #endif
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isGnomeTerminal() if ( term_detection.isGnomeTerminal()
&& ! term_detection.hasSetCursorStyleSupport() ) && ! term_detection.hasSetCursorStyleSupport() )
@ -341,7 +334,7 @@ void FTermXTerminal::setXTermCursorStyle()
void FTermXTerminal::setXTermTitle() void FTermXTerminal::setXTermTitle()
{ {
// Set the xterm title // Set the xterm title
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -352,6 +345,10 @@ 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);
@ -362,7 +359,7 @@ void FTermXTerminal::setXTermTitle()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::setXTermSize() const void FTermXTerminal::setXTermSize() const
{ {
if ( ! FTermDetection::getInstance().isXTerminal() ) if ( ! FTerm::getFTermDetection().isXTerminal() )
return; return;
FTerm::putstringf ( CSI "8;%lu;%lut" FTerm::putstringf ( CSI "8;%lu;%lut"
@ -376,7 +373,7 @@ void FTermXTerminal::setXTermFont()
{ {
// Change the XTerm font (needs the allowFontOps resource) // Change the XTerm font (needs the allowFontOps resource)
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -394,7 +391,7 @@ void FTermXTerminal::setXTermForeground()
{ {
// Set the XTerm text foreground color // Set the XTerm text foreground color
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -414,7 +411,7 @@ void FTermXTerminal::setXTermBackground()
{ {
// Set the XTerm text background color // Set the XTerm text background color
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -434,7 +431,7 @@ void FTermXTerminal::setXTermCursorColor()
{ {
// Set the text cursor color // Set the text cursor color
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -454,7 +451,7 @@ void FTermXTerminal::setXTermMouseForeground()
{ {
// Set the mouse foreground color // Set the mouse foreground color
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -473,7 +470,7 @@ void FTermXTerminal::setXTermMouseBackground()
{ {
// Set the mouse background color // Set the mouse background color
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -491,7 +488,7 @@ void FTermXTerminal::setXTermHighlightBackground()
{ {
// Set the highlight background color // Set the highlight background color
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -511,7 +508,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 ( FTermDetection::getInstance().isPuttyTerminal() ) if ( FTerm::getFTermDetection().isPuttyTerminal() )
return; return;
setXTermDefaultsMouseCursor(); setXTermDefaultsMouseCursor();
@ -531,7 +528,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 ( FTermDetection::getInstance().isPuttyTerminal() ) if ( FTerm::getFTermDetection().isPuttyTerminal() )
return; return;
setXTermDefaultsMouseCursor(); setXTermDefaultsMouseCursor();
@ -551,14 +548,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 ( ! FTermDetection::getInstance().isGnomeTerminal() ) if ( ! FTerm::getFTermDetection().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 = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( xterm_default_colors if ( xterm_default_colors
&& ! (term_detection.isMinttyTerm() && ! (term_detection.isMinttyTerm()
@ -575,7 +572,7 @@ void FTermXTerminal::resetXTermColorMap() const
{ {
// Reset the entire color table // Reset the entire color table
if ( FTermDetection::getInstance().isMinttyTerm() ) if ( FTerm::getFTermDetection().isMinttyTerm() )
{ {
FTerm::putstring (ESC "c"); // Full Reset (RIS) FTerm::putstring (ESC "c"); // Full Reset (RIS)
} }
@ -675,7 +672,7 @@ void FTermXTerminal::resetXTermHighlightBackground() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermXTerminal::canResetColor() const bool FTermXTerminal::canResetColor() const
{ {
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isGnomeTerminal() if ( term_detection.isGnomeTerminal()
&& term_detection.getGnomeTerminalID() < 3502 ) && term_detection.getGnomeTerminalID() < 3502 )
@ -696,7 +693,7 @@ bool FTermXTerminal::canResetColor() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::oscPrefix() const void FTermXTerminal::oscPrefix() const
{ {
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isTmuxTerm() ) if ( term_detection.isTmuxTerm() )
{ {
@ -713,7 +710,7 @@ void FTermXTerminal::oscPrefix() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::oscPostfix() const void FTermXTerminal::oscPostfix() const
{ {
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isScreenTerm() if ( term_detection.isScreenTerm()
|| term_detection.isTmuxTerm() ) || term_detection.isTmuxTerm() )
@ -726,7 +723,7 @@ void FTermXTerminal::oscPostfix() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermXTerminal::captureXTermFont() const FString FTermXTerminal::captureXTermFont() const
{ {
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( ! term_detection.isXTerminal() if ( ! term_detection.isXTerminal()
&& ! term_detection.isScreenTerm() && ! term_detection.isScreenTerm()
@ -772,12 +769,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 ;
std::string str = &temp[5]; char* str = &temp[5];
const std::size_t n = str.length(); const std::size_t n = std::strlen(str);
// 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.erase(n - 1); str[n - 1] = '\0';
return {str}; return {str};
} }
@ -788,7 +785,7 @@ FString FTermXTerminal::captureXTermFont() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermXTerminal::captureXTermTitle() const FString FTermXTerminal::captureXTermTitle() const
{ {
if ( FTermDetection::getInstance().isKdeTerminal() ) if ( FTerm::getFTermDetection().isKdeTerminal() )
return {}; return {};
fd_set ifds{}; fd_set ifds{};
@ -825,8 +822,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
std::string str = &temp[3]; char* str = &temp[3];
const std::size_t n = str.length(); const std::size_t n = std::strlen(str);
// 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] == '\\' )
@ -834,7 +831,7 @@ FString FTermXTerminal::captureXTermTitle() const
if ( n < 4 ) if ( n < 4 )
return {}; return {};
str.erase(n - 2); str[n - 2] = '\0';
return {str}; return {str};
} }
} }

View File

@ -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("\n"); auto text_split = s.split("\r\n");
for (auto&& line : text_split) // Line loop for (auto&& line : text_split) // Line loop
{ {
@ -274,27 +274,15 @@ void FTextView::insert (const FString& str, int pos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::replaceRange (const FString& str, int from, int to) 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()) )
throw std::out_of_range(""); // Invalid range return;
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);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -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-2021 Markus Gans * * Copyright 2014-2020 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.isEmpty() ) if ( text.isNull() || text.isEmpty() )
return; return;
const FString txt(text); const FString txt(text);

View File

@ -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.trim()} , text{txt}
{ {
init(); init();
} }
@ -69,7 +69,7 @@ FToolTip::~FToolTip() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToolTip::setText (const FString& txt) void FToolTip::setText (const FString& txt)
{ {
text.setString(txt.trim()); text.setString(txt);
calculateDimensions(); calculateDimensions();
} }

View File

@ -61,12 +61,14 @@ 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{};
TimeValue FVTerm::time_last_flush{}; struct timeval 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};
@ -183,9 +185,9 @@ void FVTerm::hideCursor (bool enable) const
if ( ! cursor_hideable ) if ( ! cursor_hideable )
return; return;
auto visibility_str = FTerm::cursorsVisibilityString (enable); const char* visibility_str = FTerm::cursorsVisibilityString (enable);
if ( visibility_str.empty() ) // Exit the function if the string is empty if ( ! visibility_str ) // Exit the function if the string is empty
return; return;
appendOutputBuffer(FTermControl{visibility_str}); appendOutputBuffer(FTermControl{visibility_str});
@ -340,8 +342,8 @@ void FVTerm::delPreprocessingHandler (const FVTerm* instance)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FVTerm::print (const FString& string) int FVTerm::print (const FString& string)
{ {
if ( string.isEmpty() ) if ( string.isNull() )
return 0; return -1;
FTermBuffer term_buffer{}; FTermBuffer term_buffer{};
term_buffer.write(string); term_buffer.write(string);
@ -351,7 +353,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.isEmpty() ) if ( ! area || string.isNull() )
return -1; return -1;
FTermBuffer term_buffer{}; FTermBuffer term_buffer{};
@ -599,9 +601,9 @@ void FVTerm::flush() const
} }
std::fflush(stdout); std::fflush(stdout);
auto& mouse = FMouseControl::getInstance(); auto& mouse = FTerm::getFMouseControl();
mouse.drawPointer(); mouse.drawPointer();
time_last_flush = FObject::getCurrentTime(); FObject::getCurrentTime (&time_last_flush);
} }
@ -1762,8 +1764,8 @@ FChar FVTerm::getCharacter ( CharacterType char_type
const int x = pos.getX(); const int x = pos.getX();
const int y = pos.getY(); const int y = pos.getY();
int xx = std::max(x, 0); int xx = ( x > 0 ) ? x : 0;
int yy = std::max(y, 0); int yy = ( y > 0 ) ? y : 0;
if ( xx >= vterm->width ) if ( xx >= vterm->width )
xx = vterm->width - 1; xx = vterm->width - 1;
@ -1874,14 +1876,17 @@ void FVTerm::init()
vdesktop->visible = true; vdesktop->visible = true;
active_area = vdesktop; active_area = vdesktop;
// Initialize the last flush time // Initialize the flush and last terminal size check time
time_last_flush = TimeValue{}; time_last_flush.tv_sec = 0;
time_last_flush.tv_usec = 0;
last_term_size_check.tv_sec = 0;
last_term_size_check.tv_usec = 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::init_characterLengths() void FVTerm::init_characterLengths()
{ {
const auto& opti_move = FOptiMove::getInstance(); const auto& opti_move = FTerm::getFOptiMove();
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();
@ -1915,7 +1920,7 @@ void FVTerm::init_combined_character()
if ( FTerm::getEncoding() != Encoding::UTF8 ) if ( FTerm::getEncoding() != Encoding::UTF8 )
return; return;
const auto& term_detection = FTermDetection::getInstance(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection.isCygwinTerminal() ) if ( term_detection.isCygwinTerminal() )
return; return;
@ -1939,7 +1944,7 @@ void FVTerm::finish() const
setNormal(); setNormal();
if ( FTerm::hasAlternateScreen() if ( FTerm::hasAlternateScreen()
&& FTermData::getInstance().isInAlternateScreen() ) && FTerm::getFTermData().isInAlternateScreen() )
clearTerm(); clearTerm();
forceTerminalUpdate(); forceTerminalUpdate();
@ -2874,13 +2879,33 @@ 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
{ {
const auto now = FObject::getCurrentTime(); timeval now;
const auto diff = now - time_last_flush; FObject::getCurrentTime(&now);
timeval diff = now - time_last_flush;
if ( diff > milliseconds(400) ) if ( diff.tv_sec > 0 || diff.tv_usec > 400000 )
{ {
flush_wait = MIN_FLUSH_WAIT; // Reset to minimum values after 400 ms flush_wait = MIN_FLUSH_WAIT; // Reset to minimum values after 400 ms
flush_average = MIN_FLUSH_WAIT; flush_average = MIN_FLUSH_WAIT;
@ -2888,7 +2913,7 @@ inline void FVTerm::flushTimeAdjustment() const
} }
else else
{ {
auto usec = uInt64(duration_cast<microseconds>(diff).count()); auto usec = uInt64(diff.tv_usec);
if ( usec < MIN_FLUSH_WAIT ) if ( usec < MIN_FLUSH_WAIT )
usec = MIN_FLUSH_WAIT; usec = MIN_FLUSH_WAIT;
@ -2922,7 +2947,13 @@ 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);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -3049,7 +3080,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.empty() ) if ( attr_str )
appendOutputBuffer (FTermControl{attr_str}); appendOutputBuffer (FTermControl{attr_str});
} }

View File

@ -20,7 +20,6 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include <algorithm>
#include <vector> #include <vector>
#include "final/fapplication.h" #include "final/fapplication.h"
@ -85,7 +84,7 @@ FWidget::FWidget (FWidget* parent)
{ {
if ( internal::var::root_widget ) if ( internal::var::root_widget )
{ {
auto& fterm_data = FTermData::getInstance(); auto& fterm_data = FTerm::getFTermData();
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);
@ -406,7 +405,7 @@ void FWidget::setPos (const FPoint& p, bool adjust)
return; return;
} }
if ( ! isWindowWidget() ) // A widgets must be inside the client area if ( ! isWindowWidget() )
{ {
if ( pos.getX() < 1 ) if ( pos.getX() < 1 )
pos.setX(1); pos.setX(1);
@ -431,7 +430,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 ) // A width can never be narrower than 1 character if ( width < 1 )
width = 1; width = 1;
wsize.setWidth(width); wsize.setWidth(width);
@ -453,7 +452,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 ) // A height can never be narrower than 1 character if ( height < 1 )
height = 1; height = 1;
wsize.setHeight(height); wsize.setHeight(height);
@ -480,10 +479,10 @@ void FWidget::setSize (const FSize& size, bool adjust)
&& getHeight() == height && wsize.getHeight() == height ) && getHeight() == height && wsize.getHeight() == height )
return; return;
if ( width < 1 ) // A width can never be narrower than 1 character if ( width < 1 )
width = 1; width = 1;
if ( height < 1 ) // A height can never be narrower than 1 character if ( height < 1 )
height = 1; height = 1;
wsize.setWidth(width); wsize.setWidth(width);
@ -625,19 +624,20 @@ void FWidget::setGeometry (const FPoint& p, const FSize& s, bool adjust)
if ( getPos() == p && getWidth() == w && getHeight() == h ) if ( getPos() == p && getWidth() == w && getHeight() == h )
return; return;
if ( isWindowWidget() ) // A window widget can be outside if ( ! isWindowWidget() )
{
( x < 1 ) ? wsize.setX(1) : wsize.setX(x);
( y < 1 ) ? wsize.setY(1) : wsize.setY(y);
}
else
{ {
wsize.setX(x); wsize.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));
}
wsize.setWidth(std::max(w, std::size_t(1u))); ( w < 1 ) ? wsize.setWidth(1) : wsize.setWidth(w);
wsize.setHeight(std::max(h, std::size_t(1u))); ( h < 1 ) ? wsize.setHeight(1) : wsize.setHeight(h);
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 && ! isInFWidgetList(close_widget, this) ) if ( ! flags.modal )
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::getInstance().dark_theme ) if ( FStartOptions::getFStartOptions().dark_theme )
{ {
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
setColorTheme<default8ColorDarkTheme>(); setColorTheme<default8ColorDarkTheme>();

View File

@ -20,8 +20,6 @@
* <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"
@ -55,16 +53,6 @@ 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()
{ {

View File

@ -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-2021 Markus Gans * * Copyright 2013-2020 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 TimeValue time_last_event; static timeval 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;

View File

@ -120,7 +120,6 @@ 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;

View File

@ -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-2021 Markus Gans * * Copyright 2015-2020 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,63 +30,43 @@
#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
{ {
class FCharMap final namespace fc
{
// Unicode fallback table for VT100, PC, and ASCII
struct CharEncodeMap
{ {
public:
// Unicode fallback table for VT100, PC, and ASCII
struct CharEncodeMap
{
wchar_t unicode; wchar_t unicode;
wchar_t vt100; wchar_t vt100;
wchar_t pc; wchar_t pc;
wchar_t ascii; wchar_t ascii;
};
// vt100 <-> utf-8
struct DECSpecialGraphics
{
VT100Key key;
UniChar unicode;
};
// Using-declaration
using CharEncodeType = std::array<CharEncodeMap, 115>;
using DECGraphicsType = std::array<DECSpecialGraphics, 39>;
using Cp437UcsType = std::array<std::array<wchar_t, 2>, 256>;
using HalfFullWidthType = std::array<std::array<wchar_t, 2>, 227>;
// Constructors
FCharMap() = default;
// Accessors
FString getClassName() const;
static auto getInstance() -> FCharMap&;
static wchar_t& getCharacter ( CharEncodeMap& char_enc
, const Encoding& enc );
static CharEncodeType& getCharEncodeMap();
static const DECGraphicsType& getDECSpecialGraphics();
static const Cp437UcsType& getCP437UCSMap();
static const HalfFullWidthType& getHalfFullWidthMap();
private:
// Data members
static CharEncodeType character;
static const DECGraphicsType dec_special_graphics;
static const Cp437UcsType cp437_ucs;
static const HalfFullWidthType halfwidth_fullwidth;
}; };
// FCharMap inline functions extern std::array<CharEncodeMap, 115> character;
//----------------------------------------------------------------------
inline FString FCharMap::getClassName() const inline wchar_t& getCharacter (CharEncodeMap& char_enc, const Encoding& enc)
{ return "FCharMap"; } {
const auto array = reinterpret_cast<wchar_t*>(&char_enc);
return array[std::size_t(enc)];
}
// vt100 <-> utf-8
struct DECSpecialGraphics
{
VT100Key key;
UniChar unicode;
};
extern const std::array<DECSpecialGraphics, 39> dec_special_graphics;
extern const std::array<std::array<wchar_t, 2>, 256> cp437_ucs;
extern const std::array<std::array<wchar_t, 2>, 227> halfwidth_fullwidth;
} // namespace fc
} // namespace finalcut } // namespace finalcut

View File

@ -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-2021 Markus Gans * * Copyright 2018-2020 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,7 +60,6 @@ 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;

View File

@ -30,7 +30,9 @@
#endif #endif
/* Define to 1 if you have the `getttynam' function. */ /* Define to 1 if you have the `getttynam' function. */
/* #undef HAVE_GETTTYNAM */ #ifndef F_HAVE_GETTTYNAM
#define F_HAVE_GETTTYNAM 1
#endif
/* Define to 1 if you have the `getuid' function. */ /* Define to 1 if you have the `getuid' function. */
#ifndef F_HAVE_GETUID #ifndef F_HAVE_GETUID
@ -48,7 +50,9 @@
#endif #endif
/* Define to 1 if GPM mouse is enabled */ /* Define to 1 if GPM mouse is enabled */
/* #undef HAVE_LIBGPM */ #ifndef F_HAVE_LIBGPM
#define F_HAVE_LIBGPM 1
#endif
/* Define to 1 if you have the <linux/fb.h> header file. */ /* Define to 1 if you have the <linux/fb.h> header file. */
#ifndef F_HAVE_LINUX_FB_H #ifndef F_HAVE_LINUX_FB_H
@ -140,7 +144,9 @@
#endif #endif
/* Define to 1 if you have the <ttyent.h> header file. */ /* Define to 1 if you have the <ttyent.h> header file. */
/* #undef HAVE_TTYENT_H */ #ifndef F_HAVE_TTYENT_H
#define F_HAVE_TTYENT_H 1
#endif
/* Define to 1 if you have the <unistd.h> header file. */ /* Define to 1 if you have the <unistd.h> header file. */
#ifndef F_HAVE_UNISTD_H #ifndef F_HAVE_UNISTD_H

View File

@ -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-2021 Markus Gans * * Copyright 2015-2020 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,7 +29,6 @@
#include <array> #include <array>
#include "final/fstring.h"
#include "final/ftypes.h" #include "final/ftypes.h"
namespace finalcut namespace finalcut
@ -37,54 +36,35 @@ namespace finalcut
enum class FKey : uInt32; // forward declaration enum class FKey : uInt32; // forward declaration
class FKeyMap final namespace fc
{
struct FKeyCapMap
{ {
public:
struct KeyCapMap
{
FKey num; FKey num;
const char* string; const char* string;
char tname[4]; char tname[4];
};
struct KeyMap
{
FKey num;
char string[8];
};
struct KeyName
{
FKey num;
char string[26];
};
// Using-declaration
using KeyCapMapType = std::array<KeyCapMap, 188>;
using KeyMapType = std::array<KeyMap, 232>;
using KeyNameType = std::array<KeyName, 388>;
// Constructors
FKeyMap() = default;
// Accessors
FString getClassName() const;
static auto getInstance() -> FKeyMap&;
static KeyCapMapType& getKeyCapMap();
static const KeyMapType& getKeyMap();
static const KeyNameType& getKeyName();
private:
// Data members
static KeyCapMapType fkey_cap_table;
static const KeyMapType fkey_table;
static const KeyNameType fkeyname;
}; };
// FKeyMap inline functions extern std::array<FKeyCapMap, 188> fkey_cap_table;
//----------------------------------------------------------------------
inline FString FKeyMap::getClassName() const struct FKeyMap
{ return "FKeyMap"; } {
FKey num;
char string[8];
};
extern const std::array<FKeyMap, 232> fkey_table;
struct FKeyName
{
FKey num;
char string[26];
};
extern const std::array<FKeyName, 388> fkeyname;
} // namespace fc
} // namespace finalcut } // namespace finalcut

View File

@ -105,11 +105,10 @@ 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();
TimeValue getKeyPressedTime() const; timeval* getKeyPressedTime();
static uInt64 getKeypressTimeout(); static uInt64 getKeypressTimeout();
static uInt64 getReadBlockingTime(); static uInt64 getReadBlockingTime();
@ -146,7 +145,7 @@ class FKeyboard final
private: private:
// Using-declaration // Using-declaration
using FKeyMapPtr = std::shared_ptr<FKeyMap::KeyCapMapType>; using FKeyMapPtr = std::shared_ptr<decltype(fc::fkey_cap_table)>;
// Constants // Constants
static constexpr FKey NOT_SET = static_cast<FKey>(-1); static constexpr FKey NOT_SET = static_cast<FKey>(-1);
@ -163,7 +162,7 @@ class FKeyboard final
static bool isIntervalTimeout(); static bool isIntervalTimeout();
// Methods // Methods
FKey UTF8decode (const std::string&) const; FKey UTF8decode (const char[]) const;
ssize_t readKey(); ssize_t readKey();
void parseKeyBuffer(); void parseKeyBuffer();
FKey parseKeyString(); FKey parseKeyString();
@ -180,7 +179,7 @@ class FKeyboard final
FKeyboardCommand escape_key_cmd{}; FKeyboardCommand escape_key_cmd{};
FKeyboardCommand mouse_tracking_cmd{}; FKeyboardCommand mouse_tracking_cmd{};
static TimeValue time_keypressed; static timeval 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;
@ -215,8 +214,8 @@ inline FKeyboard::keybuffer& FKeyboard::getKeyBuffer()
{ return fifo_buf; } { return fifo_buf; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline TimeValue FKeyboard::getKeyPressedTime() const inline timeval* FKeyboard::getKeyPressedTime()
{ return time_keypressed; } { return &time_keypressed; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline uInt64 FKeyboard::getKeypressTimeout() inline uInt64 FKeyboard::getKeypressTimeout()
@ -234,8 +233,8 @@ inline void FKeyboard::setTermcapMap (const T& keymap)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FKeyboard::setTermcapMap () inline void FKeyboard::setTermcapMap ()
{ {
using type = FKeyMap::KeyCapMapType; using type = decltype(fc::fkey_cap_table);
key_map = std::make_shared<type>(FKeyMap::getKeyCapMap()); key_map = std::make_shared<type>(fc::fkey_cap_table);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -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&
, LazyConverter&& ); , const LazyConverter& );
template <typename Container template <typename Container
, typename LazyConverter> , typename LazyConverter>
void insert (Container*, LazyConverter&&); void insert (Container*, const 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, std::forward<LazyConverter>(convert)); insert (container, 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, LazyConverter&& converter) void FListBox::insert (const Container& container, const LazyConverter& converter)
{ {
conv_type = ConvertType::Lazy; conv_type = ConvertType::Lazy;
source_container = makeFData(container); source_container = makeFData(container);
lazy_inserter = std::forward<LazyConverter>(converter); lazy_inserter = 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, LazyConverter&& converter)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template <typename Container template <typename Container
, typename LazyConverter> , typename LazyConverter>
void FListBox::insert (Container* container, LazyConverter&& converter) void FListBox::insert (Container* container, const LazyConverter& converter)
{ {
insert (*container, std::forward<LazyConverter>(converter)); insert (*container, converter);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -340,12 +340,6 @@ 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*);
@ -447,9 +441,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, bool, bool); void drawListLine (const FListViewItem*, bool, bool);
void clearList(); void clearList();
void setLineAttributes (bool, bool, bool, bool) const; void setLineAttributes (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);
@ -504,7 +498,6 @@ 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{};
@ -530,7 +523,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};

View File

@ -98,18 +98,12 @@ 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;
@ -207,7 +201,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 (const TimeValue&) = 0; virtual void processEvent (struct timeval*) = 0;
protected: protected:
// Accessors // Accessors
@ -215,17 +209,17 @@ class FMouse : public FMouseData
uInt16 getMaxWidth() const; uInt16 getMaxWidth() const;
uInt16 getMaxHeight() const; uInt16 getMaxHeight() const;
uInt64 getDblclickInterval() const; uInt64 getDblclickInterval() const;
TimeValue getMousePressedTime() const; timeval* getMousePressedTime();
// 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 TimeValue&); void setMousePressedTime (const timeval*);
void resetMousePressedTime(); void resetMousePressedTime();
// Inquiry // Inquiry
bool isDblclickTimeout (const TimeValue&) const; bool isDblclickTimeout (const timeval*) const;
private: private:
// Data members // Data members
@ -234,7 +228,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
TimeValue time_mousepressed{}; struct timeval time_mousepressed{};
FPoint new_mouse_position{}; FPoint new_mouse_position{};
}; };
@ -269,7 +263,7 @@ class FMouseGPM final : public FMouse
// Methods // Methods
void setRawData (FKeyboard::keybuffer&) override; void setRawData (FKeyboard::keybuffer&) override;
void processEvent (const TimeValue&) override; void processEvent (struct timeval*) override;
bool gpmMouse (bool = true); bool gpmMouse (bool = true);
bool enableGpmMouse(); bool enableGpmMouse();
bool disableGpmMouse(); bool disableGpmMouse();
@ -327,7 +321,7 @@ class FMouseX11 final : public FMouse
// Methods // Methods
void setRawData (FKeyboard::keybuffer&) override; void setRawData (FKeyboard::keybuffer&) override;
void processEvent (const TimeValue&) override; void processEvent (struct timeval*) override;
private: private:
// Enumeration // Enumeration
@ -357,7 +351,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 TimeValue&); void setButtonState (const int, const struct timeval*);
// Data member // Data member
char x11_mouse[MOUSE_BUF_SIZE]{'\0'}; char x11_mouse[MOUSE_BUF_SIZE]{'\0'};
@ -380,7 +374,7 @@ class FMouseSGR final : public FMouse
// Methods // Methods
void setRawData (FKeyboard::keybuffer&) override; void setRawData (FKeyboard::keybuffer&) override;
void processEvent (const TimeValue&) override; void processEvent (struct timeval*) override;
private: private:
// Enumeration // Enumeration
@ -409,7 +403,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 TimeValue&); void setPressedButtonState (const int, const struct timeval*);
void setReleasedButtonState (const int); void setReleasedButtonState (const int);
// Data members // Data members
@ -433,7 +427,7 @@ class FMouseUrxvt final : public FMouse
// Methods // Methods
void setRawData (FKeyboard::keybuffer&) override; void setRawData (FKeyboard::keybuffer&) override;
void processEvent (const TimeValue&) override; void processEvent (struct timeval*) override;
private: private:
// Enumeration // Enumeration
@ -463,7 +457,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 TimeValue&); void setButtonState (const int, const struct timeval*);
// Data members // Data members
char urxvt_mouse[MOUSE_BUF_SIZE]{'\0'}; char urxvt_mouse[MOUSE_BUF_SIZE]{'\0'};
@ -512,7 +506,6 @@ 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();
@ -550,7 +543,7 @@ class FMouseControl
void disable(); void disable();
virtual void setRawData ( FMouse::MouseType virtual void setRawData ( FMouse::MouseType
, FKeyboard::keybuffer& ); , FKeyboard::keybuffer& );
virtual void processEvent (const TimeValue&); virtual void processEvent (struct timeval* time);
void processQueuedInput(); void processQueuedInput();
bool getGpmKeyPressed (bool = true); bool getGpmKeyPressed (bool = true);
void drawPointer(); void drawPointer();

View File

@ -44,24 +44,15 @@
#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;
@ -131,6 +122,7 @@ 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();
@ -142,8 +134,8 @@ class FObject
virtual bool event (FEvent*); virtual bool event (FEvent*);
// Timer methods // Timer methods
static TimeValue getCurrentTime(); static void getCurrentTime (timeval*);
static bool isTimeout (const TimeValue&, uInt64); static bool isTimeout (const timeval*, uInt64);
int addTimer (int); int addTimer (int);
bool delTimer (int) const; bool delTimer (int) const;
bool delOwnTimers() const; bool delOwnTimers() const;
@ -153,8 +145,8 @@ class FObject
struct FTimerData struct FTimerData
{ {
int id; int id;
milliseconds interval; timeval interval;
TimeValue timeout; timeval timeout;
FObject* object; FObject* object;
}; };
@ -186,6 +178,7 @@ 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;
}; };
@ -269,6 +262,10 @@ 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(); }
@ -277,6 +274,61 @@ 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

View File

@ -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-2021 Markus Gans * * Copyright 2016-2020 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,7 +39,6 @@
#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
@ -108,7 +107,6 @@ 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&);
@ -158,7 +156,7 @@ class FOptiAttr final
// Methods // Methods
void initialize(); void initialize();
static FColor vga2ansi (FColor); static FColor vga2ansi (FColor);
std::string changeAttribute (FChar&, FChar&); const char* changeAttribute (FChar&, FChar&);
private: private:
struct Capability struct Capability
@ -167,6 +165,9 @@ 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
{ {
@ -223,7 +224,10 @@ class FOptiAttr final
bool unsetTermCrossedOut (FChar&); bool unsetTermCrossedOut (FChar&);
bool setTermDoubleUnderline (FChar&); bool setTermDoubleUnderline (FChar&);
bool unsetTermDoubleUnderline (FChar&); bool unsetTermDoubleUnderline (FChar&);
bool setTermAttributes (FChar&, const TCapAttributes&); bool setTermAttributes ( FChar&
, bool, bool, bool
, bool, bool, bool
, bool, bool, bool );
bool unsetTermAttributes (FChar&); bool unsetTermAttributes (FChar&);
bool setTermAltCharset (FChar&); bool setTermAltCharset (FChar&);
bool unsetTermAltCharset (FChar&); bool unsetTermAltCharset (FChar&);
@ -299,8 +303,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};

View File

@ -44,7 +44,6 @@
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <string>
#include "final/fstring.h" #include "final/fstring.h"
@ -93,7 +92,6 @@ 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;
@ -145,7 +143,7 @@ class FOptiMove final
// Methods // Methods
void check_boundaries (int&, int&, int&, int&) const; void check_boundaries (int&, int&, int&, int&) const;
std::string moveCursor (int, int, int, int); const char* moveCursor (int, int, int, int);
private: private:
struct Capability struct Capability
@ -156,7 +154,7 @@ class FOptiMove final
}; };
// Constant // Constant
static constexpr std::string::size_type BUF_SIZE{512u}; static constexpr std::size_t BUF_SIZE{512};
// Constants // Constants
static constexpr int LONG_DURATION{INT_MAX}; static constexpr int LONG_DURATION{INT_MAX};
@ -168,14 +166,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 (std::string&, const Capability&, int) const; int repeatedAppend (const Capability&, int, char*) const;
int relativeMove (std::string&, int, int, int, int) const; int relativeMove (char[], int, int, int, int) const;
int verticalMove (std::string&, int, int) const; int verticalMove (char[], int, int) const;
void downMove (std::string&, int&, int, int) const; void downMove (char[], int&, int, int) const;
void upMove (std::string&, int&, int, int) const; void upMove (char[], int&, int, int) const;
int horizontalMove (std::string&, int, int) const; int horizontalMove (char[], int, int) const;
void rightMove (std::string&, int&, int, int) const; void rightMove (char[], int&, int, int) const;
void leftMove (std::string&, int&, int, int) const; void leftMove (char[], 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);
@ -213,7 +211,7 @@ class FOptiMove final
int char_duration{1}; int char_duration{1};
int baudrate{9600}; int baudrate{9600};
int tabstop{0}; int tabstop{0};
std::string move_buf{}; char move_buf[BUF_SIZE]{'\0'};
bool automatic_left_margin{false}; bool automatic_left_margin{false};
bool eat_nl_glitch{false}; bool eat_nl_glitch{false};

View File

@ -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-2021 Markus Gans * * Copyright 2019-2020 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 auto getInstance() -> FStartOptions&; static FStartOptions& getFStartOptions();
// Mutator // Mutator
void setDefault(); void setDefault();

View File

@ -80,11 +80,10 @@ class FString
{ {
public: public:
// Using-declarations // Using-declarations
using iterator = std::wstring::iterator; using iterator = wchar_t*;
using const_iterator = std::wstring::const_iterator; using const_iterator = const wchar_t*;
using reference = std::wstring::reference; using reference = wchar_t&;
using const_reference = std::wstring::const_reference; using const_reference = const wchar_t&;
using difference_type = std::wstring::difference_type;
// Constructors // Constructors
FString () = default; FString () = default;
@ -168,7 +167,7 @@ class FString
virtual FString getClassName() const; virtual FString getClassName() const;
// inquiries // inquiries
bool isNull() const noexcept; // deprecated bool isNull() const noexcept;
bool isEmpty() const noexcept; bool isEmpty() const noexcept;
// Methods // Methods
@ -246,16 +245,24 @@ class FString
private: private:
// Constants // Constants
static constexpr uInt FWDBUFFER = 15;
static constexpr uInt INPBUFFER = 200; static constexpr uInt INPBUFFER = 200;
// Methods // Methods
void _assign (std::wstring&); void _initLength (std::size_t);
std::string _toCharString (const std::wstring&) const; void _assign (const wchar_t[]);
std::wstring _toWideString (const std::string&) const; void _insert (std::size_t, const wchar_t[]);
void _insert (std::size_t, std::size_t, const wchar_t[]);
void _remove (std::size_t, std::size_t);
const char* _to_cstring (const wchar_t[]) const;
const wchar_t* _to_wcstring (const char[]) const;
const wchar_t* _extractToken (wchar_t*[], const wchar_t[], const wchar_t[]) const;
// Data members // Data members
std::wstring string{}; wchar_t* string{nullptr};
mutable std::string char_string{}; std::size_t length{0};
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;
@ -281,7 +288,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));
string.append(numstr.string); _insert (length, numstr.length, numstr.string);
return *this; return *this;
} }
@ -289,10 +296,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(string.length()) ) if ( isNegative(pos) || pos > IndexT(length) )
throw std::out_of_range(""); // Invalid index position throw std::out_of_range(""); // Invalid index position
if ( std::size_t(pos) == string.length() ) if ( std::size_t(pos) == length )
return null_char; return null_char;
return string[std::size_t(pos)]; return string[std::size_t(pos)];
@ -302,10 +309,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(string.length()) ) if ( isNegative(pos) || pos > IndexT(length) )
throw std::out_of_range(""); // Invalid index position throw std::out_of_range(""); // Invalid index position
if ( std::size_t(pos) == string.length() ) if ( std::size_t(pos) == length )
return const_null_char; return const_null_char;
return string[std::size_t(pos)]; return string[std::size_t(pos)];
@ -364,63 +371,63 @@ inline FString FString::getClassName() const
{ return "FString"; } { return "FString"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FString::isNull() const noexcept // deprecated inline bool FString::isNull() const noexcept
{ return false; } { return ( bufsize == 0 || (bufsize > 0 && ! string) ); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FString::isEmpty() const noexcept inline bool FString::isEmpty() const noexcept
{ return string.empty(); } { return ( length == 0 || (length > 0 && string[0] == L'\0') ); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::size_t FString::getLength() const noexcept inline std::size_t FString::getLength() const noexcept
{ return string.length(); } { return length; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::size_t FString::capacity() const noexcept inline std::size_t FString::capacity() const noexcept
{ return string.capacity(); } { return ( length > 0 ) ? bufsize - 1 : 0; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString::iterator FString::begin() noexcept inline FString::iterator FString::begin() noexcept
{ return string.begin(); } { return string; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString::iterator FString::end() noexcept inline FString::iterator FString::end() noexcept
{ return string.end(); } { return string + length; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString::const_iterator FString::begin() const noexcept inline FString::const_iterator FString::begin() const noexcept
{ return string.cbegin(); } { return string; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString::const_iterator FString::end() const noexcept inline FString::const_iterator FString::end() const noexcept
{ return string.cend(); } { return string + length; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString::reference FString::front() inline FString::reference FString::front()
{ {
assert ( ! isEmpty() ); assert ( ! isEmpty() );
return string.front(); return (*this)[0];
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString::reference FString::back() inline FString::reference FString::back()
{ {
assert( ! isEmpty() ); assert( ! isEmpty() );
return string.back(); return (*this)[length - 1];
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString::const_reference FString::front() const inline FString::const_reference FString::front() const
{ {
assert ( ! isEmpty() ); assert ( ! isEmpty() );
return string.front(); return (*this)[0];
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString::const_reference FString::back() const inline FString::const_reference FString::back() const
{ {
assert( ! isEmpty() ); assert( ! isEmpty() );
return string.back(); return (*this)[length - 1];
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -437,7 +444,7 @@ inline FString& FString::sprintf (const FString& format, Args&&... args)
std::swprintf ( buf.data(), buf.size(), format.wc_str() std::swprintf ( buf.data(), buf.size(), format.wc_str()
, std::forward<Args>(args)... ); , std::forward<Args>(args)... );
setString(buf.data()); _assign(buf.data());
return *this; return *this;
} }

View File

@ -57,9 +57,6 @@ 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;

View File

@ -127,12 +127,31 @@ 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
@ -168,6 +187,31 @@ 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&);
@ -224,7 +268,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 std::string cursorsVisibilityString (bool = true); static const char* 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&);
@ -257,7 +301,7 @@ class FTerm final
void initTerminal(); void initTerminal();
static void initScreenSettings(); static void initScreenSettings();
static std::string changeAttribute (FChar&, FChar&); static const char* changeAttribute (FChar&, FChar&);
static void changeTermSizeFinished(); static void changeTermSizeFinished();
private: private:
@ -292,8 +336,8 @@ class FTerm final
static void restoreColorPalette(); static void restoreColorPalette();
static void setInsertCursorStyle(); static void setInsertCursorStyle();
static void setOverwriteCursorStyle(); static void setOverwriteCursorStyle();
static std::string enableCursorString(); static const char* enableCursorString();
static std::string disableCursorString(); static const char* disableCursorString();
static void enableMouse(); static void enableMouse();
static void disableMouse(); static void disableMouse();
static void enableApplicationEscKey(); static void enableApplicationEscKey();
@ -323,7 +367,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 std::string&); uInt env2uint (const char*);
bool isReverseNewFontchar (wchar_t); bool isReverseNewFontchar (wchar_t);
bool hasFullWidthSupports(); bool hasFullWidthSupports();
wchar_t cp437_to_unicode (uChar); wchar_t cp437_to_unicode (uChar);
@ -360,7 +404,7 @@ inline FString FTerm::getClassName()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTerm::setFSystem (std::unique_ptr<FSystem>& fsystem) inline void FTerm::setFSystem (std::unique_ptr<FSystem>& fsystem)
{ {
FSystem::getInstance().swap(fsystem); getFSystem().swap(fsystem);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -375,8 +419,8 @@ inline bool FTerm::unsetUTF8()
template <typename ClassT> template <typename ClassT>
inline void FTerm::setColorPaletteTheme (const FSetPalette& f) inline void FTerm::setColorPaletteTheme (const FSetPalette& f)
{ {
FColorPalette::getInstance() = std::make_shared<ClassT>(f); // Set instance getColorPaletteTheme() = std::make_shared<ClassT>(f);
FColorPalette::getInstance()->setColorPalette(); // Set palette getColorPaletteTheme()->setColorPalette();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -111,7 +111,7 @@ class FTermBuffer
private: private:
FCharVector data{}; FCharVector data{};
void add ( FString::const_iterator& void add ( FString::const_iterator&
, const FString::const_iterator& , FString::const_iterator&
, int& ); , int& );
// Non-member operators // Non-member operators

View File

@ -41,8 +41,6 @@
#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
@ -131,7 +129,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::array<int, 9>& ); , const std::vector<int>& );
template<typename PutChar> template<typename PutChar>
static void delay_output (int, const PutChar&); static void delay_output (int, const PutChar&);
@ -151,9 +149,7 @@ 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)
{ {
std::array<int, 9> attr{{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }}; return encodeParams(cap, {static_cast<int>(args)...});
attr = {{static_cast<int>(args)...}};
return encodeParams(cap, attr);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -72,7 +72,6 @@ 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;
@ -171,13 +170,6 @@ 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; }

View File

@ -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-2021 Markus Gans * * Copyright 2018-2020 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,13 +35,14 @@
#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
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -62,21 +63,16 @@ 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 FString& getTermType_256color(); const char* getTermType_256color();
const FString& getTermType_Answerback(); const char* getTermType_Answerback();
const FString& getTermType_SecDA(); const char* 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

View File

@ -79,12 +79,7 @@ class FTermDetection final
uInt8 : 3; // padding bits uInt8 : 3; // padding bits
}; };
struct kittyVersion struct kittyVersion; // forward declaration
{
int primary{0};
int secondary{0};
};
// Constructors // Constructors
FTermDetection(); FTermDetection();
@ -99,167 +94,183 @@ class FTermDetection final
FTermDetection& operator = (const FTermDetection&) = delete; FTermDetection& operator = (const FTermDetection&) = delete;
// Accessor // Accessor
FString getClassName() const; static FString getClassName();
static auto getInstance() -> FTermDetection&; static const char* getTermType();
const FString& getTermType() const; static int getGnomeTerminalID();
int getGnomeTerminalID() const; static kittyVersion getKittyVersion();
kittyVersion getKittyVersion() const;
FTerminalType& getTermTypeStruct(); FTerminalType& getTermTypeStruct();
#if DEBUG #if DEBUG
const FString& getAnswerbackString() const; static const FString& getAnswerbackString();
const FString& getSecDAString() const; static const FString& getSecDAString();
const FString& getTermType_256color() const; static const char* getTermType_256color();
const FString& getTermType_Answerback() const; static const char* getTermType_Answerback();
const FString& getTermType_SecDA() const; static const char* getTermType_SecDA();
#endif #endif
// Inquiries // Inquiries
bool isAnsiTerminal() const; static bool isAnsiTerminal();
bool isXTerminal() const; static bool isXTerminal();
bool isRxvtTerminal() const; static bool isRxvtTerminal();
bool isUrxvtTerminal() const; static bool isUrxvtTerminal();
bool isKdeTerminal() const; static bool isKdeTerminal();
bool isGnomeTerminal() const; static bool isGnomeTerminal();
bool isPuttyTerminal() const; static bool isPuttyTerminal();
bool isWindowsTerminal() const; static bool isWindowsTerminal();
bool isTeraTerm() const; static bool isTeraTerm();
bool isCygwinTerminal() const; static bool isCygwinTerminal();
bool isMinttyTerm() const; static bool isMinttyTerm();
bool isLinuxTerm() const; static bool isLinuxTerm();
bool isFreeBSDTerm() const; static bool isFreeBSDTerm();
bool isNetBSDTerm() const; static bool isNetBSDTerm();
bool isOpenBSDTerm() const; static bool isOpenBSDTerm();
bool isSunTerminal() const; static bool isSunTerminal();
bool isScreenTerm() const; static bool isScreenTerm();
bool isTmuxTerm() const; static bool isTmuxTerm();
bool isKtermTerminal() const; static bool isKtermTerminal();
bool isMltermTerminal() const; static bool isMltermTerminal();
bool isKittyTerminal() const; static bool isKittyTerminal();
bool canDisplay256Colors() const; static bool canDisplay256Colors();
bool hasTerminalDetection() const; static bool hasTerminalDetection();
bool hasSetCursorStyleSupport() const; static bool hasSetCursorStyleSupport();
// Mutators // Mutators
void setAnsiTerminal (bool = true); static void setAnsiTerminal (bool = true);
void setXTerminal (bool = true); static void setXTerminal (bool = true);
void setRxvtTerminal (bool = true); static void setRxvtTerminal (bool = true);
void setUrxvtTerminal (bool = true); static void setUrxvtTerminal (bool = true);
void setKdeTerminal (bool = true); static void setKdeTerminal (bool = true);
void setGnomeTerminal (bool = true); static void setGnomeTerminal (bool = true);
void setPuttyTerminal (bool = true); static void setPuttyTerminal (bool = true);
void setWindowsTerminal (bool = true); static void setWindowsTerminal (bool = true);
void setTeraTerm (bool = true); static void setTeraTerm (bool = true);
void setCygwinTerminal (bool = true); static void setCygwinTerminal (bool = true);
void setMinttyTerm (bool = true); static void setMinttyTerm (bool = true);
void setLinuxTerm (bool = true); static void setLinuxTerm (bool = true);
void setFreeBSDTerm (bool = true); static void setFreeBSDTerm (bool = true);
void setNetBSDTerm (bool = true); static void setNetBSDTerm (bool = true);
void setOpenBSDTerm (bool = true); static void setOpenBSDTerm (bool = true);
void setSunTerminal (bool = true); static void setSunTerminal (bool = true);
void setScreenTerm (bool = true); static void setScreenTerm (bool = true);
void setTmuxTerm (bool = true); static void setTmuxTerm (bool = true);
void setKtermTerminal (bool = true); static void setKtermTerminal (bool = true);
void setMltermTerminal (bool = true); static void setMltermTerminal (bool = true);
void setKittyTerminal (bool = true); static void setKittyTerminal (bool = true);
void setTerminalDetection (bool = true); static void setTerminalDetection (bool = true);
void setTtyTypeFileName (const FString&); static void setTtyTypeFileName (const char[]);
// Methods // Methods
void detect(); static void detect();
private: private:
struct colorEnv struct colorEnv; // forward declaration
{ struct secondaryDA; // forward declaration
FString string1{};
FString string2{};
FString string3{};
FString string4{};
FString string5{};
FString string6{};
FString string7{};
FString string8{};
};
struct secondaryDA
{
int terminal_id_type{-1};
int terminal_id_version{-1};
int terminal_id_hardware{-1};
};
// Methods // Methods
void getSystemTermType(); static void deallocation();
bool getTTYtype(); static void getSystemTermType();
static bool getTTYtype();
#if F_HAVE_GETTTYNAM #if F_HAVE_GETTTYNAM
bool getTTYSFileEntry(); static bool getTTYSFileEntry();
#endif #endif
void termtypeAnalysis(); static void termtypeAnalysis();
void detectTerminal(); static void detectTerminal();
FString init_256colorTerminal(); static const char* init_256colorTerminal();
bool get256colorEnvString(); static bool get256colorEnvString();
FString termtype_256color_quirks(); static const char* termtype_256color_quirks();
FString determineMaxColor (const FString&); static const char* determineMaxColor (const char[]);
FString getXTermColorName (FColor) const; static FString getXTermColorName (FColor);
FString parseAnswerbackMsg (const FString&); static const char* parseAnswerbackMsg (const char[]);
FString getAnswerbackMsg() const; static FString getAnswerbackMsg();
FString parseSecDA (const FString&); static const char* parseSecDA (const char[]);
int str2int (const FString&) const; static int str2int (const FString&);
FString getSecDA() const; static FString getSecDA();
FString secDA_Analysis (const FString&); static const char* secDA_Analysis (const char[]);
FString secDA_Analysis_0 (const FString&); static const char* secDA_Analysis_0 (const char[]);
FString secDA_Analysis_1 (const FString&); static const char* secDA_Analysis_1 (const char[]);
FString secDA_Analysis_24 (const FString&); static const char* secDA_Analysis_24 (const char[]);
FString secDA_Analysis_32 (); static const char* secDA_Analysis_32 (const char[]);
FString secDA_Analysis_65 (const FString&); static const char* secDA_Analysis_65 (const char[]);
FString secDA_Analysis_67 (); static const char* secDA_Analysis_67 (const char[]);
FString secDA_Analysis_77 (); static const char* secDA_Analysis_77 (const char[]);
FString secDA_Analysis_82 (); static const char* secDA_Analysis_82 ();
FString secDA_Analysis_83 (const FString&); static const char* secDA_Analysis_83 (const char[]);
FString secDA_Analysis_84 (const FString&); static const char* secDA_Analysis_84 (const char[]);
FString secDA_Analysis_85 (); static const char* secDA_Analysis_85 ();
FString secDA_Analysis_vte (const FString&); static const char* secDA_Analysis_vte (const char[]);
FString secDA_Analysis_kitty (const FString&); static const char* secDA_Analysis_kitty (const char[]);
// Data members // Data members
#if DEBUG #if DEBUG
FString termtype_256color{}; static char termtype_256color[256];
FString termtype_Answerback{}; static char termtype_Answerback[256];
FString termtype_SecDA{}; static char termtype_SecDA[256];
#endif #endif
FString termtype{}; static char termtype[256];
FString ttytypename{"/etc/ttytype"}; // Default ttytype file static char ttytypename[256];
bool decscusr_support{false}; // Preset to false static bool decscusr_support;
bool terminal_detection{true}; // Preset to true static bool terminal_detection;
bool color256{}; static bool color256;
// Gnome terminal id from SecDA static int gnome_terminal_id;
// Example: vte version 0.40.0 = 0 * 100 + 40 * 100 + 0 = 4000 static const FString* answer_back;
// a.b.c = a * 100 + b * 100 + c static const FString* sec_da;
int gnome_terminal_id{0}; static FTerminalType terminal_type;
FString answer_back{}; static colorEnv color_env;
FString sec_da{}; static kittyVersion kitty_version;
FTerminalType terminal_type{}; static secondaryDA secondary_da;
colorEnv color_env{}; };
kittyVersion kitty_version{};
secondaryDA secondary_da{};
//----------------------------------------------------------------------
// struct FTermDetection::colorEnv
//----------------------------------------------------------------------
struct FTermDetection::colorEnv
{
char* string1{nullptr};
char* string2{nullptr};
char* string3{nullptr};
char* string4{nullptr};
char* string5{nullptr};
char* string6{nullptr};
char* string7{nullptr};
char* string8{nullptr};
};
//----------------------------------------------------------------------
// struct FTermDetection::KittyVersion
//----------------------------------------------------------------------
struct FTermDetection::kittyVersion
{
int primary{0};
int secondary{0};
};
//----------------------------------------------------------------------
// struct FTermDetection::secondaryDA
//----------------------------------------------------------------------
struct FTermDetection::secondaryDA
{
int terminal_id_type{-1};
int terminal_id_version{-1};
int terminal_id_hardware{-1};
}; };
// FTermDetection inline functions // FTermDetection inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FTermDetection::getClassName() const inline FString FTermDetection::getClassName()
{ return "FTermDetection"; } { return "FTermDetection"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString& FTermDetection::getTermType() const inline const char* FTermDetection::getTermType()
{ return termtype; } { return termtype; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FTermDetection::getGnomeTerminalID() const inline int FTermDetection::getGnomeTerminalID()
{ return gnome_terminal_id; } { return gnome_terminal_id; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FTermDetection::kittyVersion FTermDetection::getKittyVersion() const inline FTermDetection::kittyVersion FTermDetection::getKittyVersion()
{ return kitty_version; } { return kitty_version; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -268,112 +279,112 @@ inline FTermDetection::FTerminalType& FTermDetection::getTermTypeStruct()
#if DEBUG #if DEBUG
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString& FTermDetection::getTermType_256color() const inline const char* FTermDetection::getTermType_256color()
{ return termtype_256color; } { return termtype_256color; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString& FTermDetection::getTermType_Answerback() const inline const char* FTermDetection::getTermType_Answerback()
{ return termtype_Answerback; } { return termtype_Answerback; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString& FTermDetection::getTermType_SecDA() const inline const char* FTermDetection::getTermType_SecDA()
{ return termtype_SecDA; } { return termtype_SecDA; }
#endif #endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::canDisplay256Colors() const inline bool FTermDetection::canDisplay256Colors()
{ return color256; } { return color256; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::hasSetCursorStyleSupport() const inline bool FTermDetection::hasSetCursorStyleSupport()
{ return decscusr_support; } { return decscusr_support; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isXTerminal() const inline bool FTermDetection::isXTerminal()
{ return terminal_type.xterm; } { return terminal_type.xterm; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isAnsiTerminal() const inline bool FTermDetection::isAnsiTerminal()
{ return terminal_type.ansi; } { return terminal_type.ansi; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isRxvtTerminal() const inline bool FTermDetection::isRxvtTerminal()
{ return terminal_type.rxvt; } { return terminal_type.rxvt; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isUrxvtTerminal() const inline bool FTermDetection::isUrxvtTerminal()
{ return terminal_type.urxvt; } { return terminal_type.urxvt; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isMltermTerminal() const inline bool FTermDetection::isMltermTerminal()
{ return terminal_type.mlterm; } { return terminal_type.mlterm; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isKittyTerminal() const inline bool FTermDetection::isKittyTerminal()
{ return terminal_type.kitty; } { return terminal_type.kitty; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isPuttyTerminal() const inline bool FTermDetection::isPuttyTerminal()
{ return terminal_type.putty; } { return terminal_type.putty; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isWindowsTerminal() const inline bool FTermDetection::isWindowsTerminal()
{ return terminal_type.win_terminal; } { return terminal_type.win_terminal; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isKdeTerminal() const inline bool FTermDetection::isKdeTerminal()
{ return terminal_type.kde_konsole; } { return terminal_type.kde_konsole; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isGnomeTerminal() const inline bool FTermDetection::isGnomeTerminal()
{ return terminal_type.gnome_terminal; } { return terminal_type.gnome_terminal; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isKtermTerminal() const inline bool FTermDetection::isKtermTerminal()
{ return terminal_type.kterm; } { return terminal_type.kterm; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isTeraTerm() const inline bool FTermDetection::isTeraTerm()
{ return terminal_type.tera_term; } { return terminal_type.tera_term; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isCygwinTerminal() const inline bool FTermDetection::isCygwinTerminal()
{ return terminal_type.cygwin; } { return terminal_type.cygwin; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isMinttyTerm() const inline bool FTermDetection::isMinttyTerm()
{ return terminal_type.mintty; } { return terminal_type.mintty; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isLinuxTerm() const inline bool FTermDetection::isLinuxTerm()
{ return terminal_type.linux_con; } { return terminal_type.linux_con; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isFreeBSDTerm() const inline bool FTermDetection::isFreeBSDTerm()
{ return terminal_type.freebsd_con; } { return terminal_type.freebsd_con; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isNetBSDTerm() const inline bool FTermDetection::isNetBSDTerm()
{ return terminal_type.netbsd_con; } { return terminal_type.netbsd_con; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isOpenBSDTerm() const inline bool FTermDetection::isOpenBSDTerm()
{ return terminal_type.openbsd_con; } { return terminal_type.openbsd_con; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isSunTerminal() const inline bool FTermDetection::isSunTerminal()
{ return terminal_type.sun_con; } { return terminal_type.sun_con; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isScreenTerm() const inline bool FTermDetection::isScreenTerm()
{ return terminal_type.screen; } { return terminal_type.screen; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::isTmuxTerm() const inline bool FTermDetection::isTmuxTerm()
{ return terminal_type.tmux; } { return terminal_type.tmux; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermDetection::hasTerminalDetection() const inline bool FTermDetection::hasTerminalDetection()
{ return terminal_detection; } { return terminal_detection; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -83,7 +83,6 @@ class FTermFreeBSD final
// Accessors // Accessors
FString getClassName() const; FString getClassName() const;
static auto getInstance() -> FTermFreeBSD&;
static CursorStyle getCursorStyle(); static CursorStyle getCursorStyle();
// Inquiry // Inquiry

View File

@ -92,7 +92,6 @@ 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;

View File

@ -73,7 +73,6 @@ 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();

View File

@ -66,7 +66,6 @@ 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;

View File

@ -251,6 +251,10 @@ void FTextView::insert (const std::initializer_list<T>& list, int pos)
} }
} }
//----------------------------------------------------------------------
inline void FTextView::deleteRange (int from, int to)
{ replaceRange (FString(), from, to); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTextView::deleteLine (int pos) inline void FTextView::deleteLine (int pos)
{ deleteRange (pos, pos); } { deleteRange (pos, pos); }

View File

@ -34,7 +34,6 @@
#include <cstring> #include <cstring>
#include <array> #include <array>
#include <chrono>
#include <functional> #include <functional>
#include <limits> #include <limits>
#include <memory> #include <memory>
@ -69,7 +68,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
@ -120,34 +119,8 @@ 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

View File

@ -418,8 +418,10 @@ 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);
@ -451,7 +453,8 @@ 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 TimeValue time_last_flush; static timeval 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;
@ -459,6 +462,7 @@ 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;

View File

@ -507,7 +507,6 @@ 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&);

View File

@ -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-2021 Markus Gans * * Copyright 2019-2020 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,10 +49,13 @@ class SGRoptimizer final
{ {
public: public:
// Constants // Constants
static constexpr std::string::size_type ATTR_BUF_SIZE{8192u}; static constexpr std::size_t ATTR_BUF_SIZE{8192};
// Using-declaration
using AttributeBuffer = std::array<char, ATTR_BUF_SIZE>;
// Constructors // Constructors
explicit SGRoptimizer (std::string&); explicit SGRoptimizer (AttributeBuffer&);
// Disable copy constructor // Disable copy constructor
SGRoptimizer (const SGRoptimizer&) = delete; SGRoptimizer (const SGRoptimizer&) = delete;
@ -75,7 +78,7 @@ class SGRoptimizer final
void combineParameter(); void combineParameter();
// Data member // Data member
std::string& seq; AttributeBuffer& seq;
struct parameter struct parameter
{ {

Some files were not shown because too many files have changed in this diff Show More