commit
5149301d29
|
@ -0,0 +1,74 @@
|
||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [master]
|
||||||
|
schedule:
|
||||||
|
- cron: '0 7 * * 2'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
# Override automatic language detection by changing the below list
|
||||||
|
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
|
||||||
|
language: ['cpp']
|
||||||
|
# Learn more...
|
||||||
|
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# We must fetch at least the immediate parents so that if this is
|
||||||
|
# a pull request then we can checkout the head.
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
# If this run was triggered by a pull request event, then checkout
|
||||||
|
# the head of the pull request instead of the merge commit.
|
||||||
|
- run: git checkout HEAD^2
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
- name: Build dependencies
|
||||||
|
run: sudo apt-get install autoconf-archive
|
||||||
|
|
||||||
|
- name: Create configure file
|
||||||
|
run: autoreconf -v --install --force
|
||||||
|
|
||||||
|
- name: Create makefiles
|
||||||
|
run: ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic"
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: make V=1 -j10
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
|
@ -1,6 +1,5 @@
|
||||||
language: cpp
|
language: cpp
|
||||||
dist: xenial
|
dist: xenial
|
||||||
sudo: required
|
|
||||||
compiler:
|
compiler:
|
||||||
- gcc
|
- gcc
|
||||||
|
|
||||||
|
@ -41,7 +40,7 @@ env:
|
||||||
bL/epiiMBKJ37X1UcRU4WZYq+peLME8EefcPcXOSWNLwJtR7mtON8uMBrLL9CWmRMFD5Hy
|
bL/epiiMBKJ37X1UcRU4WZYq+peLME8EefcPcXOSWNLwJtR7mtON8uMBrLL9CWmRMFD5Hy
|
||||||
lQYALW2DhCnDBROKB3gxB/VkBGFNE0IPGeDtBGbLqDtKWPQoL125I=
|
lQYALW2DhCnDBROKB3gxB/VkBGFNE0IPGeDtBGbLqDtKWPQoL125I=
|
||||||
|
|
||||||
matrix:
|
jobs:
|
||||||
include:
|
include:
|
||||||
#
|
#
|
||||||
# Coverity Scan
|
# Coverity Scan
|
||||||
|
|
47
ChangeLog
47
ChangeLog
|
@ -1,3 +1,50 @@
|
||||||
|
2020-10-11 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Solaris build fix
|
||||||
|
* Added saving and restoring xterm titles to the stack
|
||||||
|
for vte terminals
|
||||||
|
* Menu key - activates the menu bar
|
||||||
|
* Shift-Menu - opens the dialog menu
|
||||||
|
|
||||||
|
2020-10-08 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Better keyboard support for urxvt terminals
|
||||||
|
* Screen reports (like Secondary DA) are now read directly
|
||||||
|
* Report Cursor Position (DECXCPR) support
|
||||||
|
* FListView and FListBox now have direct access to the list of client
|
||||||
|
elements via data()
|
||||||
|
|
||||||
|
2020-10-05 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Now hides the input cursor when a widget gets hidden
|
||||||
|
|
||||||
|
2020-10-04 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Replaces some C-style arrays with std::array
|
||||||
|
* Now you can use the arrow keys to move a window into the visible area
|
||||||
|
* Removes FData memory leak in FListBoxItem and FListViewItem
|
||||||
|
|
||||||
|
2020-09-27 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* An explanation of the widget tree was added to the document
|
||||||
|
of the first steps
|
||||||
|
|
||||||
|
2020-09-26 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* FData improvements
|
||||||
|
* The number of FObject children can now be limited with
|
||||||
|
setMaxChildren()
|
||||||
|
* FApplication can now have no more than one child widget
|
||||||
|
|
||||||
|
2020-09-25 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* std::clog now streams everything to the FLogger object
|
||||||
|
* Added a unit test for the FData class
|
||||||
|
|
||||||
|
2020-09-23 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Bugfix: empty FString() + wchar_t
|
||||||
|
|
||||||
|
2020-09-22 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Bugfix in FDialog::setSize(): Automatic size adjustment and
|
||||||
|
simultaneous widget movement are now possible.
|
||||||
|
|
||||||
|
2020-09-18 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* The generic data type FDataPtr is now deprecated and was
|
||||||
|
completely replaced by the template class FData
|
||||||
|
|
||||||
2020-09-11 Markus Gans <guru.mail@muenster.de>
|
2020-09-11 Markus Gans <guru.mail@muenster.de>
|
||||||
* Fixes a problem with mouse input in Cygwin in non-blocking read mode
|
* Fixes a problem with mouse input in Cygwin in non-blocking read mode
|
||||||
|
|
||||||
|
|
39
README.md
39
README.md
|
@ -136,7 +136,10 @@ printf(...)
|
||||||
## Class digramm
|
## Class digramm
|
||||||
|
|
||||||
<pre style="line-height: 1 !important;">
|
<pre style="line-height: 1 !important;">
|
||||||
1┌──────────────┐
|
1┌────────────┐
|
||||||
|
┌-----------┤ FTermLinux │
|
||||||
|
: └────────────┘
|
||||||
|
: 1┌──────────────┐
|
||||||
┌-----------┤ FTermFreeBSD │
|
┌-----------┤ FTermFreeBSD │
|
||||||
: └──────────────┘
|
: └──────────────┘
|
||||||
: 1┌──────────────┐
|
: 1┌──────────────┐
|
||||||
|
@ -172,12 +175,15 @@ printf(...)
|
||||||
: 1┌───────────────┐ │ ┌─────────────┐
|
: 1┌───────────────┐ │ ┌─────────────┐
|
||||||
┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
|
┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
|
||||||
: └───────────────┘ │ └─────────────┘
|
: └───────────────┘ │ └─────────────┘
|
||||||
: 1┌─────────┐ │ ┌──────┐ ┌─────────┐
|
: 1┌─────────┐ │ ┌────────────┐1 1┌───────┐
|
||||||
┌-----------┤ FSystem │ │ │ FLog │◄──┤ FLogger │
|
┌-----------┤ FSystem │ ├────┤ FUserEvent ├------┤ FData │
|
||||||
: └─────────┘ │ └──┬───┘ └─────────┘
|
: └─────────┘ │ └────────────┘ └───────┘
|
||||||
: *┌─────────┐ │ :1
|
: *┌─────────┐ │ ┌──────┐ ┌─────────┐
|
||||||
: ┌--------┤ FString │ │ ┌──┴───────────┐
|
: ┌--------┤ FString │ │ │ FLog │◄──┤ FLogger │
|
||||||
: : └─────────┘ │ ┌────┤ FApplication │
|
: : └─────────┘ │ └──┬───┘ └─────────┘
|
||||||
|
: : *┌───────────────┐ │ :1
|
||||||
|
: ┌--------┤ FStringStream │ │ ┌──┴───────────┐
|
||||||
|
: : └───────────────┘ │ ┌────┤ FApplication │
|
||||||
: : *┌────────┐ │ │ └──────────────┘
|
: : *┌────────┐ │ │ └──────────────┘
|
||||||
: ┌--------┤ FPoint │ │ │ ┌────────┐
|
: ┌--------┤ FPoint │ │ │ ┌────────┐
|
||||||
: : └────────┘ │ ├────┤ FLabel │
|
: : └────────┘ │ ├────┤ FLabel │
|
||||||
|
@ -209,15 +215,16 @@ printf(...)
|
||||||
│ ┌───────────┐1 1┌──────────────────┐
|
│ ┌───────────┐1 1┌──────────────────┐
|
||||||
├────┤ FComboBox ├------┤ FDropDownListBox │
|
├────┤ FComboBox ├------┤ FDropDownListBox │
|
||||||
│ └───────────┘ └──────────────────┘
|
│ └───────────┘ └──────────────────┘
|
||||||
┌─────────────┐1 │ ┌──────────┐1 *┌──────────────┐
|
┌─────────────┐1 │ ┌──────────┐1 *┌──────────────┐1
|
||||||
│ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem │
|
│ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem ├--┐
|
||||||
└─────────────┘ │ └──────────┘ └──────────────┘
|
└─────────────┘ │ └──────────┘ └──────────────┘ :
|
||||||
│ 1┌───────────┐1 *┌───────────────┐
|
│ 1┌───────────┐1 *┌───────────────┐ :
|
||||||
├────┤ FListView ├------┤ FListViewItem │
|
├────┤ FListView ├------┤ FListViewItem │ :
|
||||||
│ └───────────┘ └───────────────┘
|
│ └───────────┘ └────────┬──────┘ :
|
||||||
│ ┌─────────────┐
|
│ ┌─────────────┐ :1 :
|
||||||
├────┤ FScrollView │
|
├────┤ FScrollView │ ┌───┴───┐1 :
|
||||||
│ └─────────────┘
|
│ └─────────────┘ │ FData ├----┘
|
||||||
|
│ └───────┘
|
||||||
│ ┌────────────┐1 *┌────────────┐
|
│ ┌────────────┐1 *┌────────────┐
|
||||||
│ ┌──┤ FStatusBar ├-----┤ FStatusKey │
|
│ ┌──┤ FStatusBar ├-----┤ FStatusKey │
|
||||||
│ │ └────────────┘ └────────────┘
|
│ │ └────────────┘ └────────────┘
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
══════════════════════════════════════════════════════════════════════════════
|
══════════════════════════════════════════════════════════════════════════════
|
||||||
Class digramm
|
Class digramm
|
||||||
══════════════════════════════════════════════════════════════════════════════
|
══════════════════════════════════════════════════════════════════════════════
|
||||||
1┌──────────────┐
|
1┌────────────┐
|
||||||
|
┌-----------┤ FTermLinux │
|
||||||
|
: └────────────┘
|
||||||
|
: 1┌──────────────┐
|
||||||
┌-----------┤ FTermFreeBSD │
|
┌-----------┤ FTermFreeBSD │
|
||||||
: └──────────────┘
|
: └──────────────┘
|
||||||
: 1┌──────────────┐
|
: 1┌──────────────┐
|
||||||
|
@ -37,12 +40,15 @@
|
||||||
: 1┌───────────────┐ │ ┌─────────────┐
|
: 1┌───────────────┐ │ ┌─────────────┐
|
||||||
┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
|
┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
|
||||||
: └───────────────┘ │ └─────────────┘
|
: └───────────────┘ │ └─────────────┘
|
||||||
: 1┌─────────┐ │ ┌──────┐ ┌─────────┐
|
: 1┌─────────┐ │ ┌────────────┐1 1┌───────┐
|
||||||
┌-----------┤ FSystem │ │ │ FLog │◄──┤ FLogger │
|
┌-----------┤ FSystem │ ├────┤ FUserEvent ├------┤ FData │
|
||||||
: └─────────┘ │ └──┬───┘ └─────────┘
|
: └─────────┘ │ └────────────┘ └───────┘
|
||||||
: *┌─────────┐ │ :1
|
: *┌─────────┐ │ ┌──────┐ ┌─────────┐
|
||||||
: ┌--------┤ FString │ │ ┌──┴───────────┐
|
: ┌--------┤ FString │ │ │ FLog │◄──┤ FLogger │
|
||||||
: : └─────────┘ │ ┌────┤ FApplication │
|
: : └─────────┘ │ └──┬───┘ └─────────┘
|
||||||
|
: : *┌───────────────┐ │ :1
|
||||||
|
: ┌--------┤ FStringStream │ │ ┌──┴───────────┐
|
||||||
|
: : └───────────────┘ │ ┌────┤ FApplication │
|
||||||
: : *┌────────┐ │ │ └──────────────┘
|
: : *┌────────┐ │ │ └──────────────┘
|
||||||
: ┌--------┤ FPoint │ │ │ ┌────────┐
|
: ┌--------┤ FPoint │ │ │ ┌────────┐
|
||||||
: : └────────┘ │ ├────┤ FLabel │
|
: : └────────┘ │ ├────┤ FLabel │
|
||||||
|
@ -74,15 +80,16 @@
|
||||||
│ ┌───────────┐1 1┌──────────────────┐
|
│ ┌───────────┐1 1┌──────────────────┐
|
||||||
├────┤ FComboBox ├------┤ FDropDownListBox │
|
├────┤ FComboBox ├------┤ FDropDownListBox │
|
||||||
│ └───────────┘ └──────────────────┘
|
│ └───────────┘ └──────────────────┘
|
||||||
┌─────────────┐1 │ ┌──────────┐1 *┌──────────────┐
|
┌─────────────┐1 │ ┌──────────┐1 *┌──────────────┐1
|
||||||
│ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem │
|
│ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem ├--┐
|
||||||
└─────────────┘ │ └──────────┘ └──────────────┘
|
└─────────────┘ │ └──────────┘ └──────────────┘ :
|
||||||
│ 1┌───────────┐1 *┌───────────────┐
|
│ 1┌───────────┐1 *┌───────────────┐ :
|
||||||
├────┤ FListView ├------┤ FListViewItem │
|
├────┤ FListView ├------┤ FListViewItem │ :
|
||||||
│ └───────────┘ └───────────────┘
|
│ └───────────┘ └────────┬──────┘ :
|
||||||
│ ┌─────────────┐
|
│ ┌─────────────┐ :1 :
|
||||||
├────┤ FScrollView │
|
├────┤ FScrollView │ ┌───┴───┐1 :
|
||||||
│ └─────────────┘
|
│ └─────────────┘ │ FData ├----┘
|
||||||
|
│ └───────┘
|
||||||
│ ┌────────────┐1 *┌────────────┐
|
│ ┌────────────┐1 *┌────────────┐
|
||||||
│ ┌──┤ FStatusBar ├-----┤ FStatusKey │
|
│ ┌──┤ FStatusBar ├-----┤ FStatusKey │
|
||||||
│ │ └────────────┘ └────────────┘
|
│ │ └────────────┘ └────────────┘
|
||||||
|
|
|
@ -85,6 +85,7 @@ You need three things:
|
||||||
* autoconf
|
* autoconf
|
||||||
* autoconf-archive
|
* autoconf-archive
|
||||||
* libtool
|
* libtool
|
||||||
|
* pkg-config
|
||||||
|
|
||||||
3. Development packages for following libraries:
|
3. Development packages for following libraries:
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,324 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
height="65.484894mm"
|
||||||
|
viewBox="0 0 149.86537 65.484895"
|
||||||
|
width="149.86537mm"
|
||||||
|
version="1.1"
|
||||||
|
id="svg109">
|
||||||
|
<metadata
|
||||||
|
id="metadata115">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs113" />
|
||||||
|
<marker
|
||||||
|
id="a"
|
||||||
|
orient="auto"
|
||||||
|
overflow="visible"
|
||||||
|
refX="0"
|
||||||
|
refY="0">
|
||||||
|
<path
|
||||||
|
d="m0 0 5-5-17.5 5 17.5 5z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#000"
|
||||||
|
stroke-width="1pt"
|
||||||
|
transform="matrix(-.4 0 0 -.4 -4 0)"
|
||||||
|
id="path2" />
|
||||||
|
</marker>
|
||||||
|
<marker
|
||||||
|
id="b"
|
||||||
|
orient="auto"
|
||||||
|
overflow="visible"
|
||||||
|
refX="0"
|
||||||
|
refY="0">
|
||||||
|
<path
|
||||||
|
d="m0 0 5-5-17.5 5 17.5 5z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#000"
|
||||||
|
stroke-width="1pt"
|
||||||
|
transform="matrix(-.4 0 0 -.4 -4 0)"
|
||||||
|
id="path5" />
|
||||||
|
</marker>
|
||||||
|
<marker
|
||||||
|
id="c"
|
||||||
|
orient="auto"
|
||||||
|
overflow="visible"
|
||||||
|
refX="0"
|
||||||
|
refY="0">
|
||||||
|
<path
|
||||||
|
d="m0 0 5-5-17.5 5 17.5 5z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#000"
|
||||||
|
stroke-width="1pt"
|
||||||
|
transform="matrix(-.4 0 0 -.4 -4 0)"
|
||||||
|
id="path8" />
|
||||||
|
</marker>
|
||||||
|
<marker
|
||||||
|
id="d"
|
||||||
|
orient="auto"
|
||||||
|
overflow="visible"
|
||||||
|
refX="0"
|
||||||
|
refY="0">
|
||||||
|
<path
|
||||||
|
d="m0 0 5-5-17.5 5 17.5 5z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#000"
|
||||||
|
stroke-width="1pt"
|
||||||
|
transform="matrix(-.4 0 0 -.4 -4 0)"
|
||||||
|
id="path11" />
|
||||||
|
</marker>
|
||||||
|
<marker
|
||||||
|
id="e"
|
||||||
|
orient="auto"
|
||||||
|
overflow="visible"
|
||||||
|
refX="0"
|
||||||
|
refY="0">
|
||||||
|
<path
|
||||||
|
d="m0 0 5-5-17.5 5 17.5 5z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#000"
|
||||||
|
stroke-width="1pt"
|
||||||
|
transform="matrix(-.4 0 0 -.4 -4 0)"
|
||||||
|
id="path14" />
|
||||||
|
</marker>
|
||||||
|
<g
|
||||||
|
style="stroke-width:1.20796704"
|
||||||
|
id="g57">
|
||||||
|
<g
|
||||||
|
transform="matrix(0.82806766,0,0,0.82760652,18.811674,-210.24741)"
|
||||||
|
id="g23">
|
||||||
|
<path
|
||||||
|
style="fill:#f9f9f9;stroke:#000000;stroke-width:0.51105303;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="m 7.868146,254.29825 h 57.783382 v 10.66144 H 7.868146 Z"
|
||||||
|
id="path17" />
|
||||||
|
<text
|
||||||
|
style="font-weight:bold;font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;letter-spacing:0;word-spacing:0;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097;stroke-opacity:0"
|
||||||
|
x="37.113487"
|
||||||
|
y="261.55215"
|
||||||
|
id="text21">
|
||||||
|
<tspan
|
||||||
|
style="stroke-width:0.51097"
|
||||||
|
x="37.113487"
|
||||||
|
y="261.55215"
|
||||||
|
id="tspan19">FApplication</tspan>
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="matrix(0.82806766,0,0,0.82760652,25.151866,-0.203308)"
|
||||||
|
id="g31">
|
||||||
|
<path
|
||||||
|
style="fill:#f9f9f9;stroke:#000000;stroke-width:0.51105303;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="M 15.875,19.022009 H 42.333334 V 29.683451 H 15.875 Z"
|
||||||
|
id="path25" />
|
||||||
|
<text
|
||||||
|
style="font-weight:bold;font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;letter-spacing:0;word-spacing:0;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097;stroke-opacity:0"
|
||||||
|
x="29.24534"
|
||||||
|
y="26.275915"
|
||||||
|
id="text29">
|
||||||
|
<tspan
|
||||||
|
style="stroke-width:0.51097"
|
||||||
|
x="29.24534"
|
||||||
|
y="26.275915"
|
||||||
|
id="tspan27">FDialog</tspan>
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="matrix(0.82806766,0,0,0.82760652,38.120716,15.124655)"
|
||||||
|
id="g39">
|
||||||
|
<path
|
||||||
|
style="fill:#f9f9f9;stroke:#000000;stroke-width:0.51105303;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="M 15.875,19.022009 H 42.333334 V 29.683451 H 15.875 Z"
|
||||||
|
id="path33" />
|
||||||
|
<text
|
||||||
|
style="font-weight:bold;font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;letter-spacing:0;word-spacing:0;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097;stroke-opacity:0"
|
||||||
|
x="29.24534"
|
||||||
|
y="26.275915"
|
||||||
|
id="text37">
|
||||||
|
<tspan
|
||||||
|
style="stroke-width:0.51097"
|
||||||
|
x="29.24534"
|
||||||
|
y="26.275915"
|
||||||
|
id="tspan35">FDialog</tspan>
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="matrix(0.82806766,0,0,0.82760652,12.006292,15.124655)"
|
||||||
|
id="g47">
|
||||||
|
<path
|
||||||
|
style="fill:#f9f9f9;stroke:#000000;stroke-width:0.51105303;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="M 15.875,19.022009 H 42.333334 V 29.683451 H 15.875 Z"
|
||||||
|
id="path41" />
|
||||||
|
<text
|
||||||
|
style="font-weight:bold;font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;letter-spacing:0;word-spacing:0;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097;stroke-opacity:0"
|
||||||
|
x="29.24534"
|
||||||
|
y="26.275915"
|
||||||
|
id="text45">
|
||||||
|
<tspan
|
||||||
|
style="stroke-width:0.51097"
|
||||||
|
x="29.24534"
|
||||||
|
y="26.275915"
|
||||||
|
id="tspan43">FLabel</tspan>
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="matrix(0.82806766,0,0,0.82760652,25.151866,-0.203308)"
|
||||||
|
id="g55">
|
||||||
|
<path
|
||||||
|
style="fill:#f9f9f9;stroke:#000000;stroke-width:0.51105303;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="M 31.75,56.063679 H 58.208334 V 66.725121 H 31.75 Z"
|
||||||
|
id="path49" />
|
||||||
|
<text
|
||||||
|
style="font-weight:bold;font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;letter-spacing:0;word-spacing:0;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097;stroke-opacity:0"
|
||||||
|
x="45.120338"
|
||||||
|
y="63.317585"
|
||||||
|
id="text53">
|
||||||
|
<tspan
|
||||||
|
style="stroke-width:0.51097"
|
||||||
|
x="45.120338"
|
||||||
|
y="63.317585"
|
||||||
|
id="tspan51">FListBox</tspan>
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<text
|
||||||
|
style="font-style:italic;font-weight:bold;font-size:4.08859491px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;letter-spacing:0;word-spacing:0;text-anchor:middle;fill:#1a1a1a;stroke-width:0.42300001;stroke-opacity:0"
|
||||||
|
transform="scale(1.0002786,0.99972148)"
|
||||||
|
x="62.287796"
|
||||||
|
y="65.409096"
|
||||||
|
id="text61">
|
||||||
|
<tspan
|
||||||
|
x="62.287796"
|
||||||
|
y="65.409096"
|
||||||
|
id="tspan59">etc.</tspan>
|
||||||
|
</text>
|
||||||
|
<path
|
||||||
|
d="m49.251306 9.2100164v5.7870836"
|
||||||
|
fill="none"
|
||||||
|
marker-end="url(#a)"
|
||||||
|
stroke="#000"
|
||||||
|
stroke-width=".423069"
|
||||||
|
id="path63" />
|
||||||
|
<path
|
||||||
|
d="m42.679299 24.537976v5.779196"
|
||||||
|
fill="none"
|
||||||
|
marker-end="url(#b)"
|
||||||
|
stroke="#000"
|
||||||
|
stroke-width=".423069"
|
||||||
|
id="path65" />
|
||||||
|
<path
|
||||||
|
d="m55.736511 24.537898v5.779196"
|
||||||
|
fill="none"
|
||||||
|
marker-end="url(#c)"
|
||||||
|
stroke="#000"
|
||||||
|
stroke-width=".423069"
|
||||||
|
id="path67" />
|
||||||
|
<path
|
||||||
|
d="m62.369882 39.865938v5.548839"
|
||||||
|
fill="none"
|
||||||
|
marker-end="url(#d)"
|
||||||
|
stroke="#000"
|
||||||
|
stroke-width=".423069"
|
||||||
|
id="path69" />
|
||||||
|
<path
|
||||||
|
d="m62.369882 55.193909v5.548839"
|
||||||
|
fill="none"
|
||||||
|
marker-end="url(#e)"
|
||||||
|
stroke="#000"
|
||||||
|
stroke-width=".423069"
|
||||||
|
id="path71" />
|
||||||
|
<g
|
||||||
|
style="font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;letter-spacing:0;word-spacing:0;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097;stroke-opacity:0"
|
||||||
|
transform="matrix(0.82806766,0,0,0.82760652,25.151866,-0.203308)"
|
||||||
|
id="g89">
|
||||||
|
<text
|
||||||
|
x="-23.01368"
|
||||||
|
y="8.7182531"
|
||||||
|
id="text75">
|
||||||
|
<tspan
|
||||||
|
x="-23.01368"
|
||||||
|
y="8.7182531"
|
||||||
|
id="tspan73">Parent:</tspan>
|
||||||
|
</text>
|
||||||
|
<text
|
||||||
|
x="-24.412582"
|
||||||
|
y="27.239086"
|
||||||
|
id="text79">
|
||||||
|
<tspan
|
||||||
|
x="-24.412582"
|
||||||
|
y="27.239086"
|
||||||
|
id="tspan77">Child:</tspan>
|
||||||
|
</text>
|
||||||
|
<text
|
||||||
|
x="-20.59841"
|
||||||
|
y="44.796837"
|
||||||
|
id="text83">
|
||||||
|
<tspan
|
||||||
|
x="-20.59841"
|
||||||
|
y="44.796837"
|
||||||
|
id="tspan81">Subchild:</tspan>
|
||||||
|
</text>
|
||||||
|
<text
|
||||||
|
x="-15.852447"
|
||||||
|
y="63.317669"
|
||||||
|
id="text87">
|
||||||
|
<tspan
|
||||||
|
x="-15.852447"
|
||||||
|
y="63.317669"
|
||||||
|
id="tspan85">Sub-subchild:</tspan>
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
style="font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;letter-spacing:0;word-spacing:0;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097;stroke-opacity:0"
|
||||||
|
transform="matrix(0.82806766,0,0,0.82760652,107.7173,-0.203308)"
|
||||||
|
id="g107">
|
||||||
|
<text
|
||||||
|
x="-5.0208001"
|
||||||
|
y="8.7182531"
|
||||||
|
id="text93">
|
||||||
|
<tspan
|
||||||
|
x="-5.0208001"
|
||||||
|
y="8.7182531"
|
||||||
|
id="tspan91">Application widget (= 1)</tspan>
|
||||||
|
</text>
|
||||||
|
<text
|
||||||
|
x="-12.021867"
|
||||||
|
y="27.239086"
|
||||||
|
id="text97">
|
||||||
|
<tspan
|
||||||
|
x="-12.021868"
|
||||||
|
y="27.239086"
|
||||||
|
id="tspan95">Main widget (= 1)</tspan>
|
||||||
|
</text>
|
||||||
|
<text
|
||||||
|
x="5.9180651"
|
||||||
|
y="44.796837"
|
||||||
|
id="text101">
|
||||||
|
<tspan
|
||||||
|
x="5.918066"
|
||||||
|
y="44.796837"
|
||||||
|
id="tspan99">Widget(s) of the main widget (≥ 0)</tspan>
|
||||||
|
</text>
|
||||||
|
<text
|
||||||
|
x="10.413227"
|
||||||
|
y="63.317669"
|
||||||
|
id="text105">
|
||||||
|
<tspan
|
||||||
|
x="10.413226"
|
||||||
|
y="63.317669"
|
||||||
|
id="tspan103">Widget(s) from the parent widget (≥ 0)</tspan>
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 9.5 KiB |
|
@ -7,6 +7,8 @@ Table of Contents
|
||||||
|
|
||||||
<!-- TOC -->
|
<!-- TOC -->
|
||||||
- [Basic functions](#basic-functions)
|
- [Basic functions](#basic-functions)
|
||||||
|
- [Widgets](#widgets)
|
||||||
|
- [Widget tree](#widget-tree)
|
||||||
- [How to use the library](#how-to-use-the-library)
|
- [How to use the library](#how-to-use-the-library)
|
||||||
- [Memory Management](#memory-management)
|
- [Memory Management](#memory-management)
|
||||||
- [Event Processing](#event-processing)
|
- [Event Processing](#event-processing)
|
||||||
|
@ -55,6 +57,49 @@ emulator. It uses various optimization methods to improve the drawing speed.
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
|
|
||||||
|
Widgets
|
||||||
|
-------
|
||||||
|
|
||||||
|
FINAL CUT has many widgets. It offers buttons, input fields, menus, and
|
||||||
|
dialog boxes that cover the most common use cases. Widgets are visual
|
||||||
|
elements that are combined to create user interfaces. Own widgets can be
|
||||||
|
easily created by creating a derived class of `FWidget` or other existing
|
||||||
|
widgets. All widgets are instances of
|
||||||
|
[FWidget](https://codedocs.xyz/gansm/finalcut/classfinalcut_1_1FWidget.html)
|
||||||
|
or its subclasses.
|
||||||
|
|
||||||
|
A widget can contain any number of child widgets. Child widgets are displayed
|
||||||
|
in the display area of the parent widget. Window widgets based on `FWindow`
|
||||||
|
have their own virtual display area and are independent of the parent widget.
|
||||||
|
|
||||||
|
When a parent widget is disabled, hidden, or deleted, the same operation is
|
||||||
|
used recursively to all its child widgets. The base class `FObject` implements
|
||||||
|
the self-organized object tree behavior. For example, `addChild()` removes
|
||||||
|
the child ownership from an existing parent object before assigning it to
|
||||||
|
the new target. When a child becomes deleted, the parent-child relationship
|
||||||
|
causes its reference in the parent object to be removed. An explicit
|
||||||
|
`delChild()` is no longer required here.
|
||||||
|
|
||||||
|
|
||||||
|
Widget tree
|
||||||
|
-----------
|
||||||
|
|
||||||
|
An `FApplication` widget is the top-level widget of an application. It is
|
||||||
|
unique and can not have a parent widget. The class `FApplication` manages
|
||||||
|
all settings and assigns keyboard and mouse input to the different widgets.
|
||||||
|
|
||||||
|
<figure class="image">
|
||||||
|
<img src="final-cut-widget tree.svg" alt="widget tree">
|
||||||
|
<figcaption>Figure 2. Widget tree of a FINAL CUT application</figcaption>
|
||||||
|
</figure>
|
||||||
|
<br /><br />
|
||||||
|
|
||||||
|
The main widget of a FINAL CUT application is the only object that
|
||||||
|
`FApplication` can have as a child. This main widget is usually a window
|
||||||
|
object that contains all sub-widgets of the application. A sub-widget can
|
||||||
|
also be another window.
|
||||||
|
|
||||||
|
|
||||||
How to use the library
|
How to use the library
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
@ -82,7 +127,7 @@ int main (int argc, char* argv[])
|
||||||
```
|
```
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="first-steps_dialog.cpp.png" alt="dialog.cpp">
|
<img src="first-steps_dialog.cpp.png" alt="dialog.cpp">
|
||||||
<figcaption>Figure 2. A blank dialog</figcaption>
|
<figcaption>Figure 3. A blank dialog</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -92,8 +137,8 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
After entering the source code in *dialog.cpp* you can compile
|
After entering the source code in *dialog.cpp* you can compile
|
||||||
the above program with gcc:
|
the above program with gcc:
|
||||||
```cpp
|
```bash
|
||||||
g++ -O2 -lfinal dialog.cpp -o dialog
|
g++ dialog.cpp -o dialog -O2 -lfinal
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -229,7 +274,7 @@ int main (int argc, char* argv[])
|
||||||
```
|
```
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="first-steps_memory.cpp.png" alt="memory.cpp">
|
<img src="first-steps_memory.cpp.png" alt="memory.cpp">
|
||||||
<figcaption>Figure 3. FObject manages its child objects</figcaption>
|
<figcaption>Figure 4. FObject manages its child objects</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -239,8 +284,8 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
After entering the source code in *memory.cpp* you can compile
|
After entering the source code in *memory.cpp* you can compile
|
||||||
the above program with gcc:
|
the above program with gcc:
|
||||||
```cpp
|
```bash
|
||||||
g++ -O2 -lfinal memory.cpp -o memory
|
g++ memory.cpp -o memory -O2 -lfinal
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -369,7 +414,7 @@ int main (int argc, char* argv[])
|
||||||
```
|
```
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="first-steps_timer.cpp.png" alt="timer.cpp">
|
<img src="first-steps_timer.cpp.png" alt="timer.cpp">
|
||||||
<figcaption>Figure 4. FObject::onTimer event handler</figcaption>
|
<figcaption>Figure 5. FObject::onTimer event handler</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -379,8 +424,8 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
After entering the source code in *timer.cpp* you can compile
|
After entering the source code in *timer.cpp* you can compile
|
||||||
the above program with gcc:
|
the above program with gcc:
|
||||||
```cpp
|
```bash
|
||||||
g++ -O2 -lfinal -std=c++11 timer.cpp -o timer
|
g++ timer.cpp -o timer -O2 -lfinal -std=c++11
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -431,7 +476,7 @@ class extendedApplication : public FApplication
|
||||||
|| last_avg[2] != load_avg[2] )
|
|| last_avg[2] != load_avg[2] )
|
||||||
{
|
{
|
||||||
FUserEvent user_event(fc::User_Event, 0);
|
FUserEvent user_event(fc::User_Event, 0);
|
||||||
user_event.setData (FDataPtr(&load_avg));
|
user_event.setData (load_avg);
|
||||||
FApplication::sendEvent (getMainWidget(), &user_event);
|
FApplication::sendEvent (getMainWidget(), &user_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,8 +503,7 @@ class dialogWidget final : public FDialog
|
||||||
private:
|
private:
|
||||||
void onUserEvent (FUserEvent* ev) override
|
void onUserEvent (FUserEvent* ev) override
|
||||||
{
|
{
|
||||||
FDataPtr dataPtr = ev->getData();
|
const auto& lavg = ev->getData<LoadAvg>();
|
||||||
auto& lavg = *(reinterpret_cast<LoadAvg*>(dataPtr));
|
|
||||||
std::setlocale(LC_NUMERIC, "C");
|
std::setlocale(LC_NUMERIC, "C");
|
||||||
loadavg_label.clear();
|
loadavg_label.clear();
|
||||||
loadavg_label << "Load average: " << lavg[0] << ", "
|
loadavg_label << "Load average: " << lavg[0] << ", "
|
||||||
|
@ -483,7 +527,7 @@ int main (int argc, char* argv[])
|
||||||
```
|
```
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="first-steps_user-event.cpp.png" alt="user-event.cpp">
|
<img src="first-steps_user-event.cpp.png" alt="user-event.cpp">
|
||||||
<figcaption>Figure 5. User event generation</figcaption>
|
<figcaption>Figure 6. User event generation</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -493,8 +537,8 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
After entering the source code in *user-event.cpp* you can compile
|
After entering the source code in *user-event.cpp* you can compile
|
||||||
the above program with gcc:
|
the above program with gcc:
|
||||||
```cpp
|
```bash
|
||||||
g++ -O2 -lfinal -std=c++11 user-event.cpp -o user-event
|
g++ user-event.cpp -o user-event -O2 -lfinal -std=c++11
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -530,9 +574,9 @@ to other widget objects.
|
||||||
1. For calling functions or static methods via a pointer:
|
1. For calling functions or static methods via a pointer:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Function
|
template< typename Function
|
||||||
, typename FunctionPointer<Function>::type = nullptr
|
, typename FunctionPointer<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args)
|
, Args&&... args)
|
||||||
|
@ -542,9 +586,9 @@ void FWidget::addCallback ( const FString& cb_signal
|
||||||
2. For calling functions or static methods via a reference:
|
2. For calling functions or static methods via a reference:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Function
|
template< typename Function
|
||||||
, typename FunctionReference<Function>::type = nullptr
|
, typename FunctionReference<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Function& cb_function
|
, Function& cb_function
|
||||||
, Args&&... args)
|
, Args&&... args)
|
||||||
|
@ -554,11 +598,11 @@ void FWidget::addCallback ( const FString& cb_signal
|
||||||
3. For calling a member method of a specific instance:
|
3. For calling a member method of a specific instance:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Object
|
template< typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename ObjectPointer<Object>::type = nullptr
|
, typename ObjectPointer<Object>::type = nullptr
|
||||||
, typename MemberFunctionPointer<Function>::type = nullptr
|
, typename MemberFunctionPointer<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance
|
, Object&& cb_instance
|
||||||
, Function&& cb_member
|
, Function&& cb_member
|
||||||
|
@ -568,9 +612,9 @@ void FWidget::addCallback ( const FString& cb_signal
|
||||||
|
|
||||||
4. For calling a std::bind call wrapper or a lambda expression:
|
4. For calling a std::bind call wrapper or a lambda expression:
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Function
|
template< typename Function
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args)
|
, Args&&... args)
|
||||||
|
@ -580,11 +624,11 @@ void FWidget::addCallback ( const FString& cb_signal
|
||||||
5. For calling a std::bind call wrapper to a specific instance:
|
5. For calling a std::bind call wrapper to a specific instance:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Object
|
template< typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename ObjectPointer<Object>::type = nullptr
|
, typename ObjectPointer<Object>::type = nullptr
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance
|
, Object&& cb_instance
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
|
@ -596,9 +640,9 @@ void FWidget::addCallback ( const FString& cb_signal
|
||||||
with the keyword auto:
|
with the keyword auto:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Function
|
template< typename Function
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Function& cb_function
|
, Function& cb_function
|
||||||
, Args&&... args)
|
, Args&&... args)
|
||||||
|
@ -612,8 +656,8 @@ remove all existing callbacks from an object.
|
||||||
1. To delete functions or static methods callbacks via a pointer:
|
1. To delete functions or static methods callbacks via a pointer:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename FunctionPtr
|
template< typename FunctionPtr
|
||||||
, typename FunctionPointer<FunctionPtr>::type = nullptr>
|
, typename FunctionPointer<FunctionPtr>::type = nullptr >
|
||||||
void FWidget::delCallback (FunctionPtr&& cb_func_ptr)
|
void FWidget::delCallback (FunctionPtr&& cb_func_ptr)
|
||||||
{...}
|
{...}
|
||||||
```
|
```
|
||||||
|
@ -621,8 +665,8 @@ void FWidget::delCallback (FunctionPtr&& cb_func_ptr)
|
||||||
2. To delete functions or static methods callbacks via a reference:
|
2. To delete functions or static methods callbacks via a reference:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Function
|
template< typename Function
|
||||||
, typename FunctionReference<Function>::type = nullptr>
|
, typename FunctionReference<Function>::type = nullptr >
|
||||||
void FWidget::delCallback (Function& cb_function)
|
void FWidget::delCallback (Function& cb_function)
|
||||||
{...}
|
{...}
|
||||||
```
|
```
|
||||||
|
@ -630,8 +674,8 @@ void FWidget::delCallback (Function& cb_function)
|
||||||
3. To delete all callbacks from a specific instance:
|
3. To delete all callbacks from a specific instance:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Object
|
template< typename Object
|
||||||
, typename ObjectPointer<Object>::type = nullptr>
|
, typename ObjectPointer<Object>::type = nullptr >
|
||||||
void FWidget::delCallback (Object&& cb_instance)
|
void FWidget::delCallback (Object&& cb_instance)
|
||||||
{...}
|
{...}
|
||||||
```
|
```
|
||||||
|
@ -646,8 +690,8 @@ void delCallback (const FString& cb_signal)
|
||||||
5. To delete all callbacks of a signal and specific instance:
|
5. To delete all callbacks of a signal and specific instance:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Object
|
template< typename Object
|
||||||
, typename ObjectPointer<Object>::type = nullptr>
|
, typename ObjectPointer<Object>::type = nullptr >
|
||||||
void delCallback (const FString& cb_signal, Object&& cb_instance)
|
void delCallback (const FString& cb_signal, Object&& cb_instance)
|
||||||
{...}
|
{...}
|
||||||
```
|
```
|
||||||
|
@ -754,7 +798,7 @@ int main (int argc, char* argv[])
|
||||||
```
|
```
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="first-steps_callback-function.cpp.png" alt="callback-function.cpp">
|
<img src="first-steps_callback-function.cpp.png" alt="callback-function.cpp">
|
||||||
<figcaption>Figure 6. Button with a callback function</figcaption>
|
<figcaption>Figure 7. Button with a callback function</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -764,8 +808,8 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
After entering the source code in *callback-function.cpp* you can compile
|
After entering the source code in *callback-function.cpp* you can compile
|
||||||
the above program with gcc:
|
the above program with gcc:
|
||||||
```cpp
|
```bash
|
||||||
g++ -O2 -lfinal callback-function.cpp -o callback-function
|
g++ callback-function.cpp -o callback-function -O2 -lfinal
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -817,7 +861,7 @@ int main (int argc, char* argv[])
|
||||||
```
|
```
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="first-steps_callback-lambda.cpp.png" alt="callback-lambda.cpp">
|
<img src="first-steps_callback-lambda.cpp.png" alt="callback-lambda.cpp">
|
||||||
<figcaption>Figure 7. Button with lambda expression callback.</figcaption>
|
<figcaption>Figure 8. Button with lambda expression callback.</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -827,8 +871,8 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
After entering the source code in *callback-lambda.cpp* you can compile
|
After entering the source code in *callback-lambda.cpp* you can compile
|
||||||
the above program with gcc:
|
the above program with gcc:
|
||||||
```cpp
|
```bash
|
||||||
g++ -O2 -lfinal -std=c++11 callback-lambda.cpp -o callback-lambda
|
g++ callback-lambda.cpp -o callback-lambda -O2 -lfinal -std=c++11
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -876,7 +920,7 @@ int main (int argc, char* argv[])
|
||||||
```
|
```
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="first-steps_callback-method.cpp.png" alt="callback-method.cpp">
|
<img src="first-steps_callback-method.cpp.png" alt="callback-method.cpp">
|
||||||
<figcaption>Figure 8. Button with a callback method</figcaption>
|
<figcaption>Figure 9. Button with a callback method</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -886,8 +930,8 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
After entering the source code in *callback-method.cpp* you can compile
|
After entering the source code in *callback-method.cpp* you can compile
|
||||||
the above program with gcc:
|
the above program with gcc:
|
||||||
```cpp
|
```bash
|
||||||
g++ -O2 -lfinal -std=c++11 callback-method.cpp -o callback-method
|
g++ callback-method.cpp -o callback-method -O2 -lfinal -std=c++11
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -997,7 +1041,7 @@ int main (int argc, char* argv[])
|
||||||
```
|
```
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="first-steps_emit-signal.cpp.png" alt="emit-signal.cpp">
|
<img src="first-steps_emit-signal.cpp.png" alt="emit-signal.cpp">
|
||||||
<figcaption>Figure 9. Callbacks with custom signals</figcaption>
|
<figcaption>Figure 10. Callbacks with custom signals</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -1007,8 +1051,8 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
After entering the source code in *emit-signal.cpp* you can compile
|
After entering the source code in *emit-signal.cpp* you can compile
|
||||||
the above program with gcc:
|
the above program with gcc:
|
||||||
```cpp
|
```bash
|
||||||
g++ -O2 -lfinal -std=c++11 emit-signal.cpp -o emit-signal
|
g++ emit-signal.cpp -o emit-signal -O2 -lfinal -std=c++11
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -1038,7 +1082,7 @@ If you want to ignore padding spaces, you must force this with the
|
||||||
|
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="widget-coordinates.svg" alt="widget coordinates">
|
<img src="widget-coordinates.svg" alt="widget coordinates">
|
||||||
<figcaption>Figure 10. Widget coordinates</figcaption>
|
<figcaption>Figure 11. Widget coordinates</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -1088,7 +1132,7 @@ methods.
|
||||||
|
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="widget-lengths.svg" alt="widget lengths">
|
<img src="widget-lengths.svg" alt="widget lengths">
|
||||||
<figcaption>Figure 11. Width and height of a widget</figcaption>
|
<figcaption>Figure 12. Width and height of a widget</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -1141,7 +1185,7 @@ absolute geometry values as a `FRect` object, you can call the method
|
||||||
|
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="widget-geometry.svg" alt="widget geometry">
|
<img src="widget-geometry.svg" alt="widget geometry">
|
||||||
<figcaption>Figure 12. Geometry of widgets</figcaption>
|
<figcaption>Figure 13. Geometry of widgets</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -1237,19 +1281,12 @@ class dialogWidget : public FDialog
|
||||||
FDialog::adjustSize();
|
FDialog::adjustSize();
|
||||||
// Centers the dialog in the terminal
|
// Centers the dialog in the terminal
|
||||||
centerDialog();
|
centerDialog();
|
||||||
}
|
// Adjust widgets before drawing
|
||||||
|
adjustWidgets();
|
||||||
void setSize (const FSize& size, bool) override
|
|
||||||
{
|
|
||||||
// Calling super class methods setSize() + adjustSize()
|
|
||||||
FDialog::setSize (size, false);
|
|
||||||
FDialog::adjustSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw() override
|
void draw() override
|
||||||
{
|
{
|
||||||
adjustWidgets(); // Adjust widgets before drawing
|
|
||||||
|
|
||||||
// Calling super class method draw()
|
// Calling super class method draw()
|
||||||
FDialog::draw();
|
FDialog::draw();
|
||||||
|
|
||||||
|
@ -1275,7 +1312,7 @@ int main (int argc, char* argv[])
|
||||||
```
|
```
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="first-steps_size-adjustment.cpp.png" alt="size-adjustment.cpp">
|
<img src="first-steps_size-adjustment.cpp.png" alt="size-adjustment.cpp">
|
||||||
<figcaption>Figure 13. Dynamic layout</figcaption>
|
<figcaption>Figure 14. Dynamic layout</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -1285,8 +1322,8 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
After entering the source code in *size-adjustment.cpp* you can compile
|
After entering the source code in *size-adjustment.cpp* you can compile
|
||||||
the above program with gcc:
|
the above program with gcc:
|
||||||
```cpp
|
```bash
|
||||||
g++ -O2 -lfinal -std=c++11 size-adjustment.cpp -o size-adjustment
|
g++ size-adjustment.cpp -o size-adjustment -O2 -lfinal -std=c++11
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -1403,7 +1440,7 @@ int main (int argc, char* argv[])
|
||||||
```
|
```
|
||||||
<figure class="image">
|
<figure class="image">
|
||||||
<img src="first-steps_scrollview.cpp.png" alt="scrollview.cpp">
|
<img src="first-steps_scrollview.cpp.png" alt="scrollview.cpp">
|
||||||
<figcaption>Figure 14. Dialog with a scrolling viewport</figcaption>
|
<figcaption>Figure 15. Dialog with a scrolling viewport</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
@ -1413,6 +1450,6 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
After entering the source code in *scrollview.cpp* you can compile
|
After entering the source code in *scrollview.cpp* you can compile
|
||||||
the above program with gcc:
|
the above program with gcc:
|
||||||
```cpp
|
```bash
|
||||||
g++ -O2 -lfinal -std=c++11 scrollview.cpp -o scrollview
|
g++ scrollview.cpp -o scrollview -O2 -lfinal -std=c++11
|
||||||
```
|
```
|
||||||
|
|
|
@ -27,7 +27,7 @@ class myWidgetColors final : public finalcut::FWidgetColors
|
||||||
~myWidgetColors() override
|
~myWidgetColors() override
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
const finalcut::FString getClassName() const override
|
finalcut::FString getClassName() const override
|
||||||
{
|
{
|
||||||
return "myWidgetColors";
|
return "myWidgetColors";
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class BeeColorTheme final : public finalcut::FWidgetColors
|
||||||
~BeeColorTheme() override
|
~BeeColorTheme() override
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
const finalcut::FString getClassName() const override
|
finalcut::FString getClassName() const override
|
||||||
{
|
{
|
||||||
return "BeeColorTheme";
|
return "BeeColorTheme";
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ class myColorPalette final : public finalcut::FColorPalette
|
||||||
~myColorPalette()
|
~myColorPalette()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
const finalcut::FString getClassName() const override
|
finalcut::FString getClassName() const override
|
||||||
{
|
{
|
||||||
return "myColorPalette";
|
return "myColorPalette";
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ class BeeColorPalette final : public finalcut::FColorPalette
|
||||||
~BeeColorPalette()
|
~BeeColorPalette()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
const finalcut::FString getClassName() const override
|
finalcut::FString getClassName() const override
|
||||||
{
|
{
|
||||||
return "BeeColorPalette";
|
return "BeeColorPalette";
|
||||||
}
|
}
|
||||||
|
@ -437,7 +437,7 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
After entering the source code in *theme.cpp* you can compile
|
After entering the source code in *theme.cpp* you can compile
|
||||||
the above program with gcc:
|
the above program with gcc:
|
||||||
```cpp
|
```bash
|
||||||
g++ -O2 -lfinal -std=c++11 theme.cpp -o theme
|
g++ theme.cpp -o theme -O2 -lfinal -std=c++11
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -39,9 +40,6 @@ using finalcut::FSize;
|
||||||
class SegmentView final : public finalcut::FDialog
|
class SegmentView final : public finalcut::FDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Using-declaration
|
|
||||||
using FDialog::setGeometry;
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
explicit SegmentView (finalcut::FWidget* = nullptr);
|
explicit SegmentView (finalcut::FWidget* = nullptr);
|
||||||
|
|
||||||
|
@ -64,12 +62,11 @@ class SegmentView final : public finalcut::FDialog
|
||||||
void get7Segment (const wchar_t);
|
void get7Segment (const wchar_t);
|
||||||
void draw() override;
|
void draw() override;
|
||||||
|
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
std::map<wchar_t, sevenSegment> code{};
|
std::map<wchar_t, sevenSegment> code{};
|
||||||
finalcut::FString line[3]{};
|
std::array<finalcut::FString, 3> line{};
|
||||||
finalcut::FLineEdit Input{"0123", this};
|
finalcut::FLineEdit input{"0123", this};
|
||||||
finalcut::FButton Exit{"E&xit", this};
|
finalcut::FButton exit{"E&xit", this};
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -86,18 +83,18 @@ SegmentView::SegmentView (finalcut::FWidget* parent)
|
||||||
hexEncoding();
|
hexEncoding();
|
||||||
|
|
||||||
// Input field
|
// Input field
|
||||||
Input.setGeometry (FPoint(2, 2), FSize{12, 1});
|
input.setGeometry (FPoint(2, 2), FSize{12, 1});
|
||||||
Input.setLabelText (L"&Hex value");
|
input.setLabelText (L"&Hex value");
|
||||||
Input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)");
|
input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)");
|
||||||
Input.setLabelOrientation(finalcut::FLineEdit::label_above);
|
input.setLabelOrientation(finalcut::FLineEdit::label_above);
|
||||||
Input.setMaxLength(9);
|
input.setMaxLength(9);
|
||||||
Input.setInputFilter("[:.hHlLpPuU[:xdigit:]]");
|
input.setInputFilter("[:.hHlLpPuU[:xdigit:]]");
|
||||||
|
|
||||||
// Exit button
|
// Exit button
|
||||||
Exit.setGeometry(FPoint{28, 11}, FSize{10, 1});
|
exit.setGeometry(FPoint{28, 11}, FSize{10, 1});
|
||||||
|
|
||||||
// Add some function callbacks
|
// Add some function callbacks
|
||||||
Input.addCallback
|
input.addCallback
|
||||||
(
|
(
|
||||||
"changed",
|
"changed",
|
||||||
[] (SegmentView& dialog)
|
[] (SegmentView& dialog)
|
||||||
|
@ -107,7 +104,7 @@ SegmentView::SegmentView (finalcut::FWidget* parent)
|
||||||
std::ref(*this)
|
std::ref(*this)
|
||||||
);
|
);
|
||||||
|
|
||||||
Exit.addCallback
|
exit.addCallback
|
||||||
(
|
(
|
||||||
"clicked",
|
"clicked",
|
||||||
finalcut::getFApplication(),
|
finalcut::getFApplication(),
|
||||||
|
@ -140,7 +137,7 @@ void SegmentView::hexEncoding()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void SegmentView::get7Segment (const wchar_t c)
|
void SegmentView::get7Segment (const wchar_t c)
|
||||||
{
|
{
|
||||||
for (int i{0}; i < 3; i++)
|
for (std::size_t i{0}; i < 3; i++)
|
||||||
line[i].clear();
|
line[i].clear();
|
||||||
|
|
||||||
switch ( c )
|
switch ( c )
|
||||||
|
@ -186,8 +183,8 @@ void SegmentView::get7Segment (const wchar_t c)
|
||||||
if ( code.find(c) != code.end() )
|
if ( code.find(c) != code.end() )
|
||||||
{
|
{
|
||||||
const sevenSegment& s = code[c];
|
const sevenSegment& s = code[c];
|
||||||
constexpr char h[2]{' ', '_'};
|
constexpr std::array<char, 2> h{{' ', '_'}};
|
||||||
constexpr char v[2]{' ', '|'};
|
constexpr std::array<char, 2> v{{' ', '|'}};
|
||||||
|
|
||||||
line[0] << ' ' << h[s.a] << ' ';
|
line[0] << ' ' << h[s.a] << ' ';
|
||||||
line[1] << v[s.f] << h[s.g] << v[s.b];
|
line[1] << v[s.f] << h[s.g] << v[s.b];
|
||||||
|
@ -206,7 +203,7 @@ void SegmentView::draw()
|
||||||
setColor(fc::LightGray, fc::Black);
|
setColor(fc::LightGray, fc::Black);
|
||||||
finalcut::drawBorder(this, FRect(FPoint{3, 6}, FPoint{40, 11}));
|
finalcut::drawBorder(this, FRect(FPoint{3, 6}, FPoint{40, 11}));
|
||||||
|
|
||||||
for (auto&& ch : Input.getText().toUpper())
|
for (auto&& ch : input.getText().toUpper())
|
||||||
{
|
{
|
||||||
const FColorPair color{fc::LightRed, fc::Black};
|
const FColorPair color{fc::LightRed, fc::Black};
|
||||||
get7Segment(ch);
|
get7Segment(ch);
|
||||||
|
|
|
@ -24,7 +24,7 @@ endif
|
||||||
# $@ = name of the targets
|
# $@ = name of the targets
|
||||||
# $^ = all dependency (without double entries)
|
# $^ = all dependency (without double entries)
|
||||||
.cpp:
|
.cpp:
|
||||||
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o $@ $^
|
$(CXX) $^ -o $@ $(CCXFLAGS) $(INCLUDES) $(LDFLAGS)
|
||||||
|
|
||||||
all: $(OBJS)
|
all: $(OBJS)
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ endif
|
||||||
# $@ = name of the targets
|
# $@ = name of the targets
|
||||||
# $^ = all dependency (without double entries)
|
# $^ = all dependency (without double entries)
|
||||||
.cpp:
|
.cpp:
|
||||||
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o $@ $^
|
$(CXX) $^ -o $@ $(CCXFLAGS) $(INCLUDES) $(LDFLAGS)
|
||||||
|
|
||||||
all: $(OBJS)
|
all: $(OBJS)
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,6 @@ using finalcut::FSize;
|
||||||
class Background final : public finalcut::FDialog
|
class Background final : public finalcut::FDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Using-declaration
|
|
||||||
using FDialog::setGeometry;
|
|
||||||
|
|
||||||
// Typedef
|
// Typedef
|
||||||
typedef std::tuple<uChar, uChar, uChar> RGB;
|
typedef std::tuple<uChar, uChar, uChar> RGB;
|
||||||
|
|
||||||
|
@ -108,8 +105,7 @@ Background::Background (finalcut::FWidget* parent)
|
||||||
|
|
||||||
for (auto& c : color_list)
|
for (auto& c : color_list)
|
||||||
{
|
{
|
||||||
FDataPtr data_ptr = reinterpret_cast<FDataPtr>(&c.second);
|
finalcut::FListBoxItem item (c.first, c.second);
|
||||||
finalcut::FListBoxItem item (c.first, data_ptr);
|
|
||||||
color_choice.insert(item);
|
color_choice.insert(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,9 +195,8 @@ void Background::cb_choice()
|
||||||
uChar r{};
|
uChar r{};
|
||||||
uChar g{};
|
uChar g{};
|
||||||
uChar b{};
|
uChar b{};
|
||||||
const FDataPtr data_ptr = color_choice.getItemData();
|
const RGB rgb = color_choice.getItemData<RGB>();
|
||||||
const RGB* rgb = reinterpret_cast<RGB*>(data_ptr);
|
std::tie(r, g, b) = rgb;
|
||||||
std::tie(r, g, b) = *rgb;
|
|
||||||
red.setValue(r);
|
red.setValue(r);
|
||||||
green.setValue(g);
|
green.setValue(g);
|
||||||
blue.setValue(b);
|
blue.setValue(b);
|
||||||
|
|
|
@ -89,13 +89,13 @@ Dialog::Dialog (FWidget* parent)
|
||||||
void Dialog::adjustSize()
|
void Dialog::adjustSize()
|
||||||
{
|
{
|
||||||
finalcut::FDialog::adjustSize();
|
finalcut::FDialog::adjustSize();
|
||||||
int X = int((getDesktopWidth() - getWidth()) / 2);
|
auto x = int((getDesktopWidth() - getWidth()) / 2);
|
||||||
const int Y = 5;
|
const int y = 5;
|
||||||
|
|
||||||
if ( X < 1 )
|
if ( x < 1 )
|
||||||
X = 1;
|
x = 1;
|
||||||
|
|
||||||
setPos (FPoint{X, Y}, false);
|
setPos (FPoint{x, y}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <array>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -36,7 +37,7 @@ using finalcut::FRect;
|
||||||
using finalcut::FSize;
|
using finalcut::FSize;
|
||||||
using finalcut::FColorPair;
|
using finalcut::FColorPair;
|
||||||
|
|
||||||
constexpr lDouble PI{3.141592653589793238L};
|
constexpr lDouble pi_value{3.141592653589793238L};
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -213,6 +214,7 @@ class Calc final : public finalcut::FDialog
|
||||||
|
|
||||||
// Event handlers
|
// Event handlers
|
||||||
void onKeyPress (finalcut::FKeyEvent*) override;
|
void onKeyPress (finalcut::FKeyEvent*) override;
|
||||||
|
void onShow (finalcut::FShowEvent*) override;
|
||||||
void onClose (finalcut::FCloseEvent*) override;
|
void onClose (finalcut::FCloseEvent*) override;
|
||||||
|
|
||||||
// Callback method
|
// Callback method
|
||||||
|
@ -230,15 +232,15 @@ class Calc final : public finalcut::FDialog
|
||||||
char infix_operator{'\0'};
|
char infix_operator{'\0'};
|
||||||
char last_infix_operator{'\0'};
|
char last_infix_operator{'\0'};
|
||||||
finalcut::FString input{""};
|
finalcut::FString input{""};
|
||||||
button button_no[Calc::NUM_OF_BUTTONS]{};
|
std::array<button, Calc::NUM_OF_BUTTONS> button_no{};
|
||||||
|
|
||||||
struct stack_data
|
struct StackData
|
||||||
{
|
{
|
||||||
lDouble term;
|
lDouble term;
|
||||||
char infix_operator;
|
char infix_operator;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::stack<stack_data> bracket_stack{};
|
std::stack<StackData> bracket_stack{};
|
||||||
std::map<Calc::button, std::shared_ptr<Button> > calculator_buttons{};
|
std::map<Calc::button, std::shared_ptr<Button> > calculator_buttons{};
|
||||||
std::map<Calc::button, keyFunction> key_map{};
|
std::map<Calc::button, keyFunction> key_map{};
|
||||||
};
|
};
|
||||||
|
@ -255,7 +257,6 @@ Calc::Calc (FWidget* parent)
|
||||||
|
|
||||||
mapKeyFunctions();
|
mapKeyFunctions();
|
||||||
clearInfixOperator();
|
clearInfixOperator();
|
||||||
std::setlocale(LC_NUMERIC, "C");
|
|
||||||
|
|
||||||
for (button key{Sine}; key < Calc::NUM_OF_BUTTONS; key = button(key + 1))
|
for (button key{Sine}; key < Calc::NUM_OF_BUTTONS; key = button(key + 1))
|
||||||
{
|
{
|
||||||
|
@ -357,6 +358,13 @@ void Calc::onKeyPress (finalcut::FKeyEvent* ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void Calc::onShow (finalcut::FShowEvent*)
|
||||||
|
{
|
||||||
|
// Overwrites the initialized value of LC_NUMERIC
|
||||||
|
std::setlocale(LC_NUMERIC, "C");
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void Calc::onClose (finalcut::FCloseEvent* ev)
|
void Calc::onClose (finalcut::FCloseEvent* ev)
|
||||||
{
|
{
|
||||||
|
@ -696,14 +704,14 @@ void Calc::percent (lDouble& x)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void Calc::pi (lDouble& x)
|
void Calc::pi (lDouble& x)
|
||||||
{
|
{
|
||||||
x = PI;
|
x = pi_value;
|
||||||
setDisplay(x);
|
setDisplay(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void Calc::open_bracket (const lDouble&)
|
void Calc::open_bracket (const lDouble&)
|
||||||
{
|
{
|
||||||
const stack_data d{ a, infix_operator };
|
const StackData d{ a, infix_operator };
|
||||||
bracket_stack.push(d);
|
bracket_stack.push(d);
|
||||||
clearInfixOperator();
|
clearInfixOperator();
|
||||||
input = "";
|
input = "";
|
||||||
|
@ -719,7 +727,7 @@ void Calc::close_bracket (const lDouble&)
|
||||||
|
|
||||||
calcInfixOperator();
|
calcInfixOperator();
|
||||||
setDisplay(a);
|
setDisplay(a);
|
||||||
const stack_data d = bracket_stack.top();
|
const StackData d = bracket_stack.top();
|
||||||
bracket_stack.pop();
|
bracket_stack.pop();
|
||||||
b = d.term;
|
b = d.term;
|
||||||
infix_operator = d.infix_operator;
|
infix_operator = d.infix_operator;
|
||||||
|
@ -828,11 +836,11 @@ void Calc::sine (lDouble& x)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( arcus_mode )
|
if ( arcus_mode )
|
||||||
x = std::asin(x) * 180.0L / PI;
|
x = std::asin(x) * 180.0L / pi_value;
|
||||||
else if ( std::fabs(std::fmod(x, 180.0L)) < LDBL_EPSILON ) // x / 180 = 0
|
else if ( std::fabs(std::fmod(x, 180.0L)) < LDBL_EPSILON ) // x / 180 = 0
|
||||||
x = 0.0L;
|
x = 0.0L;
|
||||||
else
|
else
|
||||||
x = std::sin(x * PI / 180.0L);
|
x = std::sin(x * pi_value / 180.0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( errno == EDOM )
|
if ( errno == EDOM )
|
||||||
|
@ -866,11 +874,11 @@ void Calc::cosine (lDouble& x)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( arcus_mode )
|
if ( arcus_mode )
|
||||||
x = std::acos(x) * 180.0L / PI;
|
x = std::acos(x) * 180.0L / pi_value;
|
||||||
else if ( std::fabs(std::fmod(x - 90.0L, 180.0L)) < LDBL_EPSILON ) // (x - 90) / 180 == 0
|
else if ( std::fabs(std::fmod(x - 90.0L, 180.0L)) < LDBL_EPSILON ) // (x - 90) / 180 == 0
|
||||||
x = 0.0L;
|
x = 0.0L;
|
||||||
else
|
else
|
||||||
x = std::cos(x * PI / 180.0L);
|
x = std::cos(x * pi_value / 180.0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( errno == EDOM )
|
if ( errno == EDOM )
|
||||||
|
@ -904,7 +912,7 @@ void Calc::tangent (lDouble& x)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( arcus_mode )
|
if ( arcus_mode )
|
||||||
x = std::atan(x) * 180.0L / PI;
|
x = std::atan(x) * 180.0L / pi_value;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Test if (x / 180) != 0 and x / 90 == 0
|
// Test if (x / 180) != 0 and x / 90 == 0
|
||||||
|
@ -914,7 +922,7 @@ void Calc::tangent (lDouble& x)
|
||||||
else if ( std::fabs(std::fmod(x, 180.0L)) < LDBL_EPSILON ) // x / 180 == 0
|
else if ( std::fabs(std::fmod(x, 180.0L)) < LDBL_EPSILON ) // x / 180 == 0
|
||||||
x = 0.0L;
|
x = 0.0L;
|
||||||
else
|
else
|
||||||
x = std::tan(x * PI / 180.0L);
|
x = std::tan(x * pi_value / 180.0L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,8 +951,8 @@ void Calc::draw()
|
||||||
bool Calc::isDataEntryKey (int key) const
|
bool Calc::isDataEntryKey (int key) const
|
||||||
{
|
{
|
||||||
// Test if key is in {'.', '0'..'9'}
|
// Test if key is in {'.', '0'..'9'}
|
||||||
const int data_entry_keys[] =
|
constexpr std::array<int, 11> key_list =
|
||||||
{
|
{{
|
||||||
Decimal_point,
|
Decimal_point,
|
||||||
Zero,
|
Zero,
|
||||||
One,
|
One,
|
||||||
|
@ -956,11 +964,11 @@ bool Calc::isDataEntryKey (int key) const
|
||||||
Seven,
|
Seven,
|
||||||
Eight,
|
Eight,
|
||||||
Nine
|
Nine
|
||||||
};
|
}};
|
||||||
|
|
||||||
const int* iter = std::find (data_entry_keys, data_entry_keys + 11, key);
|
const auto& iter = std::find (key_list.begin(), key_list.end(), key);
|
||||||
|
|
||||||
if ( iter != data_entry_keys + 11 )
|
if ( iter != key_list.end() )
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
@ -970,19 +978,19 @@ bool Calc::isDataEntryKey (int key) const
|
||||||
bool Calc::isOperatorKey(int key) const
|
bool Calc::isOperatorKey(int key) const
|
||||||
{
|
{
|
||||||
// Test if key is in {'*', '/', '+', '-', '^', '='}
|
// Test if key is in {'*', '/', '+', '-', '^', '='}
|
||||||
const int operators[] =
|
constexpr std::array<int, 6> operators =
|
||||||
{
|
{{
|
||||||
Multiply,
|
Multiply,
|
||||||
Divide,
|
Divide,
|
||||||
Add,
|
Add,
|
||||||
Subtract,
|
Subtract,
|
||||||
Power,
|
Power,
|
||||||
Equals
|
Equals
|
||||||
};
|
}};
|
||||||
|
|
||||||
const int* iter = std::find (operators, operators + 6, key);
|
const auto& iter = std::find (operators.begin(), operators.end(), key);
|
||||||
|
|
||||||
if ( iter != operators + 6 )
|
if ( iter != operators.end() )
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
@ -1092,8 +1100,8 @@ void Calc::adjustSize()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const wchar_t* Calc::getButtonText (const std::size_t key) const
|
const wchar_t* Calc::getButtonText (const std::size_t key) const
|
||||||
{
|
{
|
||||||
static const wchar_t* const button_text[Calc::NUM_OF_BUTTONS] =
|
constexpr std::array<const wchar_t*, Calc::NUM_OF_BUTTONS> button_text =
|
||||||
{
|
{{
|
||||||
L"&Sin",
|
L"&Sin",
|
||||||
L"&Cos",
|
L"&Cos",
|
||||||
L"&Tan",
|
L"&Tan",
|
||||||
|
@ -1128,7 +1136,7 @@ const wchar_t* Calc::getButtonText (const std::size_t key) const
|
||||||
L"&.",
|
L"&.",
|
||||||
L"&±",
|
L"&±",
|
||||||
L"&="
|
L"&="
|
||||||
};
|
}};
|
||||||
|
|
||||||
return button_text[key];
|
return button_text[key];
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -58,6 +59,7 @@ class CheckList final : public finalcut::FDialog
|
||||||
private:
|
private:
|
||||||
// Method
|
// Method
|
||||||
void populate();
|
void populate();
|
||||||
|
void adjustSize() override;
|
||||||
|
|
||||||
// Event handlers
|
// Event handlers
|
||||||
void onKeyPress (finalcut::FKeyEvent*) override;
|
void onKeyPress (finalcut::FKeyEvent*) override;
|
||||||
|
@ -67,7 +69,7 @@ class CheckList final : public finalcut::FDialog
|
||||||
void cb_showList();
|
void cb_showList();
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
finalcut::FListView listView{this};
|
finalcut::FListView listview{this};
|
||||||
finalcut::FStatusBar status_bar{this};
|
finalcut::FStatusBar status_bar{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,25 +82,24 @@ CheckList::CheckList (finalcut::FWidget* parent)
|
||||||
// (CERT, OOP50-CPP)
|
// (CERT, OOP50-CPP)
|
||||||
FDialog::setText (L"Shopping list");
|
FDialog::setText (L"Shopping list");
|
||||||
const std::size_t nf_offset = ( finalcut::FTerm::isNewFont() ) ? 1 : 0;
|
const std::size_t nf_offset = ( finalcut::FTerm::isNewFont() ) ? 1 : 0;
|
||||||
FDialog::setGeometry ( FPoint{int(1 + (parent->getWidth() - 28) / 2), 5}
|
FDialog::setSize (FSize{28 + nf_offset, 13} );
|
||||||
, FSize{28 + nf_offset, 13} );
|
setShadow(); // Instead of the transparent window shadow
|
||||||
setShadow();
|
listview.ignorePadding();
|
||||||
listView.ignorePadding();
|
listview.setGeometry ( FPoint{1 + int(nf_offset), 2}
|
||||||
listView.setGeometry ( FPoint{1 + int(nf_offset), 2}
|
|
||||||
, FSize{getWidth() - nf_offset, getHeight() - 1} );
|
, FSize{getWidth() - nf_offset, getHeight() - 1} );
|
||||||
|
|
||||||
// Add columns to the view
|
// Add columns to the view
|
||||||
listView.addColumn ("Item");
|
listview.addColumn ("Item");
|
||||||
listView.addColumn ("Priority", 9);
|
listview.addColumn ("Priority", 9);
|
||||||
|
|
||||||
// Set the type of sorting
|
// Set the type of sorting
|
||||||
listView.setColumnSortType (1, fc::by_name);
|
listview.setColumnSortType (1, fc::by_name);
|
||||||
listView.setColumnSortType (2, fc::by_name);
|
listview.setColumnSortType (2, fc::by_name);
|
||||||
|
|
||||||
// Statusbar at the bottom
|
// Statusbar at the bottom
|
||||||
finalcut::FString separator{};
|
finalcut::FString separator{};
|
||||||
separator << ' ' << fc::BoxDrawingsVertical << ' ';
|
separator << ' ' << fc::BoxDrawingsVertical << ' ';
|
||||||
listView.setStatusbarMessage ( finalcut::FString{}
|
listview.setStatusbarMessage ( finalcut::FString{}
|
||||||
<< "<Q> exit" << separator
|
<< "<Q> exit" << separator
|
||||||
<< "<Space> select an item" << separator
|
<< "<Space> select an item" << separator
|
||||||
<< "<Enter> see your pick list");
|
<< "<Enter> see your pick list");
|
||||||
|
@ -107,7 +108,7 @@ CheckList::CheckList (finalcut::FWidget* parent)
|
||||||
populate();
|
populate();
|
||||||
|
|
||||||
// Add callback method
|
// Add callback method
|
||||||
listView.addCallback
|
listview.addCallback
|
||||||
(
|
(
|
||||||
"clicked",
|
"clicked",
|
||||||
this, &CheckList::cb_showList
|
this, &CheckList::cb_showList
|
||||||
|
@ -121,29 +122,36 @@ CheckList::~CheckList() // destructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void CheckList::populate()
|
void CheckList::populate()
|
||||||
{
|
{
|
||||||
const std::string list[][2] =
|
constexpr std::array<std::array<const char*, 2>, 10> list =
|
||||||
{
|
{{
|
||||||
{ "Milk", "Highest" },
|
{{ "Milk", "Highest" }},
|
||||||
{ "Cheese", "High" },
|
{{ "Cheese", "High" }},
|
||||||
{ "Yoghurt", "Medium" },
|
{{ "Yoghurt", "Medium" }},
|
||||||
{ "Bread", "Low" },
|
{{ "Bread", "Low" }},
|
||||||
{ "Eggs", "High" },
|
{{ "Eggs", "High" }},
|
||||||
{ "Toothpaste", "Medium" },
|
{{ "Toothpaste", "Medium" }},
|
||||||
{ "Apples", "Lowest" },
|
{{ "Apples", "Lowest" }},
|
||||||
{ "Bananas", "Medium" },
|
{{ "Bananas", "Medium" }},
|
||||||
{ "Fish", "Medium" },
|
{{ "Fish", "Medium" }},
|
||||||
{ "Lemons", "Low" }
|
{{ "Lemons", "Low" }}
|
||||||
};
|
}};
|
||||||
|
|
||||||
for (const auto& line : list)
|
for (const auto& line : list)
|
||||||
{
|
{
|
||||||
const finalcut::FStringList string_line (&line[0], &line[0] + 2);
|
const finalcut::FStringList string_line (line.begin(), line.end());
|
||||||
auto iter = listView.insert (string_line);
|
auto iter = listview.insert (string_line);
|
||||||
auto item = static_cast<finalcut::FListViewItem*>(*iter);
|
auto item = static_cast<finalcut::FListViewItem*>(*iter);
|
||||||
item->setCheckable(true);
|
item->setCheckable(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void CheckList::adjustSize()
|
||||||
|
{
|
||||||
|
finalcut::FDialog::adjustSize();
|
||||||
|
setPos(FPoint{int(1 + (getDesktopWidth() - getWidth()) / 2), 5});
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void CheckList::onKeyPress (finalcut::FKeyEvent* ev)
|
void CheckList::onKeyPress (finalcut::FKeyEvent* ev)
|
||||||
{
|
{
|
||||||
|
@ -170,18 +178,12 @@ void CheckList::onClose (finalcut::FCloseEvent* ev)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void CheckList::cb_showList()
|
void CheckList::cb_showList()
|
||||||
{
|
{
|
||||||
auto iter = listView.beginOfList();
|
|
||||||
finalcut::FString shopping_list{};
|
finalcut::FString shopping_list{};
|
||||||
|
|
||||||
while ( iter != listView.endOfList() )
|
for (auto item : listview.getData())
|
||||||
{
|
{
|
||||||
const auto item = static_cast<finalcut::FListViewItem*>(*iter);
|
|
||||||
|
|
||||||
if ( item->isChecked() )
|
if ( item->isChecked() )
|
||||||
shopping_list << fc::Bullet << ' '
|
shopping_list << fc::Bullet << ' ' << item->getText(1) << '\n';
|
||||||
<< item->getText(1) << '\n';
|
|
||||||
|
|
||||||
++iter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( shopping_list.isEmpty() )
|
if ( shopping_list.isEmpty() )
|
||||||
|
|
|
@ -51,7 +51,7 @@ class EventDialog final : public finalcut::FDialog
|
||||||
EventDialog (const EventDialog&) = delete;
|
EventDialog (const EventDialog&) = delete;
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~EventDialog();
|
~EventDialog() override;
|
||||||
|
|
||||||
// Disable copy assignment operator (=)
|
// Disable copy assignment operator (=)
|
||||||
EventDialog& operator = (const EventDialog&) = delete;
|
EventDialog& operator = (const EventDialog&) = delete;
|
||||||
|
@ -162,8 +162,10 @@ void EventDialog::onKeyPress (finalcut::FKeyEvent* ev)
|
||||||
if ( key_name.isEmpty() )
|
if ( key_name.isEmpty() )
|
||||||
key_name = wchar_t(key_id);
|
key_name = wchar_t(key_id);
|
||||||
|
|
||||||
log << finalcut::FLog::Info
|
// std::clog redirects all stream data to FLogger
|
||||||
<< "Key " << key_name << " (id " << key_id << ")" << std::flush;
|
std::clog << finalcut::FLog::Info
|
||||||
|
<< "Key " << key_name
|
||||||
|
<< " (id " << key_id << ")" << std::flush;
|
||||||
|
|
||||||
finalcut::FDialog::onKeyPress(ev);
|
finalcut::FDialog::onKeyPress(ev);
|
||||||
}
|
}
|
||||||
|
@ -243,7 +245,7 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream
|
||||||
EventLog (const EventLog&) = delete;
|
EventLog (const EventLog&) = delete;
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~EventLog();
|
~EventLog() override;
|
||||||
|
|
||||||
// Disable copy assignment operator (=)
|
// Disable copy assignment operator (=)
|
||||||
EventLog& operator = (const EventLog&) = delete;
|
EventLog& operator = (const EventLog&) = delete;
|
||||||
|
@ -257,7 +259,7 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream
|
||||||
void adjustSize() override;
|
void adjustSize() override;
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
finalcut::FTextView scrollText{this};
|
finalcut::FTextView scrolltext{this};
|
||||||
EventDialog* event_dialog{new EventDialog(this)};
|
EventDialog* event_dialog{new EventDialog(this)};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -273,8 +275,8 @@ EventLog::EventLog (finalcut::FWidget* parent)
|
||||||
FDialog::setResizeable();
|
FDialog::setResizeable();
|
||||||
setMinimumSize (FSize{75, 5});
|
setMinimumSize (FSize{75, 5});
|
||||||
setShadow();
|
setShadow();
|
||||||
scrollText.ignorePadding();
|
scrolltext.ignorePadding();
|
||||||
scrollText.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||||
event_dialog->setFocus();
|
event_dialog->setFocus();
|
||||||
addTimer(250); // Starts the timer every 250 milliseconds
|
addTimer(250); // Starts the timer every 250 milliseconds
|
||||||
}
|
}
|
||||||
|
@ -288,9 +290,9 @@ void EventLog::onTimer (finalcut::FTimerEvent*)
|
||||||
{
|
{
|
||||||
if ( ! str().empty() )
|
if ( ! str().empty() )
|
||||||
{
|
{
|
||||||
scrollText.append(str());
|
scrolltext.append(str());
|
||||||
str("");
|
str("");
|
||||||
scrollText.scrollToEnd();
|
scrolltext.scrollToEnd();
|
||||||
redraw();
|
redraw();
|
||||||
updateTerminal();
|
updateTerminal();
|
||||||
}
|
}
|
||||||
|
@ -306,7 +308,7 @@ void EventLog::onClose (finalcut::FCloseEvent* ev)
|
||||||
void EventLog::adjustSize()
|
void EventLog::adjustSize()
|
||||||
{
|
{
|
||||||
finalcut::FDialog::adjustSize();
|
finalcut::FDialog::adjustSize();
|
||||||
scrollText.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
|
scrolltext.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ int main (int argc, char* argv[])
|
||||||
finalcut::FDialog dgl{&app};
|
finalcut::FDialog dgl{&app};
|
||||||
dgl.setText ("Data input");
|
dgl.setText ("Data input");
|
||||||
dgl.setGeometry (FPoint{4, 2}, FSize{37, 22});
|
dgl.setGeometry (FPoint{4, 2}, FSize{37, 22});
|
||||||
dgl.setShadow();
|
dgl.setShadow(); // Instead of the transparent window shadow
|
||||||
|
|
||||||
// Create input fields
|
// Create input fields
|
||||||
finalcut::FLineEdit name_field {&dgl};
|
finalcut::FLineEdit name_field {&dgl};
|
||||||
|
@ -93,22 +93,22 @@ int main (int argc, char* argv[])
|
||||||
c_field.setGeometry (FPoint{11, 11}, FSize{4, 1});
|
c_field.setGeometry (FPoint{11, 11}, FSize{4, 1});
|
||||||
|
|
||||||
// Create the button group
|
// Create the button group
|
||||||
finalcut::FButtonGroup radioButtonGroup {"Sex", &dgl};
|
finalcut::FButtonGroup radiobutton_group {"Sex", &dgl};
|
||||||
radioButtonGroup.setGeometry(FPoint{2, 13}, FSize{13, 4});
|
radiobutton_group.setGeometry(FPoint{2, 13}, FSize{13, 4});
|
||||||
|
|
||||||
// Create radio buttons
|
// Create radio buttons
|
||||||
finalcut::FRadioButton male {"&Male", &radioButtonGroup};
|
finalcut::FRadioButton male {"&Male", &radiobutton_group};
|
||||||
finalcut::FRadioButton female {"&Female", &radioButtonGroup};
|
finalcut::FRadioButton female {"&Female", &radiobutton_group};
|
||||||
male.setGeometry (FPoint{1, 1}, FSize{8, 1});
|
male.setGeometry (FPoint{1, 1}, FSize{8, 1});
|
||||||
female.setGeometry (FPoint{1, 2}, FSize{10, 1});
|
female.setGeometry (FPoint{1, 2}, FSize{10, 1});
|
||||||
|
|
||||||
// Create another button group
|
// Create another button group
|
||||||
finalcut::FButtonGroup checkButtonGroup {"&Data options", &dgl};
|
finalcut::FButtonGroup checkbutton_group {"&Data options", &dgl};
|
||||||
checkButtonGroup.setGeometry(FPoint{16, 13}, FSize{19, 4});
|
checkbutton_group.setGeometry(FPoint{16, 13}, FSize{19, 4});
|
||||||
|
|
||||||
// Create checkbox buttons
|
// Create checkbox buttons
|
||||||
finalcut::FCheckBox check1 {"Save data", &checkButtonGroup};
|
finalcut::FCheckBox check1 {"Save data", &checkbutton_group};
|
||||||
finalcut::FCheckBox check2 {"Encrypt data", &checkButtonGroup};
|
finalcut::FCheckBox check2 {"Encrypt data", &checkbutton_group};
|
||||||
check1.setGeometry (FPoint{1, 1}, FSize{13, 1});
|
check1.setGeometry (FPoint{1, 1}, FSize{13, 1});
|
||||||
check2.setGeometry (FPoint{1, 2}, FSize{16, 1});
|
check2.setGeometry (FPoint{1, 2}, FSize{16, 1});
|
||||||
check2.setDisable();
|
check2.setDisable();
|
||||||
|
|
|
@ -38,8 +38,8 @@ static std::weak_ptr<FString> temp_str;
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
void doubleToItem ( FListBoxItem&
|
void doubleToItem ( FListBoxItem&
|
||||||
, FDataPtr container
|
, FDataAccess* container
|
||||||
, int index);
|
, std::size_t index);
|
||||||
FString& doubleToString (std::list<double>::const_iterator iter);
|
FString& doubleToString (std::list<double>::const_iterator iter);
|
||||||
FString& mapToString ( std::map<FString
|
FString& mapToString ( std::map<FString
|
||||||
, FString>::const_iterator iter );
|
, FString>::const_iterator iter );
|
||||||
|
@ -47,14 +47,15 @@ FString& mapToString ( std::map<FString
|
||||||
|
|
||||||
// Lazy conversion insert function
|
// Lazy conversion insert function
|
||||||
void doubleToItem ( FListBoxItem& item
|
void doubleToItem ( FListBoxItem& item
|
||||||
, FDataPtr container, int index)
|
, FDataAccess* container
|
||||||
|
, std::size_t index )
|
||||||
{
|
{
|
||||||
typedef std::list<double>* double_list_ptr;
|
typedef std::list<double> DblList;
|
||||||
double_list_ptr dbllist = static_cast<double_list_ptr>(container);
|
DblList& dbl_list = flistboxhelper::getContainer<DblList>(container);
|
||||||
std::list<double>::iterator iter = dbllist->begin();
|
std::list<double>::iterator iter = dbl_list.begin();
|
||||||
std::advance (iter, index);
|
std::advance (iter, index);
|
||||||
item.setText (FString() << *iter);
|
item.setText (FString() << *iter);
|
||||||
item.setData (FDataPtr(&(*iter)));
|
item.setData (*iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert converter functions
|
// Insert converter functions
|
||||||
|
@ -100,7 +101,7 @@ class Listbox final : public FDialog
|
||||||
FListBox list1{this};
|
FListBox list1{this};
|
||||||
FListBox list2{this};
|
FListBox list2{this};
|
||||||
FListBox list3{this};
|
FListBox list3{this};
|
||||||
FButton Quit{this};
|
FButton quit{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -129,7 +130,7 @@ Listbox::Listbox (FWidget* parent)
|
||||||
//
|
//
|
||||||
// Insert via lazy conversion on print
|
// Insert via lazy conversion on print
|
||||||
//
|
//
|
||||||
list2.insert (&double_list, doubleToItem);
|
list2.insert (double_list, doubleToItem); // (container, converter)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Direct insert of the complete list
|
// Direct insert of the complete list
|
||||||
|
@ -150,11 +151,11 @@ Listbox::Listbox (FWidget* parent)
|
||||||
list3.setText ("key: value");
|
list3.setText ("key: value");
|
||||||
|
|
||||||
// Quit button
|
// Quit button
|
||||||
Quit.setGeometry(FPoint{42, 12}, FSize{10, 1});
|
quit.setGeometry(FPoint{42, 12}, FSize{10, 1});
|
||||||
Quit.setText (L"&Quit");
|
quit.setText (L"&Quit");
|
||||||
|
|
||||||
// Add quit button function callback
|
// Add quit button function callback
|
||||||
Quit.addCallback
|
quit.addCallback
|
||||||
(
|
(
|
||||||
"clicked",
|
"clicked",
|
||||||
finalcut::getFApplication(),
|
finalcut::getFApplication(),
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -62,8 +63,8 @@ class Listview final : public finalcut::FDialog
|
||||||
void cb_showInMessagebox();
|
void cb_showInMessagebox();
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
finalcut::FListView listView{this};
|
finalcut::FListView listview{this};
|
||||||
finalcut::FButton Quit{this};
|
finalcut::FButton quit{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -71,44 +72,44 @@ Listview::Listview (finalcut::FWidget* parent)
|
||||||
: finalcut::FDialog{parent}
|
: finalcut::FDialog{parent}
|
||||||
{
|
{
|
||||||
// Set FListView geometry
|
// Set FListView geometry
|
||||||
listView.setGeometry(FPoint{2, 1}, FSize{33, 14});
|
listview.setGeometry(FPoint{2, 1}, FSize{33, 14});
|
||||||
|
|
||||||
// Add columns to the view
|
// Add columns to the view
|
||||||
listView.addColumn ("City");
|
listview.addColumn ("City");
|
||||||
listView.addColumn ("Condition");
|
listview.addColumn ("Condition");
|
||||||
listView.addColumn ("Temp.");
|
listview.addColumn ("Temp.");
|
||||||
listView.addColumn ("Humidity");
|
listview.addColumn ("Humidity");
|
||||||
listView.addColumn ("Pressure", 10);
|
listview.addColumn ("Pressure", 10);
|
||||||
|
|
||||||
// Set right alignment for the third, fourth, and fifth column
|
// Set right alignment for the third, fourth, and fifth column
|
||||||
listView.setColumnAlignment (3, fc::alignRight);
|
listview.setColumnAlignment (3, fc::alignRight);
|
||||||
listView.setColumnAlignment (4, fc::alignRight);
|
listview.setColumnAlignment (4, fc::alignRight);
|
||||||
listView.setColumnAlignment (5, fc::alignRight);
|
listview.setColumnAlignment (5, fc::alignRight);
|
||||||
|
|
||||||
// Set the type of sorting
|
// Set the type of sorting
|
||||||
listView.setColumnSortType (1, fc::by_name);
|
listview.setColumnSortType (1, fc::by_name);
|
||||||
listView.setColumnSortType (2, fc::by_name);
|
listview.setColumnSortType (2, fc::by_name);
|
||||||
listView.setColumnSortType (3, fc::by_number);
|
listview.setColumnSortType (3, fc::by_number);
|
||||||
listView.setColumnSortType (4, fc::by_number);
|
listview.setColumnSortType (4, fc::by_number);
|
||||||
listView.setColumnSortType (5, fc::by_number);
|
listview.setColumnSortType (5, fc::by_number);
|
||||||
|
|
||||||
// Sort in ascending order by the 1st column
|
// Sort in ascending order by the 1st column
|
||||||
listView.setColumnSort (1, fc::ascending);
|
listview.setColumnSort (1, fc::ascending);
|
||||||
// Sorting follows later automatically on insert().
|
// Sorting follows later automatically on insert().
|
||||||
// Otherwise you could start the sorting directly with sort()
|
// Otherwise you could start the sorting directly with sort()
|
||||||
|
|
||||||
// Allways show the sort indicator (▼/▲)
|
// Allways show the sort indicator (▼/▲)
|
||||||
listView.hideSortIndicator(false);
|
listview.hideSortIndicator(false);
|
||||||
|
|
||||||
// Populate FListView with a list of items
|
// Populate FListView with a list of items
|
||||||
populate();
|
populate();
|
||||||
|
|
||||||
// Quit button
|
// Quit button
|
||||||
Quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||||
Quit.setText (L"&Quit");
|
quit.setText (L"&Quit");
|
||||||
|
|
||||||
// Add some function callbacks
|
// Add some function callbacks
|
||||||
Quit.addCallback
|
quit.addCallback
|
||||||
(
|
(
|
||||||
"clicked",
|
"clicked",
|
||||||
finalcut::getFApplication(),
|
finalcut::getFApplication(),
|
||||||
|
@ -116,7 +117,7 @@ Listview::Listview (finalcut::FWidget* parent)
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
|
||||||
listView.addCallback
|
listview.addCallback
|
||||||
(
|
(
|
||||||
"clicked",
|
"clicked",
|
||||||
this, &Listview::cb_showInMessagebox
|
this, &Listview::cb_showInMessagebox
|
||||||
|
@ -130,55 +131,55 @@ Listview::~Listview() // destructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void Listview::populate()
|
void Listview::populate()
|
||||||
{
|
{
|
||||||
const std::string weather[][5] =
|
constexpr std::array<std::array<const char*, 5>, 41> weather =
|
||||||
{
|
{{
|
||||||
{ "Alexandria", "Sunny", "31°C", "61%", "1006.4 mb" },
|
{{ "Alexandria", "Sunny", "31°C", "61%", "1006.4 mb" }},
|
||||||
{ "Amsterdam", "Cloudy", "21°C", "82%", "1021.3 mb" },
|
{{ "Amsterdam", "Cloudy", "21°C", "82%", "1021.3 mb" }},
|
||||||
{ "Baghdad", "Fair", "47°C", "9%", "1001.0 mb" },
|
{{ "Baghdad", "Fair", "47°C", "9%", "1001.0 mb" }},
|
||||||
{ "Bangkok", "Partly Cloudy", "30°C", "69%", "1002.0 mb" },
|
{{ "Bangkok", "Partly Cloudy", "30°C", "69%", "1002.0 mb" }},
|
||||||
{ "Beijing", "Fair", "31°C", "68%", "1007.1 mb" },
|
{{ "Beijing", "Fair", "31°C", "68%", "1007.1 mb" }},
|
||||||
{ "Berlin", "Cloudy", "22°C", "53%", "1022.0 mb" },
|
{{ "Berlin", "Cloudy", "22°C", "53%", "1022.0 mb" }},
|
||||||
{ "Bogotá", "Fair", "9°C", "95%", "1028.5 mb" },
|
{{ "Bogotá", "Fair", "9°C", "95%", "1028.5 mb" }},
|
||||||
{ "Budapest", "Partly Cloudy", "23°C", "37%", "1020.7 mb" },
|
{{ "Budapest", "Partly Cloudy", "23°C", "37%", "1020.7 mb" }},
|
||||||
{ "Buenos Aires", "Cloudy", "7°C", "73%", "1019.0 mb" },
|
{{ "Buenos Aires", "Cloudy", "7°C", "73%", "1019.0 mb" }},
|
||||||
{ "Cairo", "Fair", "39°C", "22%", "1006.1 mb" },
|
{{ "Cairo", "Fair", "39°C", "22%", "1006.1 mb" }},
|
||||||
{ "Cape Town", "Partly Cloudy", "12°C", "45%", "1030.1 mb" },
|
{{ "Cape Town", "Partly Cloudy", "12°C", "45%", "1030.1 mb" }},
|
||||||
{ "Chicago", "Mostly Cloudy", "21°C", "81%", "1014.9 mb" },
|
{{ "Chicago", "Mostly Cloudy", "21°C", "81%", "1014.9 mb" }},
|
||||||
{ "Delhi", "Haze", "33°C", "68%", "998.0 mb" },
|
{{ "Delhi", "Haze", "33°C", "68%", "998.0 mb" }},
|
||||||
{ "Dhaka", "Haze", "32°C", "64%", "996.3 mb" },
|
{{ "Dhaka", "Haze", "32°C", "64%", "996.3 mb" }},
|
||||||
{ "Houston", "Cloudy", "23°C", "100%", "1014.2 mb" },
|
{{ "Houston", "Cloudy", "23°C", "100%", "1014.2 mb" }},
|
||||||
{ "Istanbul", "Mostly Cloudy", "27°C", "61%", "1011.2 mb" },
|
{{ "Istanbul", "Mostly Cloudy", "27°C", "61%", "1011.2 mb" }},
|
||||||
{ "Jakarta", "Fair", "28°C", "71%", "1009.1 mb" },
|
{{ "Jakarta", "Fair", "28°C", "71%", "1009.1 mb" }},
|
||||||
{ "Jerusalem", "Sunny", "35°C", "17%", "1005.8 mb" },
|
{{ "Jerusalem", "Sunny", "35°C", "17%", "1005.8 mb" }},
|
||||||
{ "Johannesburg", "Fair", "18°C", "16%", "1020.0 mb" },
|
{{ "Johannesburg", "Fair", "18°C", "16%", "1020.0 mb" }},
|
||||||
{ "Karachi", "Mostly Cloudy", "29°C", "76%", "998.0 mb" },
|
{{ "Karachi", "Mostly Cloudy", "29°C", "76%", "998.0 mb" }},
|
||||||
{ "Lagos", "Mostly Cloudy", "27°C", "86%", "1014.6 mb" },
|
{{ "Lagos", "Mostly Cloudy", "27°C", "86%", "1014.6 mb" }},
|
||||||
{ "Lima", "Cloudy", "17°C", "83%", "1017.3 mb" },
|
{{ "Lima", "Cloudy", "17°C", "83%", "1017.3 mb" }},
|
||||||
{ "London", "Cloudy", "23°C", "71%", "1023.0 mb" },
|
{{ "London", "Cloudy", "23°C", "71%", "1023.0 mb" }},
|
||||||
{ "Los Angeles", "Fair", "21°C", "78%", "1011.9 mb" },
|
{{ "Los Angeles", "Fair", "21°C", "78%", "1011.9 mb" }},
|
||||||
{ "Madrid", "Fair", "32°C", "35%", "1020.0 mb" },
|
{{ "Madrid", "Fair", "32°C", "35%", "1020.0 mb" }},
|
||||||
{ "Mexico City", "Partly Cloudy", "14°C", "79%", "1028.5 mb" },
|
{{ "Mexico City", "Partly Cloudy", "14°C", "79%", "1028.5 mb" }},
|
||||||
{ "Moscow", "Partly Cloudy", "24°C", "54%", "1014.2 mb" },
|
{{ "Moscow", "Partly Cloudy", "24°C", "54%", "1014.2 mb" }},
|
||||||
{ "Mumbai", "Haze", "28°C", "77%", "1003.0 mb" },
|
{{ "Mumbai", "Haze", "28°C", "77%", "1003.0 mb" }},
|
||||||
{ "New York City", "Sunny", "21°C", "80%", "1014.2 mb" },
|
{{ "New York City", "Sunny", "21°C", "80%", "1014.2 mb" }},
|
||||||
{ "Paris", "Partly Cloudy", "27°C", "57%", "1024.4 mb" },
|
{{ "Paris", "Partly Cloudy", "27°C", "57%", "1024.4 mb" }},
|
||||||
{ "Reykjavík", "Mostly Cloudy", "11°C", "76%", "998.6 mb" },
|
{{ "Reykjavík", "Mostly Cloudy", "11°C", "76%", "998.6 mb" }},
|
||||||
{ "Rio de Janeiro", "Fair", "24°C", "64%", "1022.0 mb" },
|
{{ "Rio de Janeiro", "Fair", "24°C", "64%", "1022.0 mb" }},
|
||||||
{ "Rome", "Fair", "32°C", "18%", "1014.2 mb" },
|
{{ "Rome", "Fair", "32°C", "18%", "1014.2 mb" }},
|
||||||
{ "Saint Petersburg", "Mostly Cloudy", "18°C", "55%", "1014.6 mb" },
|
{{ "Saint Petersburg", "Mostly Cloudy", "18°C", "55%", "1014.6 mb" }},
|
||||||
{ "São Paulo", "Fair", "19°C", "53%", "1024.0 mb" },
|
{{ "São Paulo", "Fair", "19°C", "53%", "1024.0 mb" }},
|
||||||
{ "Seoul", "Cloudy", "26°C", "87%", "1012.2 mb" },
|
{{ "Seoul", "Cloudy", "26°C", "87%", "1012.2 mb" }},
|
||||||
{ "Shanghai", "Fair", "32°C", "69%", "1009.1 mb" },
|
{{ "Shanghai", "Fair", "32°C", "69%", "1009.1 mb" }},
|
||||||
{ "Singapore", "Mostly Cloudy", "29°C", "73%", "1009.1 mb" },
|
{{ "Singapore", "Mostly Cloudy", "29°C", "73%", "1009.1 mb" }},
|
||||||
{ "Tehran", "Fair", "36°C", "14%", "1013.2 mb" },
|
{{ "Tehran", "Fair", "36°C", "14%", "1013.2 mb" }},
|
||||||
{ "Tokyo", "Mostly Cloudy", "28°C", "67%", "1009.1 mb" },
|
{{ "Tokyo", "Mostly Cloudy", "28°C", "67%", "1009.1 mb" }},
|
||||||
{ "Zurich", "Mostly Cloudy", "23°C", "44%", "1023.7 mb" }
|
{{ "Zurich", "Mostly Cloudy", "23°C", "44%", "1023.7 mb" }}
|
||||||
};
|
}};
|
||||||
|
|
||||||
for (const auto& place : weather)
|
for (const auto& place : weather)
|
||||||
{
|
{
|
||||||
const finalcut::FStringList line (&place[0], &place[0] + 5);
|
const finalcut::FStringList line (place.begin(), place.end());
|
||||||
listView.insert (line);
|
listview.insert (line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,13 +192,16 @@ void Listview::onClose (finalcut::FCloseEvent* ev)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void Listview::cb_showInMessagebox()
|
void Listview::cb_showInMessagebox()
|
||||||
{
|
{
|
||||||
const auto& item = listView.getCurrentItem();
|
const auto& item = listview.getCurrentItem();
|
||||||
finalcut::FMessageBox info ( "Weather in " + item->getText(1)
|
finalcut::FMessageBox info ( "Weather in " + item->getText(1)
|
||||||
, " Condition: " + item->getText(2) + "\n"
|
, " Condition: " + item->getText(2) + "\n"
|
||||||
"Temperature: " + item->getText(3) + "\n"
|
"Temperature: " + item->getText(3) + "\n"
|
||||||
" Humidity: " + item->getText(4) + "\n"
|
" Humidity: " + item->getText(4) + "\n"
|
||||||
" Pressure: " + item->getText(5)
|
" Pressure: " + item->getText(5)
|
||||||
, finalcut::FMessageBox::Ok, 0, 0, this );
|
, finalcut::FMessageBox::Ok
|
||||||
|
, finalcut::FMessageBox::Reject
|
||||||
|
, finalcut::FMessageBox::Reject
|
||||||
|
, this );
|
||||||
info.show();
|
info.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,8 @@ void Mandelbrot::draw()
|
||||||
|
|
||||||
const int xoffset{2};
|
const int xoffset{2};
|
||||||
const int yoffset{2};
|
const int yoffset{2};
|
||||||
const int Cols = int(getClientWidth());
|
const auto Cols = int(getClientWidth());
|
||||||
const int Lines = int(getClientHeight());
|
const auto Lines = int(getClientHeight());
|
||||||
int current_line{0};
|
int current_line{0};
|
||||||
|
|
||||||
if ( Cols < 2 || Lines < 2 )
|
if ( Cols < 2 || Lines < 2 )
|
||||||
|
@ -167,7 +167,7 @@ int main (int argc, char* argv[])
|
||||||
// Create a simple dialog box
|
// Create a simple dialog box
|
||||||
Mandelbrot mb{&app};
|
Mandelbrot mb{&app};
|
||||||
mb.setGeometry (FPoint{6, 1}, FSize{70, 23});
|
mb.setGeometry (FPoint{6, 1}, FSize{70, 23});
|
||||||
mb.setShadow();
|
mb.setShadow(); // Instead of the transparent window shadow
|
||||||
|
|
||||||
// Set the mandelbrot object as main widget
|
// Set the mandelbrot object as main widget
|
||||||
finalcut::FWidget::setMainWidget(&mb);
|
finalcut::FWidget::setMainWidget(&mb);
|
||||||
|
|
|
@ -151,8 +151,10 @@ Menu::Menu (finalcut::FWidget* parent)
|
||||||
// Info label
|
// Info label
|
||||||
Info << "<F10> Activate menu bar\n"
|
Info << "<F10> Activate menu bar\n"
|
||||||
<< "<Ctrl>+<Space> Activate menu bar\n"
|
<< "<Ctrl>+<Space> Activate menu bar\n"
|
||||||
|
<< "<Menu> Activate menu bar\n"
|
||||||
|
<< "<Shift>+<Menu> Open dialog menu\n"
|
||||||
<< "<Meta>+<X> Exit";
|
<< "<Meta>+<X> Exit";
|
||||||
Info.setGeometry(FPoint{2, 1}, FSize{36, 3});
|
Info.setGeometry(FPoint{2, 1}, FSize{36, 5});
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -291,8 +293,8 @@ void Menu::defaultCallback (const finalcut::FMenuList* mb)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void Menu::adjustSize()
|
void Menu::adjustSize()
|
||||||
{
|
{
|
||||||
const int pw = int(getDesktopWidth());
|
const auto pw = int(getDesktopWidth());
|
||||||
const int ph = int(getDesktopHeight());
|
const auto ph = int(getDesktopHeight());
|
||||||
setX (1 + (pw - int(getWidth())) / 2, false);
|
setX (1 + (pw - int(getWidth())) / 2, false);
|
||||||
setY (1 + (ph - int(getHeight())) / 4, false);
|
setY (1 + (ph - int(getHeight())) / 4, false);
|
||||||
finalcut::FDialog::adjustSize();
|
finalcut::FDialog::adjustSize();
|
||||||
|
@ -327,8 +329,7 @@ int main (int argc, char* argv[])
|
||||||
// Create main dialog object
|
// Create main dialog object
|
||||||
Menu main_dlg {&app};
|
Menu main_dlg {&app};
|
||||||
main_dlg.setText ("Menu example");
|
main_dlg.setText ("Menu example");
|
||||||
main_dlg.setGeometry ( FPoint{int(1 + (app.getWidth() - 40) / 2), 2}
|
main_dlg.setSize ({40, 8});
|
||||||
, FSize{40, 6} );
|
|
||||||
main_dlg.setShadow();
|
main_dlg.setShadow();
|
||||||
|
|
||||||
// Set dialog main_dlg as main widget
|
// Set dialog main_dlg as main widget
|
||||||
|
|
|
@ -428,7 +428,7 @@ void MouseDraw::onClose (finalcut::FCloseEvent* ev)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void MouseDraw::draw()
|
void MouseDraw::draw()
|
||||||
{
|
{
|
||||||
const int y_max = int(getHeight());
|
const auto y_max = int(getHeight());
|
||||||
finalcut::FDialog::draw();
|
finalcut::FDialog::draw();
|
||||||
setColor();
|
setColor();
|
||||||
|
|
||||||
|
@ -463,8 +463,8 @@ void MouseDraw::draw()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void MouseDraw::drawBrush (int x, int y, bool swap_color)
|
void MouseDraw::drawBrush (int x, int y, bool swap_color)
|
||||||
{
|
{
|
||||||
const int Cols = int(getWidth());
|
const auto Cols = int(getWidth());
|
||||||
const int Lines = int(getHeight());
|
const auto Lines = int(getHeight());
|
||||||
|
|
||||||
if ( x > 10 && x < Cols && y > 2 && y < Lines )
|
if ( x > 10 && x < Cols && y > 2 && y < Lines )
|
||||||
{
|
{
|
||||||
|
@ -537,8 +537,8 @@ void MouseDraw::adjustSize()
|
||||||
{
|
{
|
||||||
const std::size_t w{60};
|
const std::size_t w{60};
|
||||||
const std::size_t h{18};
|
const std::size_t h{18};
|
||||||
const int x = 1 + int((getParentWidget()->getWidth() - w) / 2);
|
const int x = 1 + int((getDesktopWidth() - w) / 2);
|
||||||
const int y = 1 + int((getParentWidget()->getHeight() - h) / 2);
|
const int y = 1 + int((getDesktopHeight() - h) / 2);
|
||||||
setGeometry (FPoint{x, y}, FSize{w, h}, false);
|
setGeometry (FPoint{x, y}, FSize{w, h}, false);
|
||||||
finalcut::FDialog::adjustSize();
|
finalcut::FDialog::adjustSize();
|
||||||
}
|
}
|
||||||
|
@ -590,7 +590,6 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
// Create a simple dialog box
|
// Create a simple dialog box
|
||||||
MouseDraw mouse_draw{&app};
|
MouseDraw mouse_draw{&app};
|
||||||
mouse_draw.setGeometry (FPoint{12, 4}, FSize{60, 18});
|
|
||||||
|
|
||||||
// Set dialog object mouse_draw as main widget
|
// Set dialog object mouse_draw as main widget
|
||||||
finalcut::FWidget::setMainWidget(&mouse_draw);
|
finalcut::FWidget::setMainWidget(&mouse_draw);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -65,8 +66,8 @@ bool keyPressed()
|
||||||
void term_boundaries (int& x, int& y)
|
void term_boundaries (int& x, int& y)
|
||||||
{
|
{
|
||||||
// checks and corrects the terminal boundaries
|
// checks and corrects the terminal boundaries
|
||||||
const int term_width = int(app->getDesktopWidth());
|
const auto term_width = int(app->getDesktopWidth());
|
||||||
const int term_height = int(app->getDesktopHeight());
|
const auto term_height = int(app->getDesktopHeight());
|
||||||
|
|
||||||
if ( x < 0 )
|
if ( x < 0 )
|
||||||
x = 0;
|
x = 0;
|
||||||
|
@ -93,14 +94,15 @@ void move (int xold, int yold, int xnew, int ynew)
|
||||||
finalcut::FString from{};
|
finalcut::FString from{};
|
||||||
finalcut::FString to{};
|
finalcut::FString to{};
|
||||||
finalcut::FString byte{};
|
finalcut::FString byte{};
|
||||||
const std::string ctrl_character[] =
|
|
||||||
{
|
constexpr std::array<const char*, 33> ctrl_character =
|
||||||
|
{{
|
||||||
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
|
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
|
||||||
"BS", "Tab", "LF", "VT", "FF", "CR", "SO", "SI",
|
"BS", "Tab", "LF", "VT", "FF", "CR", "SO", "SI",
|
||||||
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
|
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
|
||||||
"CAN", "EM", "SUB", "Esc", "FS", "GS", "RS", "US",
|
"CAN", "EM", "SUB", "Esc", "FS", "GS", "RS", "US",
|
||||||
"Space"
|
"Space"
|
||||||
};
|
}};
|
||||||
|
|
||||||
term_boundaries(xold, yold);
|
term_boundaries(xold, yold);
|
||||||
term_boundaries(xnew, ynew);
|
term_boundaries(xnew, ynew);
|
||||||
|
@ -209,8 +211,11 @@ DirectLogger::~DirectLogger() // destructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int main (int argc, char* argv[])
|
int main (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// Disable mouse
|
// Disable mouse, color palette changes and terminal data requests
|
||||||
finalcut::FStartOptions::getFStartOptions().mouse_support = false;
|
auto& start_options = finalcut::FStartOptions::getFStartOptions();
|
||||||
|
start_options.mouse_support = false;
|
||||||
|
start_options.color_change = false;
|
||||||
|
start_options.terminal_data_request = false;
|
||||||
|
|
||||||
// Create the application object
|
// Create the application object
|
||||||
finalcut::FApplication term_app{argc, argv};
|
finalcut::FApplication term_app{argc, argv};
|
||||||
|
@ -225,8 +230,8 @@ int main (int argc, char* argv[])
|
||||||
app = &term_app;
|
app = &term_app;
|
||||||
|
|
||||||
// Get screen dimension
|
// Get screen dimension
|
||||||
int xmax = int(term_app.getDesktopWidth() - 1);
|
auto xmax = int(term_app.getDesktopWidth() - 1);
|
||||||
int ymax = int(term_app.getDesktopHeight() - 1);
|
auto ymax = int(term_app.getDesktopHeight() - 1);
|
||||||
finalcut::FString line{std::size_t(xmax) + 1, '-'};
|
finalcut::FString line{std::size_t(xmax) + 1, '-'};
|
||||||
|
|
||||||
// Place the cursor in the upper left corner
|
// Place the cursor in the upper left corner
|
||||||
|
|
|
@ -20,10 +20,11 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <string>
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include <final/final.h>
|
#include <final/final.h>
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ class RotoZoomer final : public finalcut::FDialog
|
||||||
bool benchmark{false};
|
bool benchmark{false};
|
||||||
int loops{0};
|
int loops{0};
|
||||||
int path{0};
|
int path{0};
|
||||||
wchar_t data[256]{};
|
std::wstring data{std::wstring(256, L'\0')};
|
||||||
finalcut::FString report{};
|
finalcut::FString report{};
|
||||||
time_point<system_clock> start{};
|
time_point<system_clock> start{};
|
||||||
time_point<system_clock> end{};
|
time_point<system_clock> end{};
|
||||||
|
@ -89,31 +90,35 @@ RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int l)
|
||||||
{
|
{
|
||||||
FDialog::setText ("Rotozoomer effect");
|
FDialog::setText ("Rotozoomer effect");
|
||||||
|
|
||||||
int h{0};
|
std::size_t h{0};
|
||||||
|
|
||||||
for (int j{0}; j < 8; j++)
|
for (std::size_t j{0}; j < 8; j++)
|
||||||
{
|
{
|
||||||
for (int i{0}; i < 8; i++)
|
for (std::size_t i{0}; i < 8; i++)
|
||||||
{
|
{
|
||||||
data[h++] = L' ';
|
data[h] = L' ';
|
||||||
|
h++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i{0}; i < 8; i++)
|
for (std::size_t i{0}; i < 8; i++)
|
||||||
{
|
{
|
||||||
data[h++] = L'+';
|
data[h] = L'+';
|
||||||
|
h++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j{0}; j < 8; j++)
|
for (std::size_t j{0}; j < 8; j++)
|
||||||
{
|
{
|
||||||
for (int i{0}; i < 8; i++)
|
for (std::size_t i{0}; i < 8; i++)
|
||||||
{
|
{
|
||||||
data[h++] = L'x';
|
data[h] = L'x';
|
||||||
|
h++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i{0}; i < 8; i++)
|
for (std::size_t i{0}; i < 8; i++)
|
||||||
{
|
{
|
||||||
data[h++] = L' ';
|
data[h] = L' ';
|
||||||
|
h++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,24 +134,24 @@ void RotoZoomer::draw()
|
||||||
start = system_clock::now();
|
start = system_clock::now();
|
||||||
|
|
||||||
finalcut::FDialog::draw();
|
finalcut::FDialog::draw();
|
||||||
double cx = double(80.0 / 2.0 + (80.0 / 2.0 * std::sin(double(path) / 50.0)));
|
auto cx = double(80.0 / 2.0 + (80.0 / 2.0 * std::sin(double(path) / 50.0)));
|
||||||
double cy = double(23.0 + (23.0 * std::cos(double(path) / 50.0)));
|
auto cy = double(23.0 + (23.0 * std::cos(double(path) / 50.0)));
|
||||||
double r = double(128.0 + 96.0 * std::cos(double(path) / 10.0));
|
auto r = double(128.0 + 96.0 * std::cos(double(path) / 10.0));
|
||||||
double a = double(path) / 50.0;
|
auto a = double(path) / 50.0;
|
||||||
rotozoomer (cx, cy, r, a);
|
rotozoomer (cx, cy, r, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void RotoZoomer::rotozoomer (double cx, double cy, double r, double a)
|
void RotoZoomer::rotozoomer (double cx, double cy, double r, double a)
|
||||||
{
|
{
|
||||||
const int Cols = int(getClientWidth());
|
const auto Cols = int(getClientWidth());
|
||||||
const int Lines = int(getClientHeight());
|
const auto Lines = int(getClientHeight());
|
||||||
int Ax = int(4096.0 * (cx + r * std::cos(a)));
|
auto Ax = int(4096.0 * (cx + r * std::cos(a)));
|
||||||
int Ay = int(4096.0 * (cy + r * std::sin(a)));
|
auto Ay = int(4096.0 * (cy + r * std::sin(a)));
|
||||||
int Bx = int(4096.0 * (cx + r * std::cos(a + 2.02358)));
|
auto Bx = int(4096.0 * (cx + r * std::cos(a + 2.02358)));
|
||||||
int By = int(4096.0 * (cy + r * std::sin(a + 2.02358)));
|
auto By = int(4096.0 * (cy + r * std::sin(a + 2.02358)));
|
||||||
int Cx = int(4096.0 * (cx + r * std::cos(a - 1.11701)));
|
auto Cx = int(4096.0 * (cx + r * std::cos(a - 1.11701)));
|
||||||
int Cy = int(4096.0 * (cy + r * std::sin(a - 1.11701)));
|
auto Cy = int(4096.0 * (cy + r * std::sin(a - 1.11701)));
|
||||||
int dxdx = (Bx - Ax) / 80;
|
int dxdx = (Bx - Ax) / 80;
|
||||||
int dydx = (By - Ay) / 80;
|
int dydx = (By - Ay) / 80;
|
||||||
int dxdy = (Cx - Ax) / 23;
|
int dxdy = (Cx - Ax) / 23;
|
||||||
|
@ -160,7 +165,7 @@ void RotoZoomer::rotozoomer (double cx, double cy, double r, double a)
|
||||||
|
|
||||||
for (int x = 0; x < Cols; x++)
|
for (int x = 0; x < Cols; x++)
|
||||||
{
|
{
|
||||||
wchar_t ch = data[((Cy >> 14) & 0xf) + ((Cx >> 10) & 0xf0)];
|
auto ch = data[((Cy >> 14) & 0xf) + ((Cx >> 10) & 0xf0)];
|
||||||
|
|
||||||
if ( ch == '+' )
|
if ( ch == '+' )
|
||||||
print() << finalcut::FColorPair{fc::Black, fc::Red};
|
print() << finalcut::FColorPair{fc::Black, fc::Red};
|
||||||
|
@ -226,7 +231,7 @@ void RotoZoomer::onShow (finalcut::FShowEvent*)
|
||||||
end = system_clock::now();
|
end = system_clock::now();
|
||||||
generateReport();
|
generateReport();
|
||||||
flush();
|
flush();
|
||||||
quit();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +266,9 @@ void RotoZoomer::onKeyPress (finalcut::FKeyEvent* ev)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void RotoZoomer::onClose (finalcut::FCloseEvent* ev)
|
void RotoZoomer::onClose (finalcut::FCloseEvent* ev)
|
||||||
{
|
{
|
||||||
if ( ! benchmark )
|
if ( benchmark )
|
||||||
|
ev->accept();
|
||||||
|
else
|
||||||
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,6 +312,9 @@ int main (int argc, char* argv[])
|
||||||
|| strcmp(argv[1], "-b") == 0 ) )
|
|| strcmp(argv[1], "-b") == 0 ) )
|
||||||
{
|
{
|
||||||
benchmark = true;
|
benchmark = true;
|
||||||
|
// Disable terminal data requests
|
||||||
|
auto& start_options = finalcut::FStartOptions::getFStartOptions();
|
||||||
|
start_options.terminal_data_request = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Create the application object in this scope
|
{ // Create the application object in this scope
|
||||||
|
@ -317,10 +327,8 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
if ( benchmark )
|
if ( benchmark )
|
||||||
roto.setGeometry (FPoint{1, 1}, FSize{80, 24});
|
roto.setGeometry (FPoint{1, 1}, FSize{80, 24});
|
||||||
else
|
|
||||||
roto.setGeometry (FPoint{5, 1}, FSize{72, 23});
|
|
||||||
|
|
||||||
roto.setShadow();
|
roto.setShadow(); // Instead of the transparent window shadow
|
||||||
|
|
||||||
// Set the RotoZoomer object as main widget
|
// Set the RotoZoomer object as main widget
|
||||||
finalcut::FWidget::setMainWidget(&roto);
|
finalcut::FWidget::setMainWidget(&roto);
|
||||||
|
|
|
@ -118,8 +118,8 @@ Scrollview::~Scrollview()
|
||||||
void Scrollview::setScrollSize (const FSize& size)
|
void Scrollview::setScrollSize (const FSize& size)
|
||||||
{
|
{
|
||||||
FScrollView::setScrollSize (size);
|
FScrollView::setScrollSize (size);
|
||||||
const int width = int(size.getWidth());
|
const auto width = int(size.getWidth());
|
||||||
const int height = int(size.getHeight());
|
const auto height = int(size.getHeight());
|
||||||
go_south.setPos (FPoint{width - 5, 1});
|
go_south.setPos (FPoint{width - 5, 1});
|
||||||
go_west.setPos (FPoint{width - 5, height - 1});
|
go_west.setPos (FPoint{width - 5, height - 1});
|
||||||
go_north.setPos (FPoint{1, height - 1});
|
go_north.setPos (FPoint{1, height - 1});
|
||||||
|
|
|
@ -481,9 +481,9 @@ void stringSplittingExample()
|
||||||
void fromatStringExample()
|
void fromatStringExample()
|
||||||
{
|
{
|
||||||
// Test: format a string with sprintf
|
// Test: format a string with sprintf
|
||||||
finalcut::FString formatStr{""};
|
finalcut::FString format_str{""};
|
||||||
std::cout << " formatted: "
|
std::cout << " formatted: "
|
||||||
<< formatStr.sprintf("sqrt(%d) = %d", 16, 4)
|
<< format_str.sprintf("sqrt(%d) = %d", 16, 4)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ class AttribDlg final : public finalcut::FDialog
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Constants
|
// Constants
|
||||||
static constexpr FColor UNDEFINED = static_cast<FColor>(-2);
|
static constexpr auto UNDEFINED = static_cast<FColor>(-2);
|
||||||
|
|
||||||
// Method
|
// Method
|
||||||
void adjustSize() override;
|
void adjustSize() override;
|
||||||
|
@ -177,8 +177,8 @@ void AttribDlg::cb_back()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void AttribDlg::adjustSize()
|
void AttribDlg::adjustSize()
|
||||||
{
|
{
|
||||||
int x = int((getDesktopWidth() - getWidth()) / 2);
|
auto x = int((getDesktopWidth() - getWidth()) / 2);
|
||||||
int y = int((getDesktopHeight() - getHeight()) / 2) + 1;
|
auto y = int((getDesktopHeight() - getHeight()) / 2) + 1;
|
||||||
|
|
||||||
if ( x < 1 )
|
if ( x < 1 )
|
||||||
x = 1;
|
x = 1;
|
||||||
|
@ -498,9 +498,8 @@ int main (int argc, char* argv[])
|
||||||
// This object will be automatically deleted by
|
// This object will be automatically deleted by
|
||||||
// the parent object "app" (FObject destructor).
|
// the parent object "app" (FObject destructor).
|
||||||
AttribDlg dialog{&app};
|
AttribDlg dialog{&app};
|
||||||
|
dialog.setSize (FSize{69, 21});
|
||||||
dialog.setGeometry (FPoint{6, 2}, FSize{69, 21});
|
dialog.setShadow(); // Instead of the transparent window shadow
|
||||||
dialog.setShadow();
|
|
||||||
|
|
||||||
// Create the attribute demo widget as a child object from the dialog
|
// Create the attribute demo widget as a child object from the dialog
|
||||||
AttribDemo demo(&dialog);
|
AttribDemo demo(&dialog);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -42,22 +43,22 @@ void string();
|
||||||
// struct data
|
// struct data
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
struct data
|
struct Data
|
||||||
{
|
{
|
||||||
struct alignas(alignof(std::string)) termcap_string
|
struct alignas(alignof(std::string)) TermcapString
|
||||||
{
|
{
|
||||||
const std::string name;
|
const std::string name;
|
||||||
const fc::termcaps cap;
|
const fc::termcaps cap;
|
||||||
};
|
};
|
||||||
|
|
||||||
static termcap_string strings[];
|
static std::array<TermcapString, 83> strings;
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// struct data - string data array
|
// struct data - string data array
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
data::termcap_string data::strings[] =
|
std::array<Data::TermcapString, 83> Data::strings =
|
||||||
{
|
{{
|
||||||
{ "t_bell", fc::t_bell },
|
{ "t_bell", fc::t_bell },
|
||||||
{ "t_erase_chars", fc::t_erase_chars },
|
{ "t_erase_chars", fc::t_erase_chars },
|
||||||
{ "t_clear_screen", fc::t_clear_screen },
|
{ "t_clear_screen", fc::t_clear_screen },
|
||||||
|
@ -99,6 +100,7 @@ data::termcap_string data::strings[] =
|
||||||
{ "t_parm_right_cursor", fc::t_parm_right_cursor },
|
{ "t_parm_right_cursor", fc::t_parm_right_cursor },
|
||||||
{ "t_save_cursor", fc::t_save_cursor },
|
{ "t_save_cursor", fc::t_save_cursor },
|
||||||
{ "t_restore_cursor", fc::t_restore_cursor },
|
{ "t_restore_cursor", fc::t_restore_cursor },
|
||||||
|
{ "t_cursor_style", fc::t_cursor_style },
|
||||||
{ "t_scroll_forward", fc::t_scroll_forward },
|
{ "t_scroll_forward", fc::t_scroll_forward },
|
||||||
{ "t_scroll_reverse", fc::t_scroll_reverse },
|
{ "t_scroll_reverse", fc::t_scroll_reverse },
|
||||||
{ "t_enter_ca_mode", fc::t_enter_ca_mode },
|
{ "t_enter_ca_mode", fc::t_enter_ca_mode },
|
||||||
|
@ -140,7 +142,7 @@ data::termcap_string data::strings[] =
|
||||||
{ "t_keypad_xmit", fc::t_keypad_xmit },
|
{ "t_keypad_xmit", fc::t_keypad_xmit },
|
||||||
{ "t_keypad_local", fc::t_keypad_local },
|
{ "t_keypad_local", fc::t_keypad_local },
|
||||||
{ "t_key_mouse", fc::t_key_mouse }
|
{ "t_key_mouse", fc::t_key_mouse }
|
||||||
};
|
}};
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -174,11 +176,11 @@ void tcapString (const std::string& name, const char cap_str[])
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uInt len = uInt(std::strlen(cap_str));
|
const auto len = uInt(std::strlen(cap_str));
|
||||||
|
|
||||||
for (uInt i{0}; i < len; i++)
|
for (uInt i{0}; i < len; i++)
|
||||||
{
|
{
|
||||||
const uChar c = uChar(cap_str[i]);
|
const auto c = uChar(cap_str[i]);
|
||||||
|
|
||||||
if ( c > 127 )
|
if ( c > 127 )
|
||||||
{
|
{
|
||||||
|
@ -282,10 +284,9 @@ void numeric()
|
||||||
void string()
|
void string()
|
||||||
{
|
{
|
||||||
std::cout << "\r\n[String]\r\n";
|
std::cout << "\r\n[String]\r\n";
|
||||||
const finalcut::FTermcap::tcap_map (&tcap_strings)[] \
|
const auto& tcap_strings = finalcut::FTermcap::strings;
|
||||||
= finalcut::FTermcap::strings;
|
|
||||||
|
|
||||||
for (const auto& entry : data::strings)
|
for (const auto& entry : Data::strings)
|
||||||
{
|
{
|
||||||
const std::string name = entry.name;
|
const std::string name = entry.name;
|
||||||
const fc::termcaps cap = entry.cap;
|
const fc::termcaps cap = entry.cap;
|
||||||
|
|
|
@ -213,7 +213,7 @@ MainWindow::MainWindow (finalcut::FWidget* parent)
|
||||||
ibg->unsetTransparentShadow();
|
ibg->unsetTransparentShadow();
|
||||||
|
|
||||||
// Set statusbar text for this window
|
// Set statusbar text for this window
|
||||||
setStatusbarMessage("Press Q to quit");
|
FDialog::setStatusbarMessage("Press Q to quit");
|
||||||
|
|
||||||
unsetTransparentShadow();
|
unsetTransparentShadow();
|
||||||
activateDialog();
|
activateDialog();
|
||||||
|
@ -256,12 +256,11 @@ void MainWindow::onShow (finalcut::FShowEvent*)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void MainWindow::onTimer (finalcut::FTimerEvent*)
|
void MainWindow::onTimer (finalcut::FTimerEvent*)
|
||||||
{
|
{
|
||||||
wchar_t first_Char[2];
|
|
||||||
std::size_t length = line1.getLength();
|
std::size_t length = line1.getLength();
|
||||||
first_Char[0] = line1[0];
|
const wchar_t first_char1 = line1[0];
|
||||||
first_Char[1] = line2[0];
|
const wchar_t first_char2 = line2[0];
|
||||||
line1 = line1.right(length - 1) + first_Char[0];
|
line1 = line1.right(length - 1) + first_char1;
|
||||||
line2 = line2.right(length - 1) + first_Char[1];
|
line2 = line2.right(length - 1) + first_char2;
|
||||||
redraw();
|
redraw();
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ using finalcut::FSize;
|
||||||
|
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
sInt64 StringToNumber (const finalcut::FString&);
|
sInt64 stringToNumber (const finalcut::FString&);
|
||||||
bool sortAscending (const finalcut::FObject*, const finalcut::FObject*);
|
bool sortAscending (const finalcut::FObject*, const finalcut::FObject*);
|
||||||
bool sortDescending (const finalcut::FObject*, const finalcut::FObject*);
|
bool sortDescending (const finalcut::FObject*, const finalcut::FObject*);
|
||||||
bool isLessThanInteger (const finalcut::FString&, const finalcut::FString&);
|
bool isLessThanInteger (const finalcut::FString&, const finalcut::FString&);
|
||||||
|
@ -44,13 +44,13 @@ bool isGreaterThanDouble (const finalcut::FString&, const finalcut::FString&);
|
||||||
|
|
||||||
// non-member functions
|
// non-member functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
sInt64 StringToNumber (const finalcut::FString& str)
|
sInt64 stringToNumber (const finalcut::FString& str)
|
||||||
{
|
{
|
||||||
// Cut off one character (because LONG_MAX = 2147483647)
|
// Cut off one character (because LONG_MAX = 2147483647)
|
||||||
auto NumString = str.left(str.getLength() - 1);
|
auto num_string = str.left(str.getLength() - 1);
|
||||||
NumString = NumString.replace(",", "");
|
num_string = num_string.replace(",", "");
|
||||||
NumString = NumString.replace('.', "");
|
num_string = num_string.replace('.', "");
|
||||||
sInt64 number = sInt64(NumString.toLong());
|
auto number = sInt64(num_string.toLong());
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +58,8 @@ sInt64 StringToNumber (const finalcut::FString& str)
|
||||||
inline bool isLessThanInteger ( const finalcut::FString& lhs
|
inline bool isLessThanInteger ( const finalcut::FString& lhs
|
||||||
, const finalcut::FString& rhs )
|
, const finalcut::FString& rhs )
|
||||||
{
|
{
|
||||||
const sInt64 l_number = StringToNumber(lhs);
|
const sInt64 l_number = stringToNumber(lhs);
|
||||||
const sInt64 r_number = StringToNumber(rhs);
|
const sInt64 r_number = stringToNumber(rhs);
|
||||||
return bool( l_number < r_number ); // lhs < rhs
|
return bool( l_number < r_number ); // lhs < rhs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +77,8 @@ inline bool isLessThanDouble ( const finalcut::FString& lhs
|
||||||
inline bool isGreaterThanInteger ( const finalcut::FString& lhs
|
inline bool isGreaterThanInteger ( const finalcut::FString& lhs
|
||||||
, const finalcut::FString& rhs )
|
, const finalcut::FString& rhs )
|
||||||
{
|
{
|
||||||
const sInt64 l_number = StringToNumber(lhs);
|
const sInt64 l_number = stringToNumber(lhs);
|
||||||
const sInt64 r_number = StringToNumber(rhs);
|
const sInt64 r_number = stringToNumber(rhs);
|
||||||
return bool( l_number > r_number ); // lhs > rhs
|
return bool( l_number > r_number ); // lhs > rhs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,8 +168,8 @@ class Treeview final : public finalcut::FDialog
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
bool initialized{false};
|
bool initialized{false};
|
||||||
finalcut::FListView listView{this};
|
finalcut::FListView listview{this};
|
||||||
finalcut::FButton Quit{this};
|
finalcut::FButton quit{this};
|
||||||
static TreeItem africa[];
|
static TreeItem africa[];
|
||||||
static TreeItem asia[];
|
static TreeItem asia[];
|
||||||
static TreeItem europe[];
|
static TreeItem europe[];
|
||||||
|
@ -329,26 +329,26 @@ Treeview::Treeview (finalcut::FWidget* parent)
|
||||||
: finalcut::FDialog{parent}
|
: finalcut::FDialog{parent}
|
||||||
{
|
{
|
||||||
// Set FListView geometry
|
// Set FListView geometry
|
||||||
listView.setGeometry(FPoint{2, 1}, FSize{53, 14});
|
listview.setGeometry(FPoint{2, 1}, FSize{53, 14});
|
||||||
|
|
||||||
// Add columns to the view
|
// Add columns to the view
|
||||||
listView.addColumn ("Name", 23);
|
listview.addColumn ("Name", 23);
|
||||||
listView.addColumn ("Population");
|
listview.addColumn ("Population");
|
||||||
listView.addColumn ("Density/km²");
|
listview.addColumn ("Density/km²");
|
||||||
|
|
||||||
// Set right alignment for the second and third column
|
// Set right alignment for the second and third column
|
||||||
listView.setColumnAlignment (2, fc::alignRight);
|
listview.setColumnAlignment (2, fc::alignRight);
|
||||||
listView.setColumnAlignment (3, fc::alignRight);
|
listview.setColumnAlignment (3, fc::alignRight);
|
||||||
|
|
||||||
// Set the type of sorting
|
// Set the type of sorting
|
||||||
listView.setColumnSortType (1, fc::by_name);
|
listview.setColumnSortType (1, fc::by_name);
|
||||||
listView.setColumnSortType (2, fc::user_defined);
|
listview.setColumnSortType (2, fc::user_defined);
|
||||||
listView.setColumnSortType (3, fc::user_defined);
|
listview.setColumnSortType (3, fc::user_defined);
|
||||||
listView.setUserAscendingCompare(sortAscending);
|
listview.setUserAscendingCompare(sortAscending);
|
||||||
listView.setUserDescendingCompare(sortDescending);
|
listview.setUserDescendingCompare(sortDescending);
|
||||||
|
|
||||||
// Activate tree view
|
// Activate tree view
|
||||||
listView.setTreeView();
|
listview.setTreeView();
|
||||||
|
|
||||||
// Populate FListView with a list of items
|
// Populate FListView with a list of items
|
||||||
static TreeItem continent_list[] =
|
static TreeItem continent_list[] =
|
||||||
|
@ -367,23 +367,23 @@ Treeview::Treeview (finalcut::FWidget* parent)
|
||||||
const TreeItem* country_list = continent.child_element;
|
const TreeItem* country_list = continent.child_element;
|
||||||
finalcut::FStringList continent_line ( continent.begin()
|
finalcut::FStringList continent_line ( continent.begin()
|
||||||
, continent.end() );
|
, continent.end() );
|
||||||
auto iter = listView.insert (continent_line);
|
auto iter = listview.insert (continent_line);
|
||||||
|
|
||||||
while ( country_list && country_list->name )
|
while ( country_list && country_list->name )
|
||||||
{
|
{
|
||||||
finalcut::FStringList country_line ( country_list->begin()
|
finalcut::FStringList country_line ( country_list->begin()
|
||||||
, country_list->end() );
|
, country_list->end() );
|
||||||
listView.insert (country_line, iter);
|
listview.insert (country_line, iter);
|
||||||
country_list++;
|
country_list++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quit button
|
// quit button
|
||||||
Quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||||
Quit.setText (L"&Quit");
|
quit.setText (L"&Quit");
|
||||||
|
|
||||||
// Callback function
|
// Callback function
|
||||||
Quit.addCallback
|
quit.addCallback
|
||||||
(
|
(
|
||||||
"clicked",
|
"clicked",
|
||||||
finalcut::getFApplication(),
|
finalcut::getFApplication(),
|
||||||
|
@ -401,22 +401,22 @@ Treeview::~Treeview() // destructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void Treeview::adjustSize()
|
void Treeview::adjustSize()
|
||||||
{
|
{
|
||||||
|
finalcut::FDialog::adjustSize();
|
||||||
|
|
||||||
std::size_t h = getDesktopHeight() - 4;
|
std::size_t h = getDesktopHeight() - 4;
|
||||||
setHeight (h, false);
|
setHeight (h, false);
|
||||||
int X = int((getDesktopWidth() - getWidth()) / 2);
|
auto x = int((getDesktopWidth() - getWidth()) / 2);
|
||||||
|
|
||||||
if ( X < 1 )
|
if ( x < 1 )
|
||||||
X = 1;
|
x = 1;
|
||||||
|
|
||||||
setX (X, false);
|
setPos (FPoint{x, 3}, false);
|
||||||
|
|
||||||
if ( initialized )
|
if ( initialized )
|
||||||
{
|
{
|
||||||
listView.setHeight (getHeight() - 6, false);
|
listview.setHeight (getHeight() - 6, true);
|
||||||
Quit.setY(int(getHeight()) - 4);
|
quit.setY(int(getHeight()) - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
finalcut::FDialog::adjustSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -438,8 +438,7 @@ int main (int argc, char* argv[])
|
||||||
// Create main dialog object
|
// Create main dialog object
|
||||||
Treeview d{&app};
|
Treeview d{&app};
|
||||||
d.setText (L"Continents");
|
d.setText (L"Continents");
|
||||||
d.setGeometry ( FPoint{int(1 + (app.getWidth() - 57) / 2), 3}
|
d.setSize (FSize{57, 20});
|
||||||
, FSize{57, 20} );
|
|
||||||
d.setShadow();
|
d.setShadow();
|
||||||
|
|
||||||
// Set dialog d as main widget
|
// Set dialog d as main widget
|
||||||
|
|
|
@ -68,7 +68,7 @@ class ProgressDialog final : public finalcut::FDialog
|
||||||
void cb_exit_bar();
|
void cb_exit_bar();
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
finalcut::FProgressbar progressBar{this};
|
finalcut::FProgressbar progressbar{this};
|
||||||
finalcut::FButton reset{this};
|
finalcut::FButton reset{this};
|
||||||
finalcut::FButton more{this};
|
finalcut::FButton more{this};
|
||||||
finalcut::FButton quit{this};
|
finalcut::FButton quit{this};
|
||||||
|
@ -100,8 +100,8 @@ ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
|
||||||
quit.setGeometry(FPoint{28, 6}, FSize{8, 1}, false);
|
quit.setGeometry(FPoint{28, 6}, FSize{8, 1}, false);
|
||||||
quit.setDisable();
|
quit.setDisable();
|
||||||
|
|
||||||
progressBar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
|
progressbar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
|
||||||
//progressBar.setPercentage(78);
|
//progressbar.setPercentage(78);
|
||||||
|
|
||||||
reset.addCallback
|
reset.addCallback
|
||||||
(
|
(
|
||||||
|
@ -140,9 +140,9 @@ void ProgressDialog::onShow (finalcut::FShowEvent*)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void ProgressDialog::onTimer (finalcut::FTimerEvent*)
|
void ProgressDialog::onTimer (finalcut::FTimerEvent*)
|
||||||
{
|
{
|
||||||
auto p = progressBar.getPercentage();
|
auto p = progressbar.getPercentage();
|
||||||
p++;
|
p++;
|
||||||
progressBar.setPercentage(p);
|
progressbar.setPercentage(p);
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
if ( p != 100 )
|
if ( p != 100 )
|
||||||
|
@ -167,15 +167,15 @@ void ProgressDialog::onTimer (finalcut::FTimerEvent*)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void ProgressDialog::cb_reset_bar()
|
void ProgressDialog::cb_reset_bar()
|
||||||
{
|
{
|
||||||
progressBar.reset();
|
progressbar.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void ProgressDialog::cb_more_bar()
|
void ProgressDialog::cb_more_bar()
|
||||||
{
|
{
|
||||||
auto p = progressBar.getPercentage();
|
auto p = progressbar.getPercentage();
|
||||||
p++;
|
p++;
|
||||||
progressBar.setPercentage(p);
|
progressbar.setPercentage(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -212,25 +212,25 @@ class TextWindow final : public finalcut::FDialog
|
||||||
void adjustSize() override;
|
void adjustSize() override;
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
finalcut::FTextView scrollText{this};
|
finalcut::FTextView scrolltext{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
TextWindow::TextWindow (finalcut::FWidget* parent)
|
TextWindow::TextWindow (finalcut::FWidget* parent)
|
||||||
: finalcut::FDialog{parent}
|
: finalcut::FDialog{parent}
|
||||||
{
|
{
|
||||||
scrollText.ignorePadding();
|
scrolltext.ignorePadding();
|
||||||
scrollText.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||||
setMinimumSize (FSize{51, 6});
|
setMinimumSize (FSize{51, 6});
|
||||||
scrollText.setFocus();
|
scrolltext.setFocus();
|
||||||
scrollText.insert(" -----------------------------------------------\n"
|
scrolltext.insert(" -----------------------------------------------\n"
|
||||||
" line 1\n"
|
" line 1\n"
|
||||||
" -----------------------------------------------\n"
|
" -----------------------------------------------\n"
|
||||||
" line 3\n"
|
" line 3\n"
|
||||||
" line 4"
|
" line 4"
|
||||||
, -1);
|
, -1);
|
||||||
scrollText.replaceRange(" File viewer", 1, 1);
|
scrolltext.replaceRange(" File viewer", 1, 1);
|
||||||
scrollText.deleteRange(3, 4);
|
scrolltext.deleteRange(3, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -240,14 +240,14 @@ TextWindow::~TextWindow() // destructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void TextWindow::append (const finalcut::FString& str)
|
void TextWindow::append (const finalcut::FString& str)
|
||||||
{
|
{
|
||||||
scrollText.append(str);
|
scrolltext.append(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void TextWindow::adjustSize()
|
void TextWindow::adjustSize()
|
||||||
{
|
{
|
||||||
finalcut::FDialog::adjustSize();
|
finalcut::FDialog::adjustSize();
|
||||||
scrollText.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
|
scrolltext.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -305,8 +305,7 @@ class MyDialog final : public finalcut::FDialog
|
||||||
, const finalcut::FLineEdit& ) const;
|
, const finalcut::FLineEdit& ) const;
|
||||||
void cb_setTitlebar (const finalcut::FLineEdit&);
|
void cb_setTitlebar (const finalcut::FLineEdit&);
|
||||||
void cb_showProgressBar();
|
void cb_showProgressBar();
|
||||||
void cb_updateNumber ( const finalcut::FListBox&
|
void cb_updateNumber();
|
||||||
, finalcut::FLabel& ) const;
|
|
||||||
void cb_activateButton ( const finalcut::FRadioButton&
|
void cb_activateButton ( const finalcut::FRadioButton&
|
||||||
, finalcut::FButton& ) const;
|
, finalcut::FButton& ) const;
|
||||||
void cb_view (const finalcut::FMenuItem*);
|
void cb_view (const finalcut::FMenuItem*);
|
||||||
|
@ -774,27 +773,25 @@ void MyDialog::initWidgetsCallbacks()
|
||||||
myList.addCallback
|
myList.addCallback
|
||||||
(
|
(
|
||||||
"row-selected",
|
"row-selected",
|
||||||
this, &MyDialog::cb_updateNumber,
|
this, &MyDialog::cb_updateNumber
|
||||||
std::ref(myList), std::ref(tagged_count)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void MyDialog::adjustSize()
|
void MyDialog::adjustSize()
|
||||||
{
|
{
|
||||||
const auto h = getParentWidget()->getHeight() - 4;
|
const auto h = getDesktopHeight() - 4;
|
||||||
setHeight (h, false);
|
setHeight (h, false);
|
||||||
int X = int((getDesktopWidth() - getWidth()) / 2);
|
finalcut::FDialog::adjustSize(); // with new client area size
|
||||||
|
auto x = int((getDesktopWidth() - getWidth()) / 2);
|
||||||
|
|
||||||
if ( X < 1 )
|
if ( x < 1 )
|
||||||
X = 1;
|
x = 1;
|
||||||
|
|
||||||
setX (X, false);
|
setPos (FPoint{x, 2}, false);
|
||||||
|
|
||||||
if ( initialized )
|
if ( initialized )
|
||||||
myList.setHeight (getHeight() - 3, false);
|
myList.setHeight (h - 3, true);
|
||||||
|
|
||||||
finalcut::FDialog::adjustSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -823,7 +820,10 @@ void MyDialog::cb_about()
|
||||||
, line + L" FINAL CUT " + line + L"\n\n"
|
, line + L" FINAL CUT " + line + L"\n\n"
|
||||||
L"Version " + libver + L"\n\n"
|
L"Version " + libver + L"\n\n"
|
||||||
L"(c) 2020 by Markus Gans"
|
L"(c) 2020 by Markus Gans"
|
||||||
, finalcut::FMessageBox::Ok, 0, 0, this );
|
, finalcut::FMessageBox::Ok
|
||||||
|
, finalcut::FMessageBox::Reject
|
||||||
|
, finalcut::FMessageBox::Reject
|
||||||
|
, this );
|
||||||
info.setCenterText();
|
info.setCenterText();
|
||||||
info.show();
|
info.show();
|
||||||
}
|
}
|
||||||
|
@ -843,7 +843,10 @@ void MyDialog::cb_terminfo()
|
||||||
<< " Size: " << x << fc::Times
|
<< " Size: " << x << fc::Times
|
||||||
<< y << "\n"
|
<< y << "\n"
|
||||||
<< "Colors: " << finalcut::FTerm::getMaxColor()
|
<< "Colors: " << finalcut::FTerm::getMaxColor()
|
||||||
, finalcut::FMessageBox::Ok, 0, 0, this
|
, finalcut::FMessageBox::Ok
|
||||||
|
, finalcut::FMessageBox::Reject
|
||||||
|
, finalcut::FMessageBox::Reject
|
||||||
|
, this
|
||||||
);
|
);
|
||||||
info1.setHeadline("Terminal:");
|
info1.setHeadline("Terminal:");
|
||||||
info1.exec();
|
info1.exec();
|
||||||
|
@ -858,7 +861,10 @@ void MyDialog::cb_drives()
|
||||||
, "Generic: \n\n"
|
, "Generic: \n\n"
|
||||||
"Network: \n\n"
|
"Network: \n\n"
|
||||||
" CD:"
|
" CD:"
|
||||||
, finalcut::FMessageBox::Ok, 0, 0, this
|
, finalcut::FMessageBox::Ok
|
||||||
|
, finalcut::FMessageBox::Reject
|
||||||
|
, finalcut::FMessageBox::Reject
|
||||||
|
, this
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( finalcut::FTerm::isNewFont() )
|
if ( finalcut::FTerm::isNewFont() )
|
||||||
|
@ -968,19 +974,17 @@ void MyDialog::cb_showProgressBar()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void MyDialog::cb_updateNumber ( const finalcut::FListBox& list
|
void MyDialog::cb_updateNumber()
|
||||||
, finalcut::FLabel& num) const
|
|
||||||
{
|
{
|
||||||
const auto count = list.getCount();
|
|
||||||
int select_num = 0;
|
int select_num = 0;
|
||||||
|
|
||||||
for (std::size_t n{1}; n <= count; n++)
|
for (auto&& item : myList.getData() )
|
||||||
if ( list.isSelected(n) )
|
if ( item.isSelected() )
|
||||||
select_num++;
|
select_num++;
|
||||||
|
|
||||||
num.clear();
|
tagged_count.clear();
|
||||||
num << select_num;
|
tagged_count << select_num;
|
||||||
num.redraw();
|
tagged_count.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1057,9 +1061,8 @@ int main (int argc, char* argv[])
|
||||||
// Create main dialog object d
|
// Create main dialog object d
|
||||||
MyDialog d{&app};
|
MyDialog d{&app};
|
||||||
d.setText (title);
|
d.setText (title);
|
||||||
d.setGeometry ( FPoint{int((app.getWidth() - 56) / 2), 2}
|
d.setSize (FSize{56, app.getHeight() - 4});
|
||||||
, FSize{56, app.getHeight() - 4} );
|
d.setShadow(); // Instead of the transparent window shadow
|
||||||
d.setShadow();
|
|
||||||
|
|
||||||
// Set the dialog object d as the main widget of the application.
|
// Set the dialog object d as the main widget of the application.
|
||||||
// When you close the main widget, the application will be closed.
|
// When you close the main widget, the application will be closed.
|
||||||
|
|
|
@ -79,8 +79,7 @@ Watch::Watch (FWidget* parent)
|
||||||
// Avoids calling a virtual function from the constructor
|
// Avoids calling a virtual function from the constructor
|
||||||
// (CERT, OOP50-CPP)
|
// (CERT, OOP50-CPP)
|
||||||
FDialog::setText ("Watch");
|
FDialog::setText ("Watch");
|
||||||
const int pw = int(getParentWidget()->getWidth());
|
FDialog::setSize ({22, 13});
|
||||||
FDialog::setGeometry (FPoint{1 + (pw - 22) / 2, 3}, FSize{22, 13});
|
|
||||||
|
|
||||||
// Labels
|
// Labels
|
||||||
time_label.setGeometry(FPoint{5, 2}, FSize{5, 1});
|
time_label.setGeometry(FPoint{5, 2}, FSize{5, 1});
|
||||||
|
@ -193,8 +192,9 @@ void Watch::cb_seconds()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void Watch::adjustSize()
|
void Watch::adjustSize()
|
||||||
{
|
{
|
||||||
const int pw = int(getParentWidget()->getWidth());
|
const auto pw = int(getDesktopWidth());
|
||||||
setX (1 + (pw - 22) / 2, false);
|
setX (1 + (pw - 22) / 2, false);
|
||||||
|
setY (3, false);
|
||||||
finalcut::FDialog::adjustSize();
|
finalcut::FDialog::adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ void SmallWindow::adjustSize()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
top_right_label = "zoom";
|
top_right_label = "zoom";
|
||||||
bottom_label.setVisible();
|
bottom_label.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
finalcut::FDialog::adjustSize();
|
finalcut::FDialog::adjustSize();
|
||||||
|
@ -199,7 +199,9 @@ class Window final : public finalcut::FDialog
|
||||||
void configureDialogButtons();
|
void configureDialogButtons();
|
||||||
void activateWindow (finalcut::FDialog*) const;
|
void activateWindow (finalcut::FDialog*) const;
|
||||||
void adjustSize() override;
|
void adjustSize() override;
|
||||||
template<typename InstanceT, typename CallbackT, typename... Args>
|
template <typename InstanceT
|
||||||
|
, typename CallbackT
|
||||||
|
, typename... Args>
|
||||||
void addClickedCallback ( finalcut::FWidget*
|
void addClickedCallback ( finalcut::FWidget*
|
||||||
, InstanceT&&, CallbackT&&, Args&&... );
|
, InstanceT&&, CallbackT&&, Args&&... );
|
||||||
template <typename IteratorT>
|
template <typename IteratorT>
|
||||||
|
@ -241,6 +243,8 @@ class Window final : public finalcut::FDialog
|
||||||
Window::Window (finalcut::FWidget* parent)
|
Window::Window (finalcut::FWidget* parent)
|
||||||
: finalcut::FDialog{parent}
|
: finalcut::FDialog{parent}
|
||||||
{
|
{
|
||||||
|
FDialog::setSize ({40, 6});
|
||||||
|
|
||||||
// Menu bar item
|
// Menu bar item
|
||||||
File.setStatusbarMessage ("File management commands");
|
File.setStatusbarMessage ("File management commands");
|
||||||
|
|
||||||
|
@ -257,10 +261,10 @@ Window::Window (finalcut::FWidget* parent)
|
||||||
Statusbar.setMessage("Status bar message");
|
Statusbar.setMessage("Status bar message");
|
||||||
|
|
||||||
// Generate data vector for the windows
|
// Generate data vector for the windows
|
||||||
for (int n{1}; n <= 6; n++)
|
for (uInt n{1}; n < 7; n++)
|
||||||
{
|
{
|
||||||
auto win_dat = new win_data;
|
auto win_dat = new win_data;
|
||||||
win_dat->title.sprintf("Window %1d", n);
|
win_dat->title.sprintf("Window %1u", n);
|
||||||
windows.push_back(win_dat);
|
windows.push_back(win_dat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,10 +351,12 @@ void Window::activateWindow (finalcut::FDialog* win) const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void Window::adjustSize()
|
void Window::adjustSize()
|
||||||
{
|
{
|
||||||
|
finalcut::FDialog::adjustSize();
|
||||||
|
|
||||||
const std::size_t w = getDesktopWidth();
|
const std::size_t w = getDesktopWidth();
|
||||||
const std::size_t h = getDesktopHeight();
|
const std::size_t h = getDesktopHeight();
|
||||||
const int X = int(1 + (w - 40) / 2);
|
const auto X = int(1 + (w - 40) / 2);
|
||||||
int Y = int(1 + (h - 22) / 2);
|
auto Y = int(1 + (h - 22) / 2);
|
||||||
const int dx = ( w > 80 ) ? int(w - 80) / 2 : 0;
|
const int dx = ( w > 80 ) ? int(w - 80) / 2 : 0;
|
||||||
const int dy = ( h > 24 ) ? int(h - 24) / 2 : 0;
|
const int dy = ( h > 24 ) ? int(h - 24) / 2 : 0;
|
||||||
|
|
||||||
|
@ -365,7 +371,7 @@ void Window::adjustSize()
|
||||||
{
|
{
|
||||||
if ( (*iter)->is_open )
|
if ( (*iter)->is_open )
|
||||||
{
|
{
|
||||||
const int n = int(std::distance(first, iter));
|
const auto n = int(std::distance(first, iter));
|
||||||
const int x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
|
const int x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
|
||||||
const int y = dy + 11 + int(n / 3) * 3;
|
const int y = dy + 11 + int(n / 3) * 3;
|
||||||
(*iter)->dgl->setPos (FPoint{x, y});
|
(*iter)->dgl->setPos (FPoint{x, y});
|
||||||
|
@ -373,12 +379,12 @@ void Window::adjustSize()
|
||||||
|
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
finalcut::FDialog::adjustSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename InstanceT, typename CallbackT, typename... Args>
|
template <typename InstanceT
|
||||||
|
, typename CallbackT
|
||||||
|
, typename... Args>
|
||||||
void Window::addClickedCallback ( finalcut::FWidget* widget
|
void Window::addClickedCallback ( finalcut::FWidget* widget
|
||||||
, InstanceT&& instance
|
, InstanceT&& instance
|
||||||
, CallbackT&& callback
|
, CallbackT&& callback
|
||||||
|
@ -463,7 +469,7 @@ void Window::cb_createWindows()
|
||||||
win_dat->dgl = win;
|
win_dat->dgl = win;
|
||||||
win_dat->is_open = true;
|
win_dat->is_open = true;
|
||||||
win->setText(win_dat->title);
|
win->setText(win_dat->title);
|
||||||
const int n = int(std::distance(first, iter));
|
const auto n = int(std::distance(first, iter));
|
||||||
const int x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
|
const int x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
|
||||||
const int y = dy + 11 + int(n / 3) * 3;
|
const int y = dy + 11 + int(n / 3) * 3;
|
||||||
win->setGeometry (FPoint{x, y}, FSize{20, 8});
|
win->setGeometry (FPoint{x, y}, FSize{20, 8});
|
||||||
|
@ -570,8 +576,6 @@ int main (int argc, char* argv[])
|
||||||
// Create main dialog object
|
// Create main dialog object
|
||||||
Window main_dlg {&app};
|
Window main_dlg {&app};
|
||||||
main_dlg.setText ("Main window");
|
main_dlg.setText ("Main window");
|
||||||
main_dlg.setGeometry ( FPoint{int(1 + (app.getWidth() - 40) / 2), 2}
|
|
||||||
, FSize{40, 6} );
|
|
||||||
|
|
||||||
// Set dialog main_dlg as main widget
|
// Set dialog main_dlg as main widget
|
||||||
finalcut::FWidget::setMainWidget (&main_dlg);
|
finalcut::FWidget::setMainWidget (&main_dlg);
|
||||||
|
|
|
@ -10,7 +10,7 @@ function create_code_file ()
|
||||||
echo -e "#define ${INCLUDE_GUARD}\\n"
|
echo -e "#define ${INCLUDE_GUARD}\\n"
|
||||||
echo -e "namespace finalcut\\n{\\n"
|
echo -e "namespace finalcut\\n{\\n"
|
||||||
echo -e "namespace fc\\n{\\n"
|
echo -e "namespace fc\\n{\\n"
|
||||||
echo -e "static unsigned char ${NAME}[] =\\n{"
|
echo -e "constexpr unsigned char ${NAME}[] =\\n{"
|
||||||
|
|
||||||
grep -A"${HEIGHT}" "^BITMAP" "$NEWFONTFILE" \
|
grep -A"${HEIGHT}" "^BITMAP" "$NEWFONTFILE" \
|
||||||
| tr '\n' ',' \
|
| tr '\n' ',' \
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace finalcut
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
static unsigned char __8x16graph[] =
|
constexpr unsigned char __8x16graph[] =
|
||||||
{
|
{
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
||||||
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace finalcut
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
static unsigned char __9x16graph[] =
|
constexpr unsigned char __9x16graph[] =
|
||||||
{
|
{
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
||||||
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
||||||
|
|
|
@ -11,14 +11,16 @@
|
||||||
#include <sys/kd.h>
|
#include <sys/kd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
static struct unipair unicode_cp437_pairs[] =
|
constexpr std::array<struct unipair, 282> unicode_cp437_pairs =
|
||||||
{
|
{{
|
||||||
// .----------- unicode
|
// .----------- unicode
|
||||||
// | .---- fontpos
|
// | .---- fontpos
|
||||||
// | |
|
// | |
|
||||||
|
@ -304,10 +306,10 @@ static struct unipair unicode_cp437_pairs[] =
|
||||||
{0x266a, 0x0d},
|
{0x266a, 0x0d},
|
||||||
{0x266b, 0x0e},
|
{0x266b, 0x0e},
|
||||||
{0x266c, 0x0e}
|
{0x266c, 0x0e}
|
||||||
};
|
}};
|
||||||
|
|
||||||
static struct unipair unicode_newfont_pairs[] =
|
constexpr std::array<struct unipair, 299> unicode_newfont_pairs =
|
||||||
{
|
{{
|
||||||
// .----------- unicode
|
// .----------- unicode
|
||||||
// | .---- fontpos
|
// | .---- fontpos
|
||||||
// | |
|
// | |
|
||||||
|
@ -610,7 +612,7 @@ static struct unipair unicode_newfont_pairs[] =
|
||||||
{0xe1f9, 0xf9},
|
{0xe1f9, 0xf9},
|
||||||
{0xe1fb, 0xfb},
|
{0xe1fb, 0xfb},
|
||||||
{0xe1fc, 0xfc}
|
{0xe1fc, 0xfc}
|
||||||
};
|
}};
|
||||||
|
|
||||||
} // namespace fc
|
} // namespace fc
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace finalcut
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
static unsigned char __8x16std[] =
|
constexpr unsigned char __8x16std[] =
|
||||||
{
|
{
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
||||||
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
||||||
|
|
|
@ -20,6 +20,7 @@ libfinal_la_SOURCES = \
|
||||||
fbutton.cpp \
|
fbutton.cpp \
|
||||||
fbuttongroup.cpp \
|
fbuttongroup.cpp \
|
||||||
fcallback.cpp \
|
fcallback.cpp \
|
||||||
|
fdata.cpp \
|
||||||
ftogglebutton.cpp \
|
ftogglebutton.cpp \
|
||||||
fradiobutton.cpp \
|
fradiobutton.cpp \
|
||||||
fcheckbox.cpp \
|
fcheckbox.cpp \
|
||||||
|
|
|
@ -13,6 +13,7 @@ INCLUDE_HEADERS = \
|
||||||
fbuttongroup.h \
|
fbuttongroup.h \
|
||||||
fbutton.h \
|
fbutton.h \
|
||||||
fcallback.h \
|
fcallback.h \
|
||||||
|
fdata.h \
|
||||||
fcolorpair.h \
|
fcolorpair.h \
|
||||||
fstyle.h \
|
fstyle.h \
|
||||||
ftogglebutton.h \
|
ftogglebutton.h \
|
||||||
|
@ -93,6 +94,7 @@ OBJS = \
|
||||||
fsize.o \
|
fsize.o \
|
||||||
frect.o \
|
frect.o \
|
||||||
fcallback.o \
|
fcallback.o \
|
||||||
|
fdata.o \
|
||||||
fscrollbar.o \
|
fscrollbar.o \
|
||||||
fprogressbar.o \
|
fprogressbar.o \
|
||||||
flineedit.o \
|
flineedit.o \
|
||||||
|
@ -172,7 +174,7 @@ endif
|
||||||
$(CXX) -c $(CCXFLAGS) $(INCLUDES) -fpic -o $@ $<
|
$(CXX) -c $(CCXFLAGS) $(INCLUDES) -fpic -o $@ $<
|
||||||
|
|
||||||
all: dep $(OBJS)
|
all: dep $(OBJS)
|
||||||
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR) -o $(LIB).$(VERSION) $(OBJS)
|
$(CXX) $(OBJS) -o $(LIB).$(VERSION) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR)
|
||||||
ln -s -f $(LIB).$(VERSION) libfinal.so.$(MAJOR)
|
ln -s -f $(LIB).$(VERSION) libfinal.so.$(MAJOR)
|
||||||
ln -s -f $(LIB).$(MAJOR) libfinal.so
|
ln -s -f $(LIB).$(MAJOR) libfinal.so
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ INCLUDE_HEADERS = \
|
||||||
fbuttongroup.h \
|
fbuttongroup.h \
|
||||||
fbutton.h \
|
fbutton.h \
|
||||||
fcallback.h \
|
fcallback.h \
|
||||||
|
fdata.h \
|
||||||
fcolorpair.h \
|
fcolorpair.h \
|
||||||
fstyle.h \
|
fstyle.h \
|
||||||
ftogglebutton.h \
|
ftogglebutton.h \
|
||||||
|
@ -93,6 +94,7 @@ OBJS = \
|
||||||
fsize.o \
|
fsize.o \
|
||||||
frect.o \
|
frect.o \
|
||||||
fcallback.o \
|
fcallback.o \
|
||||||
|
fdata.o \
|
||||||
fscrollbar.o \
|
fscrollbar.o \
|
||||||
fprogressbar.o \
|
fprogressbar.o \
|
||||||
flineedit.o \
|
flineedit.o \
|
||||||
|
@ -172,7 +174,7 @@ endif
|
||||||
$(CXX) -c $(CCXFLAGS) $(INCLUDES) -fpic -o $@ $<
|
$(CXX) -c $(CCXFLAGS) $(INCLUDES) -fpic -o $@ $<
|
||||||
|
|
||||||
all: dep $(OBJS)
|
all: dep $(OBJS)
|
||||||
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR) -o $(LIB).$(VERSION) $(OBJS)
|
$(CXX) $(OBJS) -o $(LIB).$(VERSION) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR)
|
||||||
ln -s -f $(LIB).$(VERSION) libfinal.so.$(MAJOR)
|
ln -s -f $(LIB).$(VERSION) libfinal.so.$(MAJOR)
|
||||||
ln -s -f $(LIB).$(MAJOR) libfinal.so
|
ln -s -f $(LIB).$(MAJOR) libfinal.so
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
@ -63,9 +65,35 @@ FMouseControl* FApplication::mouse {nullptr}; // mouse control
|
||||||
int FApplication::loop_level {0}; // event loop level
|
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}; // preset to 5 ms /200 Hz
|
uInt64 FApplication::next_event_wait {5000}; // preset to 5 ms (200 Hz)
|
||||||
struct timeval FApplication::time_last_event{};
|
struct timeval FApplication::time_last_event{};
|
||||||
|
|
||||||
|
|
||||||
|
const std::vector<FApplication::CmdOption> FApplication::long_options =
|
||||||
|
{
|
||||||
|
{"encoding", required_argument, nullptr, 'e' },
|
||||||
|
{"log-file", required_argument, nullptr, 'l' },
|
||||||
|
{"no-mouse", no_argument, nullptr, 'm' },
|
||||||
|
{"no-optimized-cursor", no_argument, nullptr, 'o' },
|
||||||
|
{"no-terminal-detection", no_argument, nullptr, 'd' },
|
||||||
|
{"no-terminal-data-request", no_argument, nullptr, 'r' },
|
||||||
|
{"no-color-change", no_argument, nullptr, 'c' },
|
||||||
|
{"no-sgr-optimizer", no_argument, nullptr, 's' },
|
||||||
|
{"vgafont", no_argument, nullptr, 'v' },
|
||||||
|
{"newfont", no_argument, nullptr, 'n' },
|
||||||
|
{"dark-theme", no_argument, nullptr, 't' },
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
{"no-esc-for-alt-meta", no_argument, nullptr, 'E' },
|
||||||
|
{"no-cursorstyle-change", no_argument, nullptr, 'C' },
|
||||||
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
{"no-esc-for-alt-meta", no_argument, nullptr, 'E' },
|
||||||
|
#endif
|
||||||
|
|
||||||
|
{nullptr, 0, nullptr, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// class FApplication
|
// class FApplication
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -94,9 +122,10 @@ FApplication::FApplication (const int& _argc, char* _argv[])
|
||||||
|
|
||||||
if ( ! (_argc && _argv) )
|
if ( ! (_argc && _argv) )
|
||||||
{
|
{
|
||||||
static char empty_str[1] = "";
|
typedef char* CString;
|
||||||
|
static std::array<CString, 1> empty{{CString("")}};
|
||||||
app_argc = 0;
|
app_argc = 0;
|
||||||
app_argv = reinterpret_cast<char**>(&empty_str);
|
app_argv = empty.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
@ -122,21 +151,37 @@ FApplication* FApplication::getApplicationObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FApplication::FLogPtr& FApplication::getLog()
|
FWidget* FApplication::getKeyboardWidget()
|
||||||
{
|
{
|
||||||
// Global logger object
|
return keyboard_widget;
|
||||||
static FLogPtr* logger = new FLogPtr();
|
|
||||||
|
|
||||||
if ( logger && logger->get() == nullptr )
|
|
||||||
*logger = std::make_shared<FLogger>();
|
|
||||||
|
|
||||||
return *logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::setLog (const FLogPtr& logger)
|
FApplication::FLogPtr& FApplication::getLog()
|
||||||
{
|
{
|
||||||
getLog() = logger;
|
// Global logger object
|
||||||
|
static auto logger_ptr = new FLogPtr();
|
||||||
|
|
||||||
|
if ( logger_ptr && logger_ptr->get() == nullptr )
|
||||||
|
{
|
||||||
|
*logger_ptr = std::make_shared<FLogger>();
|
||||||
|
|
||||||
|
// Set the logger as rdbuf of clog
|
||||||
|
std::clog.rdbuf(logger_ptr->get());
|
||||||
|
}
|
||||||
|
|
||||||
|
return *logger_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FApplication::setLog (const FLogPtr& log)
|
||||||
|
{
|
||||||
|
FLogPtr& logger = getLog();
|
||||||
|
logger.reset();
|
||||||
|
logger = log;
|
||||||
|
|
||||||
|
// Set the logger as rdbuf of clog
|
||||||
|
std::clog.rdbuf(logger.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -306,6 +351,35 @@ void FApplication::setDarkTheme()
|
||||||
setColorTheme<default16ColorDarkTheme>();
|
setColorTheme<default16ColorDarkTheme>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FApplication::setLogFile (const FString& filename)
|
||||||
|
{
|
||||||
|
auto& log_stream = getStartOptions().logfile_stream;
|
||||||
|
log_stream.open(filename, std::ofstream::out);
|
||||||
|
|
||||||
|
if ( log_stream.is_open() )
|
||||||
|
{
|
||||||
|
// Get the global logger object
|
||||||
|
FLog& log = *FApplication::getLog();
|
||||||
|
log.setOutputStream(log_stream);
|
||||||
|
log.enableTimestamp();
|
||||||
|
log.setLineEnding (finalcut::FLog::LF);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ftermdata = FTerm::getFTermData();
|
||||||
|
ftermdata->setExitMessage ( "Could not open log file \""
|
||||||
|
+ filename + "\"" );
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FApplication::setKeyboardWidget (FWidget* widget)
|
||||||
|
{
|
||||||
|
keyboard_widget = widget;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
|
void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
|
||||||
{
|
{
|
||||||
|
@ -333,6 +407,8 @@ void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
|
||||||
void FApplication::processExternalUserEvent()
|
void FApplication::processExternalUserEvent()
|
||||||
{
|
{
|
||||||
// This method can be overloaded and replaced by own code
|
// This method can be overloaded and replaced by own code
|
||||||
|
|
||||||
|
if ( FKeyboard::getReadBlockingTime() < 10000 )
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,6 +417,9 @@ void FApplication::processExternalUserEvent()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::init()
|
void FApplication::init()
|
||||||
{
|
{
|
||||||
|
// FApplication cannot have a second child widget
|
||||||
|
setMaxChildren(1);
|
||||||
|
|
||||||
// Initialize the last event time
|
// Initialize the last event time
|
||||||
time_last_event.tv_sec = 0;
|
time_last_event.tv_sec = 0;
|
||||||
time_last_event.tv_usec = 0;
|
time_last_event.tv_usec = 0;
|
||||||
|
@ -405,113 +484,70 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::setLogFile (const FString& filename)
|
inline FApplication::CmdMap& FApplication::mapCmdOptions()
|
||||||
{
|
{
|
||||||
auto& log_stream = getStartOptions().logfile_stream;
|
using std::placeholders::_1;
|
||||||
log_stream.open(filename, std::ofstream::out);
|
auto enc = std::bind(&FApplication::setTerminalEncoding, _1);
|
||||||
|
auto log = std::bind(&FApplication::setLogFile, _1);
|
||||||
|
auto opt = &FApplication::getStartOptions;
|
||||||
|
static CmdMap cmd_map{};
|
||||||
|
|
||||||
if ( log_stream.is_open() )
|
// --encoding
|
||||||
{
|
cmd_map['e'] = [enc] (const char* arg) { enc(FString(arg)); };
|
||||||
// Get the global logger object
|
// --log-file
|
||||||
FLog& log = *FApplication::getLog();
|
cmd_map['l'] = [log] (const char* arg) { log(FString(arg)); };
|
||||||
log.setOutputStream(log_stream);
|
// --no-mouse
|
||||||
log.enableTimestamp();
|
cmd_map['m'] = [opt] (const char*) { opt().mouse_support = false; };
|
||||||
log.setLineEnding (finalcut::FLog::LF);
|
// --no-optimized-cursor
|
||||||
}
|
cmd_map['o'] = [opt] (const char*) { opt().cursor_optimisation = false; };
|
||||||
else
|
// --no-terminal-detection
|
||||||
{
|
cmd_map['d'] = [opt] (const char*) { opt().terminal_detection = false; };
|
||||||
auto ftermdata = FTerm::getFTermData();
|
// --no-terminal-data-request
|
||||||
ftermdata->setExitMessage ( "Could not open log file \""
|
cmd_map['r'] = [opt] (const char*) { opt().terminal_data_request = false; };
|
||||||
+ filename + "\"" );
|
// --no-color-change
|
||||||
exit(EXIT_FAILURE);
|
cmd_map['c'] = [opt] (const char*) { opt().color_change = false; };
|
||||||
}
|
// --no-sgr-optimizer
|
||||||
|
cmd_map['s'] = [opt] (const char*) { opt().sgr_optimizer = false; };
|
||||||
|
// --vgafont
|
||||||
|
cmd_map['v'] = [opt] (const char*) { opt().vgafont = true; };
|
||||||
|
// --newfont
|
||||||
|
cmd_map['n'] = [opt] (const char*) { opt().newfont = true; };
|
||||||
|
// --dark-theme
|
||||||
|
cmd_map['t'] = [opt] (const char*) { opt().dark_theme = true; };
|
||||||
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
// --no-esc-for-alt-meta
|
||||||
|
cmd_map['E'] = [opt] (const char*) { opt().meta_sends_escape = false; };
|
||||||
|
// --no-cursorstyle-change
|
||||||
|
cmd_map['C'] = [opt] (const char*) { opt().change_cursorstyle = false; };
|
||||||
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
// --no-esc-for-alt-meta
|
||||||
|
cmd_map['E'] = [opt] (const char*) { opt().meta_sends_escape = false; };
|
||||||
|
#endif
|
||||||
|
return cmd_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::cmd_options (const int& argc, char* argv[])
|
void FApplication::cmdOptions (const int& argc, char* argv[])
|
||||||
{
|
{
|
||||||
// Interpret the command line options
|
// Interpret the command line options
|
||||||
|
|
||||||
|
auto& cmd_map = mapCmdOptions();
|
||||||
|
|
||||||
while ( true )
|
while ( true )
|
||||||
{
|
{
|
||||||
static struct option long_options[] =
|
|
||||||
{
|
|
||||||
{"encoding", required_argument, nullptr, 0 },
|
|
||||||
{"log-file", required_argument, nullptr, 0 },
|
|
||||||
{"no-mouse", no_argument, nullptr, 0 },
|
|
||||||
{"no-optimized-cursor", no_argument, nullptr, 0 },
|
|
||||||
{"no-terminal-detection", no_argument, nullptr, 0 },
|
|
||||||
{"no-terminal-data-request", no_argument, nullptr, 0 },
|
|
||||||
{"no-color-change", no_argument, nullptr, 0 },
|
|
||||||
{"no-sgr-optimizer", no_argument, nullptr, 0 },
|
|
||||||
{"vgafont", no_argument, nullptr, 0 },
|
|
||||||
{"newfont", no_argument, nullptr, 0 },
|
|
||||||
{"dark-theme", no_argument, nullptr, 0 },
|
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
{"no-esc-for-alt-meta", no_argument, nullptr, 0 },
|
|
||||||
{"no-cursorstyle-change", no_argument, nullptr, 0 },
|
|
||||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
{"no-esc-for-alt-meta", no_argument, nullptr, 0 },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{nullptr, 0, nullptr, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
int idx{0};
|
int idx{0};
|
||||||
const int c = getopt_long (argc, argv, "", long_options, &idx);
|
auto p = reinterpret_cast<const struct option*>(long_options.data());
|
||||||
|
const int opt = getopt_long (argc, argv, "", p, &idx);
|
||||||
|
|
||||||
if ( c == -1 )
|
if ( opt == -1 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ( c == 0 )
|
if ( cmd_map.find(opt) != cmd_map.end() )
|
||||||
{
|
cmd_map[opt](optarg);
|
||||||
if ( std::strcmp(long_options[idx].name, "encoding") == 0 )
|
|
||||||
setTerminalEncoding(FString(optarg));
|
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "log-file") == 0 )
|
|
||||||
setLogFile(FString(optarg));
|
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "no-mouse") == 0 )
|
|
||||||
getStartOptions().mouse_support = false;
|
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "no-optimized-cursor") == 0 )
|
|
||||||
getStartOptions().cursor_optimisation = false;
|
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "no-terminal-detection") == 0 )
|
|
||||||
getStartOptions().terminal_detection = false;
|
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "no-terminal-data-request") == 0 )
|
|
||||||
getStartOptions().terminal_data_request = false;
|
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "no-color-change") == 0 )
|
|
||||||
getStartOptions().color_change = false;
|
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "no-sgr-optimizer") == 0 )
|
|
||||||
getStartOptions().sgr_optimizer = false;
|
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "vgafont") == 0 )
|
|
||||||
getStartOptions().vgafont = true;
|
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "newfont") == 0 )
|
|
||||||
getStartOptions().newfont = true;
|
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "dark-theme") == 0 )
|
|
||||||
getStartOptions().dark_theme = true;
|
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
|
|
||||||
getStartOptions().meta_sends_escape = false;
|
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "no-cursorstyle-change") == 0 )
|
|
||||||
getStartOptions().change_cursorstyle = false;
|
|
||||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
|
|
||||||
getStartOptions().meta_sends_escape = false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd_map.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -574,6 +610,10 @@ void FApplication::showParameterUsage()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FApplication::destroyLog()
|
inline void FApplication::destroyLog()
|
||||||
{
|
{
|
||||||
|
// Reset the rdbuf of clog
|
||||||
|
std::clog.rdbuf(default_clog_rdbuf);
|
||||||
|
|
||||||
|
// Delete the logger
|
||||||
const FLogPtr* logger = &(getLog());
|
const FLogPtr* logger = &(getLog());
|
||||||
delete logger;
|
delete logger;
|
||||||
}
|
}
|
||||||
|
@ -796,34 +836,30 @@ bool FApplication::processAccelerator (const FWidget* const& widget) const
|
||||||
{
|
{
|
||||||
bool accpt{false};
|
bool accpt{false};
|
||||||
|
|
||||||
if ( widget
|
if ( ! widget || widget->getAcceleratorList().empty() )
|
||||||
&& ! widget->getAcceleratorList().empty() )
|
return accpt;
|
||||||
{
|
|
||||||
auto iter = widget->getAcceleratorList().begin();
|
|
||||||
const auto& last = widget->getAcceleratorList().end();
|
|
||||||
|
|
||||||
while ( iter != last && ! quit_now && ! app_exit_loop )
|
for (auto&& item : widget->getAcceleratorList())
|
||||||
{
|
{
|
||||||
if ( iter->key == keyboard->getKey() )
|
if ( item.key == keyboard->getKey() )
|
||||||
{
|
{
|
||||||
// unset the move/size mode
|
// unset the move/size mode
|
||||||
auto move_size = getMoveSizeWidget();
|
auto move_size = getMoveSizeWidget();
|
||||||
|
|
||||||
if ( move_size )
|
if ( move_size )
|
||||||
{
|
{
|
||||||
auto w = move_size;
|
|
||||||
setMoveSizeWidget(nullptr);
|
setMoveSizeWidget(nullptr);
|
||||||
w->redraw();
|
move_size->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
|
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
|
||||||
sendEvent (iter->object, &a_ev);
|
sendEvent (item.object, &a_ev);
|
||||||
accpt = a_ev.isAccepted();
|
accpt = a_ev.isAccepted();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
++iter;
|
if ( quit_now || app_exit_loop )
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return accpt;
|
return accpt;
|
||||||
|
@ -1173,7 +1209,7 @@ FWidget* FApplication::processParameters (const int& argc, char* argv[])
|
||||||
FApplication::exit(EXIT_SUCCESS);
|
FApplication::exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_options (argc, argv);
|
cmdOptions (argc, argv);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1342,4 +1378,13 @@ bool FApplication::isNextEventTimeout()
|
||||||
return FObject::isTimeout (&time_last_event, next_event_wait);
|
return FObject::isTimeout (&time_last_event, next_event_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FLog non-member operators
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
std::ostream& operator << (std::ostream& outstr, FLog::LogLevel l)
|
||||||
|
{
|
||||||
|
*FApplication::getLog() << l;
|
||||||
|
return outstr;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include "final/fbusyindicator.h"
|
#include "final/fbusyindicator.h"
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
|
@ -75,11 +76,11 @@ void FBusyIndicator::init()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FBusyIndicator::createIndicatorText()
|
void FBusyIndicator::createIndicatorText()
|
||||||
{
|
{
|
||||||
FString line[4]{};
|
std::array<FString, 4> line{};
|
||||||
|
|
||||||
if ( FTerm::getEncoding() == fc::UTF8 )
|
if ( FTerm::getEncoding() == fc::UTF8 )
|
||||||
{
|
{
|
||||||
const wchar_t (&p)[8] = uni_pattern;
|
const auto& p = uni_pattern;
|
||||||
line[0] << " " << p[7] << " " << p[0] << " \n";
|
line[0] << " " << p[7] << " " << p[0] << " \n";
|
||||||
line[1] << " " << p[6] << " " << p[1] << " \n";
|
line[1] << " " << p[6] << " " << p[1] << " \n";
|
||||||
line[2] << " " << p[5] << " " << p[2] << " \n";
|
line[2] << " " << p[5] << " " << p[2] << " \n";
|
||||||
|
@ -87,7 +88,7 @@ void FBusyIndicator::createIndicatorText()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char (&p)[8] = pattern;
|
const auto& p = pattern;
|
||||||
line[0] << " " << p[7] << " " << p[0] << " \n";
|
line[0] << " " << p[7] << " " << p[0] << " \n";
|
||||||
line[1] << " " << p[6] << " " << p[1] << " \n";
|
line[1] << " " << p[6] << " " << p[1] << " \n";
|
||||||
line[2] << " " << p[5] << " " << p[2] << " \n";
|
line[2] << " " << p[5] << " " << p[2] << " \n";
|
||||||
|
|
|
@ -309,40 +309,7 @@ void FButtonGroup::onAccel (FAccelEvent*)
|
||||||
void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
|
void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
|
||||||
{
|
{
|
||||||
in_ev->ignore(); // Change default value to ignore
|
in_ev->ignore(); // Change default value to ignore
|
||||||
|
focusInRadioButton (in_ev);
|
||||||
if ( hasCheckedButton() && ! buttonlist.empty() )
|
|
||||||
{
|
|
||||||
for (auto&& item : buttonlist)
|
|
||||||
{
|
|
||||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
|
||||||
|
|
||||||
if ( toggle_button->isChecked() )
|
|
||||||
{
|
|
||||||
if ( isRadioButton(toggle_button) )
|
|
||||||
{
|
|
||||||
auto prev_element = getFocusWidget();
|
|
||||||
|
|
||||||
toggle_button->setFocus();
|
|
||||||
|
|
||||||
FFocusEvent cfi (fc::ChildFocusIn_Event);
|
|
||||||
FApplication::sendEvent(this, &cfi);
|
|
||||||
|
|
||||||
FFocusEvent in (fc::FocusIn_Event);
|
|
||||||
FApplication::sendEvent(toggle_button, &in);
|
|
||||||
|
|
||||||
if ( in.isAccepted() )
|
|
||||||
in_ev->accept();
|
|
||||||
|
|
||||||
if ( prev_element )
|
|
||||||
prev_element->redraw();
|
|
||||||
|
|
||||||
toggle_button->redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} // end of range-based for loop
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! in_ev->isAccepted() )
|
if ( ! in_ev->isAccepted() )
|
||||||
{
|
{
|
||||||
|
@ -484,25 +451,13 @@ void FButtonGroup::drawText ( const FString& label_text
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FButtonGroup::directFocus()
|
bool FButtonGroup::directFocusCheckedRadioButton (FToggleButton* item) const
|
||||||
{
|
{
|
||||||
if ( ! hasFocusedButton() )
|
if ( ! isRadioButton(item) )
|
||||||
{
|
return false;
|
||||||
bool found_checked{false};
|
|
||||||
|
|
||||||
if ( hasCheckedButton() && ! buttonlist.empty() )
|
|
||||||
{
|
|
||||||
for (auto&& item : buttonlist)
|
|
||||||
{
|
|
||||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
|
||||||
|
|
||||||
if ( toggle_button->isChecked() )
|
|
||||||
{
|
|
||||||
if ( isRadioButton(toggle_button) )
|
|
||||||
{
|
|
||||||
found_checked = true;
|
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
toggle_button->setFocus();
|
item->setFocus();
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
focused_widget->redraw();
|
focused_widget->redraw();
|
||||||
|
@ -511,14 +466,36 @@ void FButtonGroup::directFocus()
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
focused_widget->redraw();
|
focused_widget->redraw();
|
||||||
}
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
bool FButtonGroup::directFocusRadioButton() const
|
||||||
|
{
|
||||||
|
if ( ! hasCheckedButton() || buttonlist.empty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool found_checked{false};
|
||||||
|
|
||||||
|
for (auto&& item : buttonlist)
|
||||||
|
{
|
||||||
|
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||||
|
|
||||||
|
if ( toggle_button->isChecked() )
|
||||||
|
{
|
||||||
|
found_checked = directFocusCheckedRadioButton(toggle_button);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // end of range-based for loop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! found_checked )
|
return found_checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FButtonGroup::directFocus()
|
||||||
|
{
|
||||||
|
if ( ! hasFocusedButton() && ! directFocusRadioButton() )
|
||||||
{
|
{
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
focusFirstChild();
|
focusFirstChild();
|
||||||
|
@ -531,7 +508,6 @@ void FButtonGroup::directFocus()
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
focused_widget->redraw();
|
focused_widget->redraw();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( getStatusBar() )
|
if ( getStatusBar() )
|
||||||
{
|
{
|
||||||
|
@ -541,6 +517,49 @@ void FButtonGroup::directFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FButtonGroup::focusCheckedRadioButton ( FToggleButton* toggle_button
|
||||||
|
, FFocusEvent* in_ev )
|
||||||
|
{
|
||||||
|
auto prev_element = getFocusWidget();
|
||||||
|
|
||||||
|
toggle_button->setFocus();
|
||||||
|
|
||||||
|
FFocusEvent cfi (fc::ChildFocusIn_Event);
|
||||||
|
FApplication::sendEvent(this, &cfi);
|
||||||
|
|
||||||
|
FFocusEvent in (fc::FocusIn_Event);
|
||||||
|
FApplication::sendEvent(toggle_button, &in);
|
||||||
|
|
||||||
|
if ( in.isAccepted() )
|
||||||
|
in_ev->accept();
|
||||||
|
|
||||||
|
if ( prev_element )
|
||||||
|
prev_element->redraw();
|
||||||
|
|
||||||
|
toggle_button->redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FButtonGroup::focusInRadioButton (FFocusEvent* in_ev)
|
||||||
|
{
|
||||||
|
if ( ! hasCheckedButton() || buttonlist.empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (auto&& item : buttonlist)
|
||||||
|
{
|
||||||
|
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||||
|
|
||||||
|
if ( toggle_button->isChecked() )
|
||||||
|
{
|
||||||
|
if ( isRadioButton(toggle_button) )
|
||||||
|
focusCheckedRadioButton (toggle_button, in_ev);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FButtonGroup::cb_buttonToggled (const FToggleButton* button) const
|
void FButtonGroup::cb_buttonToggled (const FToggleButton* button) const
|
||||||
{
|
{
|
||||||
|
|
1316
src/fcharmap.cpp
1316
src/fcharmap.cpp
File diff suppressed because it is too large
Load Diff
|
@ -29,7 +29,6 @@
|
||||||
#include "final/flabel.h"
|
#include "final/flabel.h"
|
||||||
#include "final/flineedit.h"
|
#include "final/flineedit.h"
|
||||||
#include "final/flistbox.h"
|
#include "final/flistbox.h"
|
||||||
#include "final/flog.h"
|
|
||||||
#include "final/fmouse.h"
|
#include "final/fmouse.h"
|
||||||
#include "final/fpoint.h"
|
#include "final/fpoint.h"
|
||||||
#include "final/fsize.h"
|
#include "final/fsize.h"
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* fdata.cpp - A general-purpose data wrapper *
|
||||||
|
* *
|
||||||
|
* This file is part of the FINAL CUT widget toolkit *
|
||||||
|
* *
|
||||||
|
* Copyright 2020 Markus Gans *
|
||||||
|
* *
|
||||||
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
* published by the Free Software Foundation; either version 3 of *
|
||||||
|
* the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* FINAL CUT is distributed in the hope that it will be useful, but *
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU Lesser General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Lesser General Public *
|
||||||
|
* License along with this program. If not, see *
|
||||||
|
* <http://www.gnu.org/licenses/>. *
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include "final/fdata.h"
|
||||||
|
|
||||||
|
namespace finalcut
|
||||||
|
{
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// class FDataAccess
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
// constructors and destructor
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
FDataAccess::FDataAccess()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
FDataAccess::~FDataAccess() // destructor
|
||||||
|
{ }
|
||||||
|
|
||||||
|
} // namespace finalcut
|
||||||
|
|
|
@ -226,8 +226,8 @@ void FDialog::setPos (const FPoint& pos, bool)
|
||||||
if ( getTermGeometry().overlap(old_geometry) )
|
if ( getTermGeometry().overlap(old_geometry) )
|
||||||
{
|
{
|
||||||
FRect restore{};
|
FRect restore{};
|
||||||
const std::size_t d_width = std::size_t(std::abs(dx));
|
const auto d_width = std::size_t(std::abs(dx));
|
||||||
const std::size_t d_height = std::size_t(std::abs(dy));
|
const auto d_height = std::size_t(std::abs(dy));
|
||||||
|
|
||||||
// dx > 0 : move left
|
// dx > 0 : move left
|
||||||
// dx = 0 : move vertical
|
// dx = 0 : move vertical
|
||||||
|
@ -282,7 +282,16 @@ void FDialog::move (const FPoint& d_pos)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FDialog::moveUp (int n)
|
inline bool FDialog::moveUp (int n)
|
||||||
{
|
{
|
||||||
|
if ( isBottomOutside() )
|
||||||
|
{
|
||||||
|
const auto y_max = int(getMaxHeight());
|
||||||
|
FWindow::setY(y_max, false);
|
||||||
|
putArea (getTermPos(), getVWin());
|
||||||
|
restoreOverlaidWindows();
|
||||||
|
}
|
||||||
|
else
|
||||||
move ({0, -n});
|
move ({0, -n});
|
||||||
|
|
||||||
return ! setPos_error;
|
return ! setPos_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +305,16 @@ inline bool FDialog::moveDown (int n)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FDialog::moveLeft (int n)
|
inline bool FDialog::moveLeft (int n)
|
||||||
{
|
{
|
||||||
|
if ( isLeftOutside() )
|
||||||
|
{
|
||||||
|
const auto x_max = int(getMaxWidth());
|
||||||
|
FWindow::setX(x_max, false);
|
||||||
|
putArea (getTermPos(), getVWin());
|
||||||
|
restoreOverlaidWindows();
|
||||||
|
}
|
||||||
|
else
|
||||||
move ({-n, 0});
|
move ({-n, 0});
|
||||||
|
|
||||||
return ! setPos_error;
|
return ! setPos_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +341,7 @@ void FDialog::setSize (const FSize& size, bool adjust)
|
||||||
const int dw = int(getWidth()) - int(size.getWidth());
|
const int dw = int(getWidth()) - int(size.getWidth());
|
||||||
const int dh = int(getHeight()) - int(size.getHeight());
|
const int dh = int(getHeight()) - int(size.getHeight());
|
||||||
const auto& shadow = getShadow();
|
const auto& shadow = getShadow();
|
||||||
FWindow::setSize (size, adjust);
|
FWindow::setSize (size, false);
|
||||||
|
|
||||||
// get adjust width and height
|
// get adjust width and height
|
||||||
const std::size_t w = getWidth() + shadow.getWidth();
|
const std::size_t w = getWidth() + shadow.getWidth();
|
||||||
|
@ -336,8 +354,8 @@ void FDialog::setSize (const FSize& size, bool adjust)
|
||||||
// dh = 0 : scale only width
|
// dh = 0 : scale only width
|
||||||
// dh < 0 : scale up height
|
// dh < 0 : scale up height
|
||||||
|
|
||||||
const std::size_t d_width = std::size_t(dw);
|
const auto d_width = std::size_t(dw);
|
||||||
const std::size_t d_height = std::size_t(dh);
|
const auto d_height = std::size_t(dh);
|
||||||
|
|
||||||
// restoring the non-covered terminal areas
|
// restoring the non-covered terminal areas
|
||||||
if ( dw > 0 )
|
if ( dw > 0 )
|
||||||
|
@ -346,6 +364,9 @@ void FDialog::setSize (const FSize& size, bool adjust)
|
||||||
if ( dh > 0 )
|
if ( dh > 0 )
|
||||||
restoreVTerm ({x, y + int(h), w + d_width, d_height}); // restore bottom
|
restoreVTerm ({x, y + int(h), w + d_width, d_height}); // restore bottom
|
||||||
|
|
||||||
|
if ( adjust ) // Adjust the size after restoreVTerm(),
|
||||||
|
adjustSize(); // because adjustSize() can also change x and y
|
||||||
|
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
// handle overlaid windows
|
// handle overlaid windows
|
||||||
|
@ -439,7 +460,8 @@ void FDialog::onKeyPress (FKeyEvent* ev)
|
||||||
cancelMouseResize();
|
cancelMouseResize();
|
||||||
|
|
||||||
if ( ev->key() == fc::Fckey_caret // Ctrl+^ (Ctrl+6)
|
if ( ev->key() == fc::Fckey_caret // Ctrl+^ (Ctrl+6)
|
||||||
|| ev->key() == fc::Fkey_f22 ) // Shift+F10
|
|| ev->key() == fc::Fkey_f22 // Shift+F10
|
||||||
|
|| ev->key() == fc::Fkey_smenu ) // Shift+Menu
|
||||||
{
|
{
|
||||||
ev->accept();
|
ev->accept();
|
||||||
// open the titlebar menu
|
// open the titlebar menu
|
||||||
|
@ -455,8 +477,9 @@ void FDialog::onKeyPress (FKeyEvent* ev)
|
||||||
if ( this == getMainWidget() )
|
if ( this == getMainWidget() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( ev->key() == fc::Fkey_escape
|
if ( ! ev->isAccepted()
|
||||||
|| ev->key() == fc::Fkey_escape_mintty )
|
&& ( ev->key() == fc::Fkey_escape
|
||||||
|
|| ev->key() == fc::Fkey_escape_mintty) )
|
||||||
{
|
{
|
||||||
ev->accept();
|
ev->accept();
|
||||||
|
|
||||||
|
@ -470,9 +493,9 @@ void FDialog::onKeyPress (FKeyEvent* ev)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FDialog::onMouseDown (FMouseEvent* ev)
|
void FDialog::onMouseDown (FMouseEvent* ev)
|
||||||
{
|
{
|
||||||
const int width = int(getWidth());
|
const auto width = int(getWidth());
|
||||||
|
|
||||||
const mouseStates ms =
|
const MouseStates ms =
|
||||||
{
|
{
|
||||||
ev->getX(),
|
ev->getX(),
|
||||||
ev->getY(),
|
ev->getY(),
|
||||||
|
@ -531,7 +554,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FDialog::onMouseUp (FMouseEvent* ev)
|
void FDialog::onMouseUp (FMouseEvent* ev)
|
||||||
{
|
{
|
||||||
const mouseStates ms =
|
const MouseStates ms =
|
||||||
{
|
{
|
||||||
ev->getX(),
|
ev->getX(),
|
||||||
ev->getY(),
|
ev->getY(),
|
||||||
|
@ -580,7 +603,7 @@ void FDialog::onMouseUp (FMouseEvent* ev)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FDialog::onMouseMove (FMouseEvent* ev)
|
void FDialog::onMouseMove (FMouseEvent* ev)
|
||||||
{
|
{
|
||||||
const mouseStates ms =
|
const MouseStates ms =
|
||||||
{
|
{
|
||||||
ev->getX(),
|
ev->getX(),
|
||||||
ev->getY(),
|
ev->getY(),
|
||||||
|
@ -610,7 +633,7 @@ void FDialog::onMouseMove (FMouseEvent* ev)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FDialog::onMouseDoubleClick (FMouseEvent* ev)
|
void FDialog::onMouseDoubleClick (FMouseEvent* ev)
|
||||||
{
|
{
|
||||||
const mouseStates ms =
|
const MouseStates ms =
|
||||||
{
|
{
|
||||||
ev->getX(),
|
ev->getX(),
|
||||||
ev->getY(),
|
ev->getY(),
|
||||||
|
@ -1069,13 +1092,13 @@ inline void FDialog::drawRestoreSizeButton()
|
||||||
if ( FTerm::isMonochron() )
|
if ( FTerm::isMonochron() )
|
||||||
{
|
{
|
||||||
print ('[');
|
print ('[');
|
||||||
print (fc::BlackDownPointingTriangle); // ▼
|
print (fc::BlackDiamondSuit); // ◆
|
||||||
print (']');
|
print (']');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print (' ');
|
print (' ');
|
||||||
print (fc::BlackDownPointingTriangle); // ▼
|
print (fc::BlackDiamondSuit); // ◆
|
||||||
print (' ');
|
print (' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1295,7 +1318,7 @@ inline void FDialog::deactivateZoomButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FDialog::activateZoomButton (const mouseStates& ms)
|
inline void FDialog::activateZoomButton (const MouseStates& ms)
|
||||||
{
|
{
|
||||||
if ( ms.mouse_x <= int(getWidth() - ms.zoom_btn)
|
if ( ms.mouse_x <= int(getWidth() - ms.zoom_btn)
|
||||||
|| ms.mouse_y != 1 )
|
|| ms.mouse_y != 1 )
|
||||||
|
@ -1307,7 +1330,7 @@ inline void FDialog::activateZoomButton (const mouseStates& ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FDialog::leaveZoomButton (const mouseStates& ms)
|
inline void FDialog::leaveZoomButton (const MouseStates& ms)
|
||||||
{
|
{
|
||||||
bool zoom_button_pressed_before = zoom_button_pressed;
|
bool zoom_button_pressed_before = zoom_button_pressed;
|
||||||
|
|
||||||
|
@ -1324,7 +1347,7 @@ inline void FDialog::leaveZoomButton (const mouseStates& ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FDialog::pressZoomButton (const mouseStates& ms)
|
void FDialog::pressZoomButton (const MouseStates& ms)
|
||||||
{
|
{
|
||||||
if ( ms.mouse_x <= int(getWidth() - ms.zoom_btn)
|
if ( ms.mouse_x <= int(getWidth() - ms.zoom_btn)
|
||||||
|| ms.mouse_y != 1
|
|| ms.mouse_y != 1
|
||||||
|
@ -1348,7 +1371,7 @@ inline bool FDialog::isMouseOverMenu (const FPoint& termpos) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FDialog::passEventToSubMenu ( const mouseStates& ms
|
inline void FDialog::passEventToSubMenu ( const MouseStates& ms
|
||||||
, const FMouseEvent* ev )
|
, const FMouseEvent* ev )
|
||||||
{
|
{
|
||||||
// Mouse event handover to the dialog menu
|
// Mouse event handover to the dialog menu
|
||||||
|
@ -1382,48 +1405,58 @@ inline void FDialog::moveSizeKey (FKeyEvent* ev)
|
||||||
{
|
{
|
||||||
case fc::Fkey_up:
|
case fc::Fkey_up:
|
||||||
moveUp(1);
|
moveUp(1);
|
||||||
|
ev->accept();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fc::Fkey_down:
|
case fc::Fkey_down:
|
||||||
moveDown(1);
|
moveDown(1);
|
||||||
|
ev->accept();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fc::Fkey_left:
|
case fc::Fkey_left:
|
||||||
moveLeft(1);
|
moveLeft(1);
|
||||||
|
ev->accept();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fc::Fkey_right:
|
case fc::Fkey_right:
|
||||||
moveRight(1);
|
moveRight(1);
|
||||||
|
ev->accept();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fc::Fmkey_up:
|
case fc::Fmkey_up:
|
||||||
case fc::Fkey_sr:
|
case fc::Fkey_sr:
|
||||||
reduceHeight(1);
|
reduceHeight(1);
|
||||||
|
ev->accept();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fc::Fmkey_down:
|
case fc::Fmkey_down:
|
||||||
case fc::Fkey_sf:
|
case fc::Fkey_sf:
|
||||||
expandHeight(1);
|
expandHeight(1);
|
||||||
|
ev->accept();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fc::Fmkey_left:
|
case fc::Fmkey_left:
|
||||||
case fc::Fkey_sleft:
|
case fc::Fkey_sleft:
|
||||||
reduceWidth(1);
|
reduceWidth(1);
|
||||||
|
ev->accept();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fc::Fmkey_right:
|
case fc::Fmkey_right:
|
||||||
case fc::Fkey_sright:
|
case fc::Fkey_sright:
|
||||||
expandWidth(1);
|
expandWidth(1);
|
||||||
|
ev->accept();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fc::Fkey_return:
|
case fc::Fkey_return:
|
||||||
case fc::Fkey_enter:
|
case fc::Fkey_enter:
|
||||||
acceptMoveSize();
|
acceptMoveSize();
|
||||||
|
ev->accept();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fc::Fkey_escape:
|
case fc::Fkey_escape:
|
||||||
case fc::Fkey_escape_mintty:
|
case fc::Fkey_escape_mintty:
|
||||||
cancelMoveSize();
|
cancelMoveSize();
|
||||||
|
ev->accept();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1468,7 +1501,25 @@ bool FDialog::isOutsideTerminal (const FPoint& pos) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FDialog::isLowerRightResizeCorner (const mouseStates& ms) const
|
bool FDialog::isLeftOutside() const
|
||||||
|
{
|
||||||
|
if ( getX() > int(getMaxWidth()) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
bool FDialog::isBottomOutside() const
|
||||||
|
{
|
||||||
|
if ( getY() > int(getMaxHeight()) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
bool FDialog::isLowerRightResizeCorner (const MouseStates& ms) const
|
||||||
{
|
{
|
||||||
// 3 characters in the lower right corner |
|
// 3 characters in the lower right corner |
|
||||||
// x
|
// x
|
||||||
|
@ -1487,7 +1538,7 @@ bool FDialog::isLowerRightResizeCorner (const mouseStates& ms) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FDialog::resizeMouseDown (const mouseStates& ms)
|
void FDialog::resizeMouseDown (const MouseStates& ms)
|
||||||
{
|
{
|
||||||
// Click on the lower right resize corner
|
// Click on the lower right resize corner
|
||||||
|
|
||||||
|
@ -1512,7 +1563,7 @@ void FDialog::resizeMouseDown (const mouseStates& ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FDialog::resizeMouseUpMove (const mouseStates& ms, bool mouse_up)
|
void FDialog::resizeMouseUpMove (const MouseStates& ms, bool mouse_up)
|
||||||
{
|
{
|
||||||
// Resize the dialog
|
// Resize the dialog
|
||||||
if ( isResizeable() && ! resize_click_pos.isOrigin() )
|
if ( isResizeable() && ! resize_click_pos.isOrigin() )
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "final/fevent.h"
|
#include "final/fevent.h"
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
|
@ -372,12 +371,4 @@ FUserEvent::~FUserEvent() // destructor
|
||||||
int FUserEvent::getUserId() const
|
int FUserEvent::getUserId() const
|
||||||
{ return uid; }
|
{ return uid; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
FDataPtr FUserEvent::getData() const
|
|
||||||
{ return data_pointer; }
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void FUserEvent::setData (FDataPtr data)
|
|
||||||
{ data_pointer = data; }
|
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <strings.h> // need for strcasecmp
|
#include <strings.h> // need for strcasecmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "final/fevent.h"
|
#include "final/fevent.h"
|
||||||
|
@ -55,7 +56,7 @@ bool sortDirFirst ( const FFileDialog::FDirEntry& lhs
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString fileChooser ( FWidget* parent
|
FString fileChooser ( FWidget* parent
|
||||||
, const FString& dirname
|
, const FString& dirname
|
||||||
, const FString& filter
|
, const FString& filter
|
||||||
, FFileDialog::DialogType type )
|
, FFileDialog::DialogType type )
|
||||||
|
@ -165,9 +166,9 @@ FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FFileDialog::getSelectedFile() const
|
FString FFileDialog::getSelectedFile() const
|
||||||
{
|
{
|
||||||
const uLong n = uLong(filebrowser.currentItem() - 1);
|
const auto n = uLong(filebrowser.currentItem() - 1);
|
||||||
|
|
||||||
if ( dir_entries[n].directory )
|
if ( dir_entries[n].directory )
|
||||||
return FString{""};
|
return FString{""};
|
||||||
|
@ -179,7 +180,7 @@ const FString FFileDialog::getSelectedFile() const
|
||||||
void FFileDialog::setPath (const FString& dir)
|
void FFileDialog::setPath (const FString& dir)
|
||||||
{
|
{
|
||||||
const char* const dirname = dir.c_str();
|
const char* const dirname = dir.c_str();
|
||||||
char resolved_path[MAXPATHLEN]{};
|
std::array<char, MAXPATHLEN> resolved_path{};
|
||||||
FString r_dir{};
|
FString r_dir{};
|
||||||
struct stat sb{};
|
struct stat sb{};
|
||||||
|
|
||||||
|
@ -201,8 +202,8 @@ void FFileDialog::setPath (const FString& dir)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( fsystem && fsystem->realpath(dir.c_str(), resolved_path) != nullptr )
|
if ( fsystem && fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr )
|
||||||
r_dir.setString(resolved_path);
|
r_dir.setString(resolved_path.data());
|
||||||
else
|
else
|
||||||
r_dir.setString(dir);
|
r_dir.setString(dir);
|
||||||
|
|
||||||
|
@ -257,7 +258,7 @@ void FFileDialog::onKeyPress (FKeyEvent* ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FFileDialog::fileOpenChooser ( FWidget* parent
|
FString FFileDialog::fileOpenChooser ( FWidget* parent
|
||||||
, const FString& dirname
|
, const FString& dirname
|
||||||
, const FString& filter )
|
, const FString& filter )
|
||||||
{
|
{
|
||||||
|
@ -265,7 +266,7 @@ const FString FFileDialog::fileOpenChooser ( FWidget* parent
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FFileDialog::fileSaveChooser ( FWidget* parent
|
FString FFileDialog::fileSaveChooser ( FWidget* parent
|
||||||
, const FString& dirname
|
, const FString& dirname
|
||||||
, const FString& filter )
|
, const FString& filter )
|
||||||
{
|
{
|
||||||
|
@ -418,20 +419,20 @@ 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
|
||||||
{
|
{
|
||||||
char search[128]{};
|
std::array<char, 128> search{};
|
||||||
|
|
||||||
if ( show_hidden && fname[0] == '.' && fname[1] != '\0' ) // hidden files
|
if ( show_hidden && fname[0] == '.' && fname[1] != '\0' ) // hidden files
|
||||||
{
|
{
|
||||||
search[0] = '.';
|
search[0] = '.';
|
||||||
search[1] = '\0';
|
search[1] = '\0';
|
||||||
std::strncat(search, pattern, sizeof(search) - std::strlen(search) - 1);
|
std::strncat(search.data(), pattern, search.size() - std::strlen(search.data()) - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
std::strncpy(search, pattern, sizeof(search));
|
std::strncpy(search.data(), pattern, search.size() - 1);
|
||||||
|
|
||||||
search[sizeof(search) - 1] = '\0';
|
search[search.size() - 1] = '\0';
|
||||||
|
|
||||||
if ( fnmatch (search, fname, FNM_PERIOD) == 0 )
|
if ( fnmatch (search.data(), fname, FNM_PERIOD) == 0 )
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
@ -595,24 +596,24 @@ void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) const
|
||||||
if ( ! entry.symbolic_link )
|
if ( ! entry.symbolic_link )
|
||||||
return; // No symbolic link
|
return; // No symbolic link
|
||||||
|
|
||||||
char resolved_path[MAXPATHLEN]{};
|
std::array<char, MAXPATHLEN> resolved_path{};
|
||||||
char symLink[MAXPATHLEN]{};
|
std::array<char, MAXPATHLEN> symLink{};
|
||||||
struct stat sb{};
|
struct stat sb{};
|
||||||
|
|
||||||
if ( ! fsystem )
|
if ( ! fsystem )
|
||||||
fsystem = FTerm::getFSystem();
|
fsystem = FTerm::getFSystem();
|
||||||
|
|
||||||
std::strncpy (symLink, dir, sizeof(symLink));
|
std::strncpy (symLink.data(), dir, symLink.size() - 1);
|
||||||
symLink[sizeof(symLink) - 1] = '\0';
|
symLink[symLink.size() - 1] = '\0';
|
||||||
std::strncat ( symLink
|
std::strncat ( symLink.data()
|
||||||
, entry.name.c_str()
|
, entry.name.c_str()
|
||||||
, sizeof(symLink) - std::strlen(symLink) - 1);
|
, symLink.size() - std::strlen(symLink.data()) - 1);
|
||||||
symLink[sizeof(symLink) - 1] = '\0';
|
symLink[symLink.size() - 1] = '\0';
|
||||||
|
|
||||||
if ( fsystem->realpath(symLink, resolved_path) == nullptr )
|
if ( fsystem->realpath(symLink.data(), resolved_path.data()) == nullptr )
|
||||||
return; // Cannot follow the symlink
|
return; // Cannot follow the symlink
|
||||||
|
|
||||||
if ( lstat(resolved_path, &sb) == -1 )
|
if ( lstat(resolved_path.data(), &sb) == -1 )
|
||||||
return; // Cannot get file status
|
return; // Cannot get file status
|
||||||
|
|
||||||
if ( S_ISDIR(sb.st_mode) )
|
if ( S_ISDIR(sb.st_mode) )
|
||||||
|
@ -736,18 +737,18 @@ void FFileDialog::printPath (const FString& txt)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FFileDialog::getHomeDir()
|
FString FFileDialog::getHomeDir()
|
||||||
{
|
{
|
||||||
struct passwd pwd{};
|
struct passwd pwd{};
|
||||||
struct passwd* pwd_ptr{};
|
struct passwd* pwd_ptr{};
|
||||||
char buf[1024]{};
|
std::array<char, 1024> buf{};
|
||||||
|
|
||||||
if ( ! fsystem )
|
if ( ! fsystem )
|
||||||
fsystem = FTerm::getFSystem();
|
fsystem = FTerm::getFSystem();
|
||||||
|
|
||||||
const uid_t euid = fsystem->geteuid();
|
const uid_t euid = fsystem->geteuid();
|
||||||
|
|
||||||
if ( fsystem->getpwuid_r(euid, &pwd, buf, sizeof(buf), &pwd_ptr) )
|
if ( fsystem->getpwuid_r(euid, &pwd, buf.data(), buf.size(), &pwd_ptr) )
|
||||||
return FString{""};
|
return FString{""};
|
||||||
else
|
else
|
||||||
return FString{pwd.pw_dir};
|
return FString{pwd.pw_dir};
|
||||||
|
@ -823,7 +824,7 @@ void FFileDialog::cb_processRowChanged()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FFileDialog::cb_processClicked()
|
void FFileDialog::cb_processClicked()
|
||||||
{
|
{
|
||||||
const uLong n = uLong(filebrowser.currentItem() - 1);
|
const auto n = uLong(filebrowser.currentItem() - 1);
|
||||||
|
|
||||||
if ( dir_entries[n].directory )
|
if ( dir_entries[n].directory )
|
||||||
changeDir(dir_entries[n].name);
|
changeDir(dir_entries[n].name);
|
||||||
|
|
|
@ -20,9 +20,10 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "final/fc.h"
|
#include "final/fc.h"
|
||||||
#include "final/fkey_map.h"
|
#include "final/fkey_map.h"
|
||||||
#include "final/ftypes.h"
|
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
{
|
{
|
||||||
|
@ -30,14 +31,13 @@ namespace finalcut
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
FKeyMap fkey[] =
|
std::array<FKeyMap, 188> fkey
|
||||||
{
|
{{
|
||||||
{ fc::Fkey_backspace , nullptr, "kb" }, // backspace key
|
{ fc::Fkey_backspace , nullptr, "kb" }, // backspace key
|
||||||
{ fc::Fkey_catab , nullptr, "ka" }, // clear-all-tabs key
|
{ fc::Fkey_catab , nullptr, "ka" }, // clear-all-tabs key
|
||||||
{ fc::Fkey_clear , nullptr, "kC" }, // clear-screen or erase key
|
{ fc::Fkey_clear , nullptr, "kC" }, // clear-screen or erase key
|
||||||
{ fc::Fkey_ctab , nullptr, "kt" }, // clear-tab key
|
{ fc::Fkey_ctab , nullptr, "kt" }, // clear-tab key
|
||||||
{ fc::Fkey_dc , nullptr, "kD" }, // delete-character key
|
{ fc::Fkey_dc , nullptr, "kD" }, // delete-character key
|
||||||
{ fc::Fkey_dc , nullptr, "kDx"}, // keypad delete
|
|
||||||
{ fc::Fkey_dl , nullptr, "kL" }, // delete-line key
|
{ fc::Fkey_dl , nullptr, "kL" }, // delete-line key
|
||||||
{ fc::Fkey_down , nullptr, "kd" }, // down-arrow key
|
{ fc::Fkey_down , nullptr, "kd" }, // down-arrow key
|
||||||
{ fc::Fkey_eic , nullptr, "kM" }, // sent by rmir or smir in insert mode
|
{ fc::Fkey_eic , nullptr, "kM" }, // sent by rmir or smir in insert mode
|
||||||
|
@ -184,38 +184,52 @@ FKeyMap fkey[] =
|
||||||
{ fc::Fkey_f63 , nullptr, "Fr" }, // F63 function key
|
{ fc::Fkey_f63 , nullptr, "Fr" }, // F63 function key
|
||||||
// Some terminals (e.g. PuTTY) send vt100 key codes
|
// Some terminals (e.g. PuTTY) send vt100 key codes
|
||||||
// when the arrow and function keys are pressed
|
// when the arrow and function keys are pressed
|
||||||
{ fc::Fkey_down , CSI "B", "kdx"}, // down-arrow key (standard mode)
|
{ fc::Fkey_f1 , ESC "OP", "k1x"}, // PF1 (application mode)
|
||||||
{ fc::Fkey_down , ESC "OB", "kdX"}, // down-arrow key (application mode)
|
{ fc::Fkey_f2 , ESC "OQ", "k2x"}, // PF2 (application mode)
|
||||||
{ fc::Fkey_f1 , ESC "OP", "k1X"}, // PF1 (application mode)
|
{ fc::Fkey_f3 , ESC "OR", "k3x"}, // PF3 (application mode)
|
||||||
{ fc::Fkey_f2 , ESC "OQ", "k2X"}, // PF2 (application mode)
|
{ fc::Fkey_f4 , ESC "OS", "k4x"}, // PF4 (application mode)
|
||||||
{ fc::Fkey_f3 , ESC "OR", "k3X"}, // PF3 (application mode)
|
|
||||||
{ fc::Fkey_f4 , ESC "OS", "k4X"}, // PF4 (application mode)
|
|
||||||
{ fc::Fkey_left , CSI "D", "klx"}, // left-arrow key (standard mode)
|
{ fc::Fkey_left , CSI "D", "klx"}, // left-arrow key (standard mode)
|
||||||
{ fc::Fkey_left , ESC "OD", "klX"}, // left-arrow key (application mode)
|
{ fc::Fkey_left , ESC "OD", "klX"}, // left-arrow key (application mode)
|
||||||
{ fc::Fkey_right , CSI "C", "krx"}, // right-arrow key (standard mode)
|
{ fc::Fkey_right , CSI "C", "krx"}, // right-arrow key (standard mode)
|
||||||
{ fc::Fkey_right , ESC "OC", "krX"}, // right-arrow key (application mode)
|
{ fc::Fkey_right , ESC "OC", "krX"}, // right-arrow key (application mode)
|
||||||
{ fc::Fkey_up , CSI "A", "kux"}, // up-arrow key (standard mode)
|
{ fc::Fkey_up , CSI "A", "kux"}, // up-arrow key (standard mode)
|
||||||
{ fc::Fkey_up , ESC "OA", "kuX"}, // up-arrow key (application mode)
|
{ fc::Fkey_up , ESC "OA", "kuX"}, // up-arrow key (application mode)
|
||||||
|
{ fc::Fkey_down , CSI "B", "kdx"}, // down-arrow key (standard mode)
|
||||||
|
{ fc::Fkey_down , ESC "OB", "kdX"}, // down-arrow key (application mode)
|
||||||
|
{ fc::Fkey_sf , CSI "a", "kFx"}, // scroll-forward key (shift-up)
|
||||||
|
{ fc::Fkey_sr , CSI "b", "kRx"}, // scroll-backward key (shift-down)
|
||||||
// Fallback for rxvt with TERM=xterm
|
// Fallback for rxvt with TERM=xterm
|
||||||
{ fc::Fkey_home , CSI "7~", "khx"}, // home key
|
{ fc::Fkey_home , CSI "7~", "khx"}, // home key
|
||||||
{ fc::Fkey_end , CSI "8~", "@7x"}, // end key
|
{ fc::Fkey_end , CSI "8~", "@7x"}, // end key
|
||||||
{ fc::Fkey_f1 , CSI "11~", "k1x"}, // F1 function key
|
{ fc::Fkey_f1 , CSI "11~", "k1X"}, // F1 function key
|
||||||
{ fc::Fkey_f2 , CSI "12~", "k2x"}, // F2 function key
|
{ fc::Fkey_f2 , CSI "12~", "k2X"}, // F2 function key
|
||||||
{ fc::Fkey_f3 , CSI "13~", "k3x"}, // F3 function key
|
{ fc::Fkey_f3 , CSI "13~", "k3X"}, // F3 function key
|
||||||
{ fc::Fkey_f4 , CSI "14~", "k4x"}, // F4 function key
|
{ fc::Fkey_f4 , CSI "14~", "k4X"}, // F4 function key
|
||||||
// Fallback for TERM=ansi
|
// Fallback for TERM=ansi
|
||||||
{ fc::Fkey_end , CSI "K", "@7X"}, // end key
|
{ fc::Fkey_home , CSI "H", "khX"}, // home key
|
||||||
|
{ fc::Fkey_end , CSI "F", "@7X"}, // end key
|
||||||
|
{ fc::Fkey_end , CSI "K", "@7y"}, // end key (Microsoft HyperTerminal)
|
||||||
// Keypad keys
|
// Keypad keys
|
||||||
{ fc::Fkey_enter , ESC "OM", "@8x"}, // enter key
|
{ fc::Fkey_enter , ESC "OM", "@8x"}, // enter key
|
||||||
{ fc::Fkey_slash , ESC "Oo", "KP1"}, // keypad slash
|
{ fc::Fkey_slash , ESC "Oo", "KP1"}, // keypad slash
|
||||||
{ fc::Fkey_asterisk , ESC "Oj", "KP2"}, // keypad asterisk
|
{ fc::Fkey_asterisk , ESC "Oj", "KP2"}, // keypad asterisk
|
||||||
{ fc::Fkey_minus_sign, ESC "Om", "KP3"}, // keypad minus sign
|
{ fc::Fkey_minus_sign, ESC "Om", "KP3"}, // keypad minus sign
|
||||||
{ fc::Fkey_plus_sign , ESC "Ok", "KP4"}, // keypad plus sign
|
{ fc::Fkey_plus_sign , ESC "Ok", "KP4"}, // keypad plus sign
|
||||||
{ 0 , nullptr, "\0" }
|
{ fc::Fkey_ic , ESC "Op", "kIx"}, // keypad insert
|
||||||
};
|
{ fc::Fkey_dc , ESC "On", "kDx"}, // keypad delete
|
||||||
|
{ fc::Fkey_left , ESC "Ot", "kly"}, // keypad left-arrow
|
||||||
|
{ fc::Fkey_right , ESC "Ov", "kry"}, // keypad right-arrow
|
||||||
|
{ fc::Fkey_up , ESC "Ox", "kuy"}, // keypad up-arrow
|
||||||
|
{ fc::Fkey_down , ESC "Or", "kdy"}, // keypad down-arrow
|
||||||
|
{ fc::Fkey_a1 , ESC "Ow", "K1x"}, // keypad upper left
|
||||||
|
{ fc::Fkey_a3 , ESC "Oy", "K3x"}, // keypad upper right
|
||||||
|
{ fc::Fkey_b2 , ESC "Ou", "K2x"}, // keypad center
|
||||||
|
{ fc::Fkey_c1 , ESC "Oq", "K4x"}, // keypad lower left
|
||||||
|
{ fc::Fkey_c3 , ESC "Os", "K5x"} // keypad lower right
|
||||||
|
}};
|
||||||
|
|
||||||
FMetakeyMap fmetakey[] =
|
constexpr std::array<FMetakeyMap, 232> fmetakey =
|
||||||
{
|
{{
|
||||||
{ fc::Fmkey_ic , "\033[2;3~" }, // M-insert
|
{ fc::Fmkey_ic , "\033[2;3~" }, // M-insert
|
||||||
{ fc::Fmkey_ic , "\033\033[2~" }, // M-insert
|
{ fc::Fmkey_ic , "\033\033[2~" }, // M-insert
|
||||||
{ fc::Fmkey_dc , "\033[3;3~" }, // M-delete
|
{ fc::Fmkey_dc , "\033[3;3~" }, // M-delete
|
||||||
|
@ -289,9 +303,13 @@ FMetakeyMap fmetakey[] =
|
||||||
{ fc::Fckey_ppage , "\033[5;5~" }, // ctrl-prev-page
|
{ fc::Fckey_ppage , "\033[5;5~" }, // ctrl-prev-page
|
||||||
{ fc::Fckey_npage , "\033[6;5~" }, // ctrl-next-page
|
{ fc::Fckey_npage , "\033[6;5~" }, // ctrl-next-page
|
||||||
{ fc::Fckey_up , "\033[1;5A" }, // ctrl-up
|
{ fc::Fckey_up , "\033[1;5A" }, // ctrl-up
|
||||||
|
{ fc::Fckey_up , "\033Oa" }, // ctrl-up
|
||||||
{ fc::Fckey_down , "\033[1;5B" }, // ctrl-down
|
{ fc::Fckey_down , "\033[1;5B" }, // ctrl-down
|
||||||
|
{ fc::Fckey_down , "\033Ob" }, // ctrl-down
|
||||||
{ fc::Fckey_right , "\033[1;5C" }, // ctrl-right
|
{ fc::Fckey_right , "\033[1;5C" }, // ctrl-right
|
||||||
|
{ fc::Fckey_right , "\033Oc" }, // ctrl-right
|
||||||
{ fc::Fckey_left , "\033[1;5D" }, // ctrl-left
|
{ fc::Fckey_left , "\033[1;5D" }, // ctrl-left
|
||||||
|
{ fc::Fckey_left , "\033Od" }, // ctrl-left
|
||||||
{ fc::Fckey_sic , "\033[2;6~" }, // shift-ctrl-M-insert
|
{ fc::Fckey_sic , "\033[2;6~" }, // shift-ctrl-M-insert
|
||||||
{ fc::Fckey_sdc , "\033[3;6~" }, // shift-ctrl-M-delete
|
{ fc::Fckey_sdc , "\033[3;6~" }, // shift-ctrl-M-delete
|
||||||
{ fc::Fckey_shome , "\033[1;6H" }, // shift-ctrl-M-home
|
{ fc::Fckey_shome , "\033[1;6H" }, // shift-ctrl-M-home
|
||||||
|
@ -443,12 +461,11 @@ FMetakeyMap fmetakey[] =
|
||||||
{ fc::Fmkey_left_curly_bracket , "\033{" }, // M-{
|
{ fc::Fmkey_left_curly_bracket , "\033{" }, // M-{
|
||||||
{ fc::Fmkey_vertical_bar , "\033|" }, // M-|
|
{ fc::Fmkey_vertical_bar , "\033|" }, // M-|
|
||||||
{ fc::Fmkey_right_curly_bracket , "\033}" }, // M-}
|
{ fc::Fmkey_right_curly_bracket , "\033}" }, // M-}
|
||||||
{ fc::Fmkey_tilde , "\033~" }, // M-~
|
{ fc::Fmkey_tilde , "\033~" } // M-~
|
||||||
{ 0 , "\0" }
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
FKeyName fkeyname[] =
|
constexpr std::array<FKeyName, 388> fkeyname =
|
||||||
{
|
{{
|
||||||
{ fc::Fckey_a , "Ctrl+A" },
|
{ fc::Fckey_a , "Ctrl+A" },
|
||||||
{ fc::Fckey_b , "Ctrl+B" },
|
{ fc::Fckey_b , "Ctrl+B" },
|
||||||
{ fc::Fckey_c , "Ctrl+C" },
|
{ fc::Fckey_c , "Ctrl+C" },
|
||||||
|
@ -836,9 +853,8 @@ FKeyName fkeyname[] =
|
||||||
{ fc::Fkey_mouse , "xterm mouse" },
|
{ fc::Fkey_mouse , "xterm mouse" },
|
||||||
{ fc::Fkey_extended_mouse , "SGR extended mouse" },
|
{ fc::Fkey_extended_mouse , "SGR extended mouse" },
|
||||||
{ fc::Fkey_urxvt_mouse , "urxvt mouse extension" },
|
{ fc::Fkey_urxvt_mouse , "urxvt mouse extension" },
|
||||||
{ fc::Fkey_incomplete , "incomplete key string" },
|
{ fc::Fkey_incomplete , "incomplete key string" }
|
||||||
{ 0 , "\0" }
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace fc
|
} // namespace fc
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include <sys/select.h> // need for FD_ZERO, FD_SET, FD_CLR, ...
|
#include <sys/select.h> // need for FD_ZERO, FD_SET, FD_CLR, ...
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "final/fkeyboard.h"
|
#include "final/fkeyboard.h"
|
||||||
|
@ -86,11 +88,20 @@ void FKeyboard::fetchKeyCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FKeyboard::getKeyName (const FKey keynum) const
|
FString FKeyboard::getKeyName (const FKey keynum) const
|
||||||
{
|
{
|
||||||
for (std::size_t i{0}; fc::fkeyname[i].string[0] != 0; i++)
|
const auto& found_key = std::find_if
|
||||||
if ( fc::fkeyname[i].num && fc::fkeyname[i].num == keynum )
|
(
|
||||||
return FString{fc::fkeyname[i].string};
|
fc::fkeyname.begin(),
|
||||||
|
fc::fkeyname.end(),
|
||||||
|
[&keynum] (const fc::FKeyName& kn)
|
||||||
|
{
|
||||||
|
return (kn.num > 0 && kn.num == keynum);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( found_key != fc::fkeyname.end() )
|
||||||
|
return FString{found_key->string};
|
||||||
|
|
||||||
if ( keynum > 32 && keynum < 127 )
|
if ( keynum > 32 && keynum < 127 )
|
||||||
return FString{char(keynum)};
|
return FString{char(keynum)};
|
||||||
|
@ -99,9 +110,27 @@ const FString FKeyboard::getKeyName (const FKey keynum) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FKeyboard::setTermcapMap (fc::FKeyMap* keymap)
|
bool FKeyboard::setNonBlockingInput (bool enable)
|
||||||
{
|
{
|
||||||
key_map = keymap;
|
if ( enable == non_blocking_stdin )
|
||||||
|
return non_blocking_stdin;
|
||||||
|
|
||||||
|
if ( enable ) // make stdin non-blocking
|
||||||
|
{
|
||||||
|
stdin_status_flags |= O_NONBLOCK;
|
||||||
|
|
||||||
|
if ( fcntl (FTermios::getStdIn(), F_SETFL, stdin_status_flags) != -1 )
|
||||||
|
non_blocking_stdin = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stdin_status_flags &= ~O_NONBLOCK;
|
||||||
|
|
||||||
|
if ( fcntl (FTermios::getStdIn(), F_SETFL, stdin_status_flags) != -1 )
|
||||||
|
non_blocking_stdin = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return non_blocking_stdin;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -221,12 +250,12 @@ inline FKey FKeyboard::getTermcapKey()
|
||||||
|
|
||||||
assert ( FIFO_BUF_SIZE > 0 );
|
assert ( FIFO_BUF_SIZE > 0 );
|
||||||
|
|
||||||
if ( ! key_map )
|
if ( key_map.use_count() == 0 )
|
||||||
return NOT_SET;
|
return NOT_SET;
|
||||||
|
|
||||||
for (std::size_t i{0}; key_map[i].tname[0] != 0; i++)
|
for (auto&& entry : *key_map)
|
||||||
{
|
{
|
||||||
const char* k = key_map[i].string;
|
const char* k = entry.string;
|
||||||
const std::size_t len = ( k ) ? std::strlen(k) : 0;
|
const std::size_t len = ( k ) ? std::strlen(k) : 0;
|
||||||
|
|
||||||
if ( k && std::strncmp(k, fifo_buf, len) == 0 ) // found
|
if ( k && std::strncmp(k, fifo_buf, len) == 0 ) // found
|
||||||
|
@ -240,7 +269,7 @@ inline FKey FKeyboard::getTermcapKey()
|
||||||
fifo_buf[n] = '\0';
|
fifo_buf[n] = '\0';
|
||||||
|
|
||||||
input_data_pending = bool(fifo_buf[0] != '\0');
|
input_data_pending = bool(fifo_buf[0] != '\0');
|
||||||
return fc::fkey[i].num;
|
return entry.num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,9 +283,9 @@ inline FKey FKeyboard::getMetaKey()
|
||||||
|
|
||||||
assert ( FIFO_BUF_SIZE > 0 );
|
assert ( FIFO_BUF_SIZE > 0 );
|
||||||
|
|
||||||
for (std::size_t i{0}; fc::fmetakey[i].string[0] != 0; i++)
|
for (auto&& entry : fc::fmetakey)
|
||||||
{
|
{
|
||||||
const char* kmeta = fc::fmetakey[i].string; // The string is never null
|
const char* kmeta = entry.string; // The string is never null
|
||||||
const std::size_t len = std::strlen(kmeta);
|
const std::size_t len = std::strlen(kmeta);
|
||||||
|
|
||||||
if ( std::strncmp(kmeta, fifo_buf, len) == 0 ) // found
|
if ( std::strncmp(kmeta, fifo_buf, len) == 0 ) // found
|
||||||
|
@ -279,7 +308,7 @@ inline FKey FKeyboard::getMetaKey()
|
||||||
fifo_buf[n] = '\0';
|
fifo_buf[n] = '\0';
|
||||||
|
|
||||||
input_data_pending = bool(fifo_buf[0] != '\0');
|
input_data_pending = bool(fifo_buf[0] != '\0');
|
||||||
return fc::fmetakey[i].num;
|
return entry.num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,13 +322,13 @@ inline FKey FKeyboard::getSingleKey()
|
||||||
|
|
||||||
std::size_t n{};
|
std::size_t n{};
|
||||||
std::size_t len{1};
|
std::size_t len{1};
|
||||||
const uChar firstchar = uChar(fifo_buf[0]);
|
const auto firstchar = uChar(fifo_buf[0]);
|
||||||
FKey keycode{};
|
FKey keycode{};
|
||||||
|
|
||||||
// Look for a utf-8 character
|
// Look for a utf-8 character
|
||||||
if ( utf8_input && (firstchar & 0xc0) == 0xc0 )
|
if ( utf8_input && (firstchar & 0xc0) == 0xc0 )
|
||||||
{
|
{
|
||||||
char utf8char[5]{}; // Init array with '\0'
|
std::array<char, 5> utf8char{}; // Init array with '\0'
|
||||||
const std::size_t buf_len = std::strlen(fifo_buf);
|
const std::size_t buf_len = std::strlen(fifo_buf);
|
||||||
|
|
||||||
if ( (firstchar & 0xe0) == 0xc0 )
|
if ( (firstchar & 0xe0) == 0xc0 )
|
||||||
|
@ -315,7 +344,7 @@ inline FKey FKeyboard::getSingleKey()
|
||||||
for (std::size_t i{0}; i < len ; i++)
|
for (std::size_t i{0}; i < len ; i++)
|
||||||
utf8char[i] = char(fifo_buf[i] & 0xff);
|
utf8char[i] = char(fifo_buf[i] & 0xff);
|
||||||
|
|
||||||
keycode = UTF8decode(utf8char);
|
keycode = UTF8decode(utf8char.data());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
keycode = uChar(fifo_buf[0] & 0xff);
|
keycode = uChar(fifo_buf[0] & 0xff);
|
||||||
|
@ -334,30 +363,6 @@ inline FKey FKeyboard::getSingleKey()
|
||||||
return FKey(keycode == 127 ? fc::Fkey_backspace : keycode);
|
return FKey(keycode == 127 ? fc::Fkey_backspace : keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
bool FKeyboard::setNonBlockingInput (bool enable)
|
|
||||||
{
|
|
||||||
if ( enable == non_blocking_stdin )
|
|
||||||
return non_blocking_stdin;
|
|
||||||
|
|
||||||
if ( enable ) // make stdin non-blocking
|
|
||||||
{
|
|
||||||
stdin_status_flags |= O_NONBLOCK;
|
|
||||||
|
|
||||||
if ( fcntl (FTermios::getStdIn(), F_SETFL, stdin_status_flags) != -1 )
|
|
||||||
non_blocking_stdin = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stdin_status_flags &= ~O_NONBLOCK;
|
|
||||||
|
|
||||||
if ( fcntl (FTermios::getStdIn(), F_SETFL, stdin_status_flags) != -1 )
|
|
||||||
non_blocking_stdin = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return non_blocking_stdin;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FKeyboard::isKeypressTimeout()
|
inline bool FKeyboard::isKeypressTimeout()
|
||||||
{
|
{
|
||||||
|
@ -382,7 +387,7 @@ FKey FKeyboard::UTF8decode (const char utf8[]) const
|
||||||
|
|
||||||
for (std::size_t i{0}; i < len; ++i)
|
for (std::size_t i{0}; i < len; ++i)
|
||||||
{
|
{
|
||||||
const uChar ch = uChar(utf8[i]);
|
const auto ch = uChar(utf8[i]);
|
||||||
|
|
||||||
if ( (ch & 0xc0) == 0x80 )
|
if ( (ch & 0xc0) == 0x80 )
|
||||||
{
|
{
|
||||||
|
@ -475,7 +480,7 @@ void FKeyboard::parseKeyBuffer()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FKey FKeyboard::parseKeyString()
|
FKey FKeyboard::parseKeyString()
|
||||||
{
|
{
|
||||||
const uChar firstchar = uChar(fifo_buf[0]);
|
const auto firstchar = uChar(fifo_buf[0]);
|
||||||
|
|
||||||
if ( firstchar == ESC[0] )
|
if ( firstchar == ESC[0] )
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,13 +20,14 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
#include "final/fapplication.h"
|
#include "final/fapplication.h"
|
||||||
#include "final/fevent.h"
|
#include "final/fevent.h"
|
||||||
#include "final/flabel.h"
|
#include "final/flabel.h"
|
||||||
#include "final/flog.h"
|
|
||||||
#include "final/flineedit.h"
|
#include "final/flineedit.h"
|
||||||
|
#include "final/flog.h"
|
||||||
#include "final/fpoint.h"
|
#include "final/fpoint.h"
|
||||||
#include "final/fsize.h"
|
#include "final/fsize.h"
|
||||||
#include "final/fstatusbar.h"
|
#include "final/fstatusbar.h"
|
||||||
|
@ -752,7 +753,7 @@ void FLineEdit::drawInputField()
|
||||||
|
|
||||||
// set the cursor to the insert pos.
|
// set the cursor to the insert pos.
|
||||||
const auto cursor_pos_column = getCursorColumnPos();
|
const auto cursor_pos_column = getCursorColumnPos();
|
||||||
const int xpos = int(2 + cursor_pos_column
|
const auto xpos = int(2 + cursor_pos_column
|
||||||
- text_offset_column
|
- text_offset_column
|
||||||
+ char_width_offset);
|
+ char_width_offset);
|
||||||
setCursorPos ({xpos, 1});
|
setCursorPos ({xpos, 1});
|
||||||
|
@ -802,7 +803,7 @@ inline std::size_t FLineEdit::getCursorColumnPos() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString FLineEdit::getPasswordText() const
|
inline FString FLineEdit::getPasswordText() const
|
||||||
{
|
{
|
||||||
return FString{text.getLength(), fc::Bullet}; // •
|
return FString{text.getLength(), fc::Bullet}; // •
|
||||||
}
|
}
|
||||||
|
@ -833,7 +834,7 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
|
||||||
}
|
}
|
||||||
catch (const std::out_of_range& ex)
|
catch (const std::out_of_range& ex)
|
||||||
{
|
{
|
||||||
*FApplication::getLog() << FLog::Error
|
std::clog << FLog::Error
|
||||||
<< "Out of Range error: " << ex.what() << std::endl;
|
<< "Out of Range error: " << ex.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,7 +858,7 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
|
||||||
}
|
}
|
||||||
catch (const std::out_of_range& ex)
|
catch (const std::out_of_range& ex)
|
||||||
{
|
{
|
||||||
*FApplication::getLog() << FLog::Error
|
std::clog << FLog::Error
|
||||||
<< "Out of Range error: " << ex.what() << std::endl;
|
<< "Out of Range error: " << ex.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -893,7 +894,7 @@ std::size_t FLineEdit::clickPosToCursorPos (std::size_t pos)
|
||||||
}
|
}
|
||||||
catch (const std::out_of_range& ex)
|
catch (const std::out_of_range& ex)
|
||||||
{
|
{
|
||||||
*FApplication::getLog() << FLog::Error
|
std::clog << FLog::Error
|
||||||
<< "Out of Range error: " << ex.what() << std::endl;
|
<< "Out of Range error: " << ex.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -927,7 +928,7 @@ void FLineEdit::adjustTextOffset()
|
||||||
}
|
}
|
||||||
catch (const std::out_of_range& ex)
|
catch (const std::out_of_range& ex)
|
||||||
{
|
{
|
||||||
*FApplication::getLog() << FLog::Error
|
std::clog << FLog::Error
|
||||||
<< "Out of Range error: " << ex.what() << std::endl;
|
<< "Out of Range error: " << ex.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -940,7 +941,7 @@ void FLineEdit::adjustTextOffset()
|
||||||
}
|
}
|
||||||
catch (const std::out_of_range& ex)
|
catch (const std::out_of_range& ex)
|
||||||
{
|
{
|
||||||
*FApplication::getLog() << FLog::Error
|
std::clog << FLog::Error
|
||||||
<< "Out of Range error: " << ex.what() << std::endl;
|
<< "Out of Range error: " << ex.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1109,9 +1110,9 @@ inline wchar_t FLineEdit::characterFilter (const wchar_t c) const
|
||||||
if ( input_filter.empty() )
|
if ( input_filter.empty() )
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
const wchar_t character[2]{c, L'\0'};
|
std::array<const wchar_t, 2> character{{c, L'\0'}};
|
||||||
|
|
||||||
if ( regex_match(character, std::wregex(input_filter)) )
|
if ( regex_match(character.data(), std::wregex(input_filter)) )
|
||||||
return c;
|
return c;
|
||||||
else
|
else
|
||||||
return L'\0';
|
return L'\0';
|
||||||
|
|
|
@ -51,12 +51,6 @@ FListBoxItem::FListBoxItem (const FListBoxItem& item)
|
||||||
, selected{item.selected}
|
, selected{item.selected}
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
FListBoxItem::FListBoxItem (const FString& txt, FDataPtr data)
|
|
||||||
: text{txt}
|
|
||||||
, data_pointer{data}
|
|
||||||
{ }
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FListBoxItem::~FListBoxItem() // destructor
|
FListBoxItem::~FListBoxItem() // destructor
|
||||||
{ }
|
{ }
|
||||||
|
@ -95,6 +89,9 @@ FListBox::FListBox (FWidget* parent)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FListBox::~FListBox() // destructor
|
FListBox::~FListBox() // destructor
|
||||||
{
|
{
|
||||||
|
if ( source_container )
|
||||||
|
delete source_container; // for lazy conversion
|
||||||
|
|
||||||
delOwnTimers();
|
delOwnTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +120,7 @@ void FListBox::setCurrentItem (std::size_t index)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListBox::setCurrentItem (listBoxItems::iterator iter)
|
void FListBox::setCurrentItem (FListBoxItems::iterator iter)
|
||||||
{
|
{
|
||||||
const auto index = std::size_t(std::distance(itemlist.begin(), iter)) + 1;
|
const auto index = std::size_t(std::distance(itemlist.begin(), iter)) + 1;
|
||||||
setCurrentItem(index);
|
setCurrentItem(index);
|
||||||
|
@ -644,7 +641,7 @@ void FListBox::adjustSize()
|
||||||
|
|
||||||
// private methods of FListBox
|
// private methods of FListBox
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FString FListBox::getString (listBoxItems::iterator iter)
|
inline FString FListBox::getString (FListBoxItems::iterator iter)
|
||||||
{
|
{
|
||||||
return iter->getText();
|
return iter->getText();
|
||||||
}
|
}
|
||||||
|
@ -695,7 +692,7 @@ inline void FListBox::mapKeyFunctions()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListBox::processKeyAction (FKeyEvent* ev)
|
void FListBox::processKeyAction (FKeyEvent* ev)
|
||||||
{
|
{
|
||||||
const int idx = int(ev->key());
|
const auto idx = int(ev->key());
|
||||||
|
|
||||||
if ( key_map.find(idx) != key_map.end() )
|
if ( key_map.find(idx) != key_map.end() )
|
||||||
{
|
{
|
||||||
|
@ -837,7 +834,7 @@ void FListBox::drawList()
|
||||||
const bool lineHasBrackets = hasBrackets(iter);
|
const bool lineHasBrackets = hasBrackets(iter);
|
||||||
|
|
||||||
// Import data via lazy conversion
|
// Import data via lazy conversion
|
||||||
lazyConvert (iter, int(y));
|
lazyConvert (iter, y);
|
||||||
|
|
||||||
// Set screen position and attributes
|
// Set screen position and attributes
|
||||||
setLineAttributes ( int(y), isSelected(iter), lineHasBrackets
|
setLineAttributes ( int(y), isSelected(iter), lineHasBrackets
|
||||||
|
@ -863,7 +860,7 @@ void FListBox::drawList()
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FListBox::drawListLine ( int y
|
inline void FListBox::drawListLine ( int y
|
||||||
, listBoxItems::iterator iter
|
, FListBoxItems::iterator iter
|
||||||
, bool serach_mark )
|
, bool serach_mark )
|
||||||
{
|
{
|
||||||
const std::size_t inc_len = inc_search.getLength();
|
const std::size_t inc_len = inc_search.getLength();
|
||||||
|
@ -918,7 +915,7 @@ inline void FListBox::printRightBracket (fc::brackets_type bracket_type)
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FListBox::drawListBracketsLine ( int y
|
inline void FListBox::drawListBracketsLine ( int y
|
||||||
, listBoxItems::iterator iter
|
, FListBoxItems::iterator iter
|
||||||
, bool serach_mark )
|
, bool serach_mark )
|
||||||
{
|
{
|
||||||
std::size_t b{0};
|
std::size_t b{0};
|
||||||
|
@ -936,7 +933,7 @@ inline void FListBox::drawListBracketsLine ( int y
|
||||||
printLeftBracket (iter->brackets);
|
printLeftBracket (iter->brackets);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::size_t first = std::size_t(xoffset);
|
const auto first = std::size_t(xoffset);
|
||||||
const std::size_t max_width = getWidth() - nf_offset - 4 - b;
|
const std::size_t max_width = getWidth() - nf_offset - 4 - b;
|
||||||
const FString element(getColumnSubString (getString(iter), first, max_width));
|
const FString element(getColumnSubString (getString(iter), first, max_width));
|
||||||
std::size_t column_width = getColumnWidth(element);
|
std::size_t column_width = getColumnWidth(element);
|
||||||
|
@ -1236,7 +1233,7 @@ void FListBox::wheelUp (int pagesize)
|
||||||
void FListBox::wheelDown (int pagesize)
|
void FListBox::wheelDown (int pagesize)
|
||||||
{
|
{
|
||||||
const std::size_t element_count = getCount();
|
const std::size_t element_count = getCount();
|
||||||
int yoffset_end = int(element_count - getClientHeight());
|
auto yoffset_end = int(element_count - getClientHeight());
|
||||||
|
|
||||||
if ( yoffset_end < 0 )
|
if ( yoffset_end < 0 )
|
||||||
yoffset_end = 0;
|
yoffset_end = 0;
|
||||||
|
@ -1369,7 +1366,7 @@ void FListBox::prevListItem (int distance)
|
||||||
void FListBox::nextListItem (int distance)
|
void FListBox::nextListItem (int distance)
|
||||||
{
|
{
|
||||||
const std::size_t element_count = getCount();
|
const std::size_t element_count = getCount();
|
||||||
const int yoffset_end = int(element_count - getClientHeight());
|
const auto yoffset_end = int(element_count - getClientHeight());
|
||||||
|
|
||||||
if ( current == element_count )
|
if ( current == element_count )
|
||||||
return;
|
return;
|
||||||
|
@ -1410,7 +1407,7 @@ void FListBox::scrollToX (int val)
|
||||||
void FListBox::scrollToY (int val)
|
void FListBox::scrollToY (int val)
|
||||||
{
|
{
|
||||||
const std::size_t element_count = getCount();
|
const std::size_t element_count = getCount();
|
||||||
const int yoffset_end = int(element_count - getClientHeight());
|
const auto yoffset_end = int(element_count - getClientHeight());
|
||||||
|
|
||||||
if ( yoffset == val )
|
if ( yoffset == val )
|
||||||
return;
|
return;
|
||||||
|
@ -1519,7 +1516,7 @@ inline void FListBox::firstPos()
|
||||||
inline void FListBox::lastPos()
|
inline void FListBox::lastPos()
|
||||||
{
|
{
|
||||||
const std::size_t element_count = getCount();
|
const std::size_t element_count = getCount();
|
||||||
const int yoffset_end = int(element_count - getClientHeight());
|
const auto yoffset_end = int(element_count - getClientHeight());
|
||||||
current = element_count;
|
current = element_count;
|
||||||
|
|
||||||
if ( current > getClientHeight() )
|
if ( current > getClientHeight() )
|
||||||
|
@ -1625,8 +1622,9 @@ inline bool FListBox::deletePreviousCharacter()
|
||||||
{
|
{
|
||||||
const std::size_t inc_len = inc_search.getLength();
|
const std::size_t inc_len = inc_search.getLength();
|
||||||
|
|
||||||
if ( inc_len > 0 )
|
if ( inc_len == 0 )
|
||||||
{
|
return false;
|
||||||
|
|
||||||
inc_search.remove(inc_len - 1, 1);
|
inc_search.remove(inc_len - 1, 1);
|
||||||
|
|
||||||
if ( inc_len > 1 )
|
if ( inc_len > 1 )
|
||||||
|
@ -1647,9 +1645,6 @@ inline bool FListBox::deletePreviousCharacter()
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1729,12 +1724,12 @@ void FListBox::changeOnResize() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
|
void FListBox::lazyConvert(FListBoxItems::iterator iter, std::size_t y)
|
||||||
{
|
{
|
||||||
if ( conv_type != lazy_convert || ! iter->getText().isNull() )
|
if ( conv_type != lazy_convert || ! iter->getText().isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lazy_inserter (*iter, source_container, y + yoffset);
|
lazy_inserter (*iter, source_container, y + std::size_t(yoffset));
|
||||||
const auto column_width = getColumnWidth(iter->text);
|
const auto column_width = getColumnWidth(iter->text);
|
||||||
recalculateHorizontalBar (column_width, hasBrackets(iter));
|
recalculateHorizontalBar (column_width, hasBrackets(iter));
|
||||||
|
|
||||||
|
|
|
@ -198,21 +198,6 @@ FListViewItem::FListViewItem (iterator parent_iter)
|
||||||
insert (this, parent_iter);
|
insert (this, parent_iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
FListViewItem::FListViewItem ( const FStringList& cols
|
|
||||||
, FDataPtr data
|
|
||||||
, iterator parent_iter )
|
|
||||||
: FObject{nullptr}
|
|
||||||
, column_list{cols}
|
|
||||||
, data_pointer{data}
|
|
||||||
{
|
|
||||||
if ( cols.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
replaceControlCodes();
|
|
||||||
insert (this, parent_iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FListViewItem::~FListViewItem() // destructor
|
FListViewItem::~FListViewItem() // destructor
|
||||||
{
|
{
|
||||||
|
@ -254,7 +239,7 @@ FString FListViewItem::getText (int column) const
|
||||||
return fc::emptyFString::get();
|
return fc::emptyFString::get();
|
||||||
|
|
||||||
// Convert column position to address offset (index)
|
// Convert column position to address offset (index)
|
||||||
const std::size_t index = std::size_t(column - 1);
|
const auto index = std::size_t(column - 1);
|
||||||
return column_list[index];
|
return column_list[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +275,7 @@ void FListViewItem::setText (int column, const FString& text)
|
||||||
|
|
||||||
if ( ! listview->header[index].fixed_width )
|
if ( ! listview->header[index].fixed_width )
|
||||||
{
|
{
|
||||||
const int column_width = int(getColumnWidth(text));
|
const auto column_width = int(getColumnWidth(text));
|
||||||
|
|
||||||
if ( column_width > listview->header[index].width )
|
if ( column_width > listview->header[index].width )
|
||||||
listview->header[index].width = column_width;
|
listview->header[index].width = column_width;
|
||||||
|
@ -720,7 +705,7 @@ fc::text_alignment FListView::getColumnAlignment (int column) const
|
||||||
return fc::alignLeft;
|
return fc::alignLeft;
|
||||||
|
|
||||||
// Convert column position to address offset (index)
|
// Convert column position to address offset (index)
|
||||||
const std::size_t index = std::size_t(column - 1);
|
const auto index = std::size_t(column - 1);
|
||||||
return header[index].alignment;
|
return header[index].alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,7 +718,7 @@ FString FListView::getColumnText (int column) const
|
||||||
return fc::emptyFString::get();
|
return fc::emptyFString::get();
|
||||||
|
|
||||||
// Convert column position to address offset (index)
|
// Convert column position to address offset (index)
|
||||||
const std::size_t index = std::size_t(column - 1);
|
const auto index = std::size_t(column - 1);
|
||||||
return header[index].name;
|
return header[index].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,7 +726,7 @@ FString FListView::getColumnText (int column) const
|
||||||
fc::sorting_type FListView::getColumnSortType (int column) const
|
fc::sorting_type FListView::getColumnSortType (int column) const
|
||||||
{
|
{
|
||||||
fc::sorting_type type;
|
fc::sorting_type type;
|
||||||
const std::size_t col = std::size_t(column);
|
const auto col = std::size_t(column);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -779,7 +764,7 @@ void FListView::setColumnAlignment (int column, fc::text_alignment align)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Convert column position to address offset (index)
|
// Convert column position to address offset (index)
|
||||||
const std::size_t index = std::size_t(column - 1);
|
const auto index = std::size_t(column - 1);
|
||||||
header[index].alignment = align;
|
header[index].alignment = align;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,11 +777,11 @@ void FListView::setColumnText (int column, const FString& label)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Convert column position to address offset (index)
|
// Convert column position to address offset (index)
|
||||||
std::size_t index = std::size_t(column - 1);
|
auto index = std::size_t(column - 1);
|
||||||
|
|
||||||
if ( ! header[index].fixed_width )
|
if ( ! header[index].fixed_width )
|
||||||
{
|
{
|
||||||
const int column_width = int(getColumnWidth(label));
|
const auto column_width = int(getColumnWidth(label));
|
||||||
|
|
||||||
if ( column_width > header[index].width )
|
if ( column_width > header[index].width )
|
||||||
header[index].width = column_width;
|
header[index].width = column_width;
|
||||||
|
@ -895,33 +880,6 @@ FObject::iterator FListView::insert ( FListViewItem* item
|
||||||
return item_iter;
|
return item_iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
FObject::iterator FListView::insert ( const FStringList& cols
|
|
||||||
, FDataPtr d
|
|
||||||
, iterator parent_iter )
|
|
||||||
{
|
|
||||||
FListViewItem* item;
|
|
||||||
|
|
||||||
if ( cols.empty() || parent_iter == getNullIterator() )
|
|
||||||
return getNullIterator();
|
|
||||||
|
|
||||||
if ( ! *parent_iter )
|
|
||||||
parent_iter = root;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
item = new FListViewItem (cols, d, getNullIterator());
|
|
||||||
}
|
|
||||||
catch (const std::bad_alloc&)
|
|
||||||
{
|
|
||||||
badAllocOutput ("FListViewItem");
|
|
||||||
return getNullIterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
item->replaceControlCodes();
|
|
||||||
return insert(item, parent_iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListView::remove (FListViewItem* item)
|
void FListView::remove (FListViewItem* item)
|
||||||
{
|
{
|
||||||
|
@ -1417,7 +1375,7 @@ void FListView::onFocusOut (FFocusEvent*)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListView::adjustViewport (const int element_count)
|
void FListView::adjustViewport (const int element_count)
|
||||||
{
|
{
|
||||||
const int height = int(getClientHeight());
|
const auto height = int(getClientHeight());
|
||||||
|
|
||||||
if ( height <= 0 || element_count == 0 )
|
if ( height <= 0 || element_count == 0 )
|
||||||
return;
|
return;
|
||||||
|
@ -1553,7 +1511,7 @@ inline void FListView::mapKeyFunctions()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListView::processKeyAction (FKeyEvent* ev)
|
void FListView::processKeyAction (FKeyEvent* ev)
|
||||||
{
|
{
|
||||||
const int idx = int(ev->key());
|
const auto idx = int(ev->key());
|
||||||
|
|
||||||
if ( key_map.find(idx) != key_map.end() )
|
if ( key_map.find(idx) != key_map.end() )
|
||||||
{
|
{
|
||||||
|
@ -1704,7 +1662,7 @@ void FListView::drawHeadlines()
|
||||||
|| max_line_width < 1 )
|
|| max_line_width < 1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
headerItems::const_iterator iter = header.begin();
|
HeaderItems::const_iterator iter = header.begin();
|
||||||
headerline.clear();
|
headerline.clear();
|
||||||
|
|
||||||
if ( hasCheckableItems() )
|
if ( hasCheckableItems() )
|
||||||
|
@ -1802,7 +1760,7 @@ void FListView::drawListLine ( const FListViewItem* item
|
||||||
{
|
{
|
||||||
static constexpr std::size_t ellipsis_length = 2;
|
static constexpr std::size_t ellipsis_length = 2;
|
||||||
const auto& text = item->column_list[col];
|
const auto& text = item->column_list[col];
|
||||||
std::size_t width = std::size_t(header[col].width);
|
auto width = std::size_t(header[col].width);
|
||||||
const std::size_t column_width = getColumnWidth(text);
|
const std::size_t column_width = getColumnWidth(text);
|
||||||
// Increment the value of col for the column position
|
// Increment the value of col for the column position
|
||||||
// and the next iteration
|
// and the next iteration
|
||||||
|
@ -2025,16 +1983,16 @@ inline void FListView::drawHeaderBorder (std::size_t length)
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListView::drawHeadlineLabel (const headerItems::const_iterator& iter)
|
void FListView::drawHeadlineLabel (const HeaderItems::const_iterator& iter)
|
||||||
{
|
{
|
||||||
// Print label text
|
// Print label text
|
||||||
static constexpr std::size_t leading_space = 1;
|
static constexpr std::size_t leading_space = 1;
|
||||||
const auto& text = iter->name;
|
const auto& text = iter->name;
|
||||||
FString txt{" " + text};
|
FString txt{" " + text};
|
||||||
const std::size_t width = std::size_t(iter->width);
|
const auto width = std::size_t(iter->width);
|
||||||
std::size_t column_width = getColumnWidth(txt);
|
std::size_t column_width = getColumnWidth(txt);
|
||||||
const std::size_t column_max = leading_space + width;
|
const std::size_t column_max = leading_space + width;
|
||||||
const headerItems::const_iterator first = header.begin();
|
const HeaderItems::const_iterator first = header.begin();
|
||||||
const int column = int(std::distance(first, iter)) + 1;
|
const int column = int(std::distance(first, iter)) + 1;
|
||||||
const bool has_sort_indicator( sort_column == column && ! hide_sort_indicator );
|
const bool has_sort_indicator( sort_column == column && ! hide_sort_indicator );
|
||||||
const auto& wc = getColorTheme();
|
const auto& wc = getColorTheme();
|
||||||
|
@ -2161,7 +2119,7 @@ void FListView::drawBufferedHeadline()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListView::drawColumnEllipsis ( const headerItems::const_iterator& iter
|
void FListView::drawColumnEllipsis ( const HeaderItems::const_iterator& iter
|
||||||
, const FString& text )
|
, const FString& text )
|
||||||
{
|
{
|
||||||
// Print label ellipsis
|
// Print label ellipsis
|
||||||
|
@ -2211,7 +2169,7 @@ std::size_t FListView::determineLineWidth (FListViewItem* item)
|
||||||
|
|
||||||
for (auto&& header_item : header)
|
for (auto&& header_item : header)
|
||||||
{
|
{
|
||||||
const std::size_t width = std::size_t(header_item.width);
|
const auto width = std::size_t(header_item.width);
|
||||||
const bool fixed_width = header_item.fixed_width;
|
const bool fixed_width = header_item.fixed_width;
|
||||||
|
|
||||||
if ( ! fixed_width )
|
if ( ! fixed_width )
|
||||||
|
@ -2318,7 +2276,7 @@ void FListView::mouseHeaderClicked()
|
||||||
{
|
{
|
||||||
static constexpr int leading_space = 1;
|
static constexpr int leading_space = 1;
|
||||||
const bool has_sort_indicator( column == sort_column );
|
const bool has_sort_indicator( column == sort_column );
|
||||||
int click_width = int(getColumnWidth(item.name));
|
auto click_width = int(getColumnWidth(item.name));
|
||||||
|
|
||||||
if ( has_sort_indicator )
|
if ( has_sort_indicator )
|
||||||
click_width += 2;
|
click_width += 2;
|
||||||
|
@ -2377,7 +2335,7 @@ void FListView::wheelDown (int pagesize)
|
||||||
if ( itemlist.empty() )
|
if ( itemlist.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int element_count = int(getCount());
|
const auto element_count = int(getCount());
|
||||||
|
|
||||||
if ( current_iter.getPosition() + 1 == element_count )
|
if ( current_iter.getPosition() + 1 == element_count )
|
||||||
return;
|
return;
|
||||||
|
@ -2416,7 +2374,7 @@ bool FListView::dragScrollUp (int position_before)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FListView::dragScrollDown (int position_before)
|
bool FListView::dragScrollDown (int position_before)
|
||||||
{
|
{
|
||||||
const int element_count = int(getCount());
|
const auto element_count = int(getCount());
|
||||||
|
|
||||||
if ( position_before + 1 == element_count )
|
if ( position_before + 1 == element_count )
|
||||||
{
|
{
|
||||||
|
@ -2635,7 +2593,7 @@ inline void FListView::lastPos()
|
||||||
if ( itemlist.empty() )
|
if ( itemlist.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int element_count = int(getCount());
|
const auto element_count = int(getCount());
|
||||||
current_iter += element_count - current_iter.getPosition() - 1;
|
current_iter += element_count - current_iter.getPosition() - 1;
|
||||||
const int difference = element_count - last_visible_line.getPosition() - 1;
|
const int difference = element_count - last_visible_line.getPosition() - 1;
|
||||||
first_visible_line += difference;
|
first_visible_line += difference;
|
||||||
|
@ -2730,7 +2688,7 @@ void FListView::stepForward (int distance)
|
||||||
if ( itemlist.empty() )
|
if ( itemlist.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int element_count = int(getCount());
|
const auto element_count = int(getCount());
|
||||||
|
|
||||||
if ( current_iter.getPosition() + 1 == element_count )
|
if ( current_iter.getPosition() + 1 == element_count )
|
||||||
return;
|
return;
|
||||||
|
@ -2811,7 +2769,7 @@ void FListView::scrollToX (int x)
|
||||||
void FListView::scrollToY (int y)
|
void FListView::scrollToY (int y)
|
||||||
{
|
{
|
||||||
const int pagesize = int(getClientHeight()) - 1;
|
const int pagesize = int(getClientHeight()) - 1;
|
||||||
const int element_count = int(getCount());
|
const auto element_count = int(getCount());
|
||||||
|
|
||||||
if ( first_visible_line.getPosition() == y )
|
if ( first_visible_line.getPosition() == y )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -47,6 +47,7 @@ FLog& FLog::operator << (LogLevel l)
|
||||||
{
|
{
|
||||||
using std::placeholders::_1;
|
using std::placeholders::_1;
|
||||||
sync();
|
sync();
|
||||||
|
std::lock_guard<std::mutex> lock_guard(mut);
|
||||||
|
|
||||||
switch ( l )
|
switch ( l )
|
||||||
{
|
{
|
||||||
|
@ -77,6 +78,7 @@ int FLog::sync()
|
||||||
{
|
{
|
||||||
if ( ! str().empty() )
|
if ( ! str().empty() )
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock_guard(mut);
|
||||||
current_log (str());
|
current_log (str());
|
||||||
str("");
|
str("");
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "final/flogger.h"
|
#include "final/flogger.h"
|
||||||
|
@ -58,21 +59,23 @@ void FLogger::newlineReplace ( std::string& str
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const std::string FLogger::getTimeString() const
|
std::string FLogger::getTimeString() const
|
||||||
{
|
{
|
||||||
char str[100];
|
std::array<char, 100> str;
|
||||||
const auto& now = std::chrono::system_clock::now();
|
const auto& now = std::chrono::system_clock::now();
|
||||||
const auto& t = std::chrono::system_clock::to_time_t(now);
|
const auto& t = std::chrono::system_clock::to_time_t(now);
|
||||||
// Print RFC 2822 date
|
// Print RFC 2822 date
|
||||||
struct tm time{};
|
struct tm time{};
|
||||||
localtime_r (&t, &time);
|
localtime_r (&t, &time);
|
||||||
std::strftime (str, sizeof(str), "%a, %d %b %Y %T %z", &time);
|
std::strftime (str.data(), str.size(), "%a, %d %b %Y %T %z", &time);
|
||||||
return std::string(str);
|
return std::string(str.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const std::string FLogger::getEOL() const
|
std::string FLogger::getEOL()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock_guard(getMutex());
|
||||||
|
|
||||||
if ( getEnding() == FLog::LF )
|
if ( getEnding() == FLog::LF )
|
||||||
return "\n";
|
return "\n";
|
||||||
else if ( getEnding() == FLog::CR )
|
else if ( getEnding() == FLog::CR )
|
||||||
|
@ -88,6 +91,8 @@ void FLogger::printLogLine (const std::string& msg)
|
||||||
{
|
{
|
||||||
const std::string& log_level = [this] ()
|
const std::string& log_level = [this] ()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock_guard(getMutex());
|
||||||
|
|
||||||
switch ( getLevel() )
|
switch ( getLevel() )
|
||||||
{
|
{
|
||||||
case Info:
|
case Info:
|
||||||
|
|
|
@ -136,13 +136,8 @@ void FMenu::onKeyPress (FKeyEvent* ev)
|
||||||
// looking for menu bar hotkey
|
// looking for menu bar hotkey
|
||||||
auto menu_bar = getMenuBar();
|
auto menu_bar = getMenuBar();
|
||||||
|
|
||||||
if ( menu_bar )
|
if ( menu_bar && menu_bar->hotkeyMenu(ev) )
|
||||||
{
|
|
||||||
auto mbar = static_cast<FMenuBar*>(menu_bar);
|
|
||||||
|
|
||||||
if ( mbar->hotkeyMenu(ev) )
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
switch ( ev->key() )
|
switch ( ev->key() )
|
||||||
{
|
{
|
||||||
|
@ -272,7 +267,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||||
if ( ! mouse_down || getItemList().empty() )
|
if ( ! mouse_down || getItemList().empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mouseStates ms =
|
MouseStates ms =
|
||||||
{
|
{
|
||||||
false, // focus_changed
|
false, // focus_changed
|
||||||
false, // hide_sub_menu
|
false, // hide_sub_menu
|
||||||
|
@ -824,7 +819,7 @@ bool FMenu::mouseUpOverList (const FPoint& mouse_pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenu::mouseMoveOverList (const FPoint& mouse_pos, mouseStates& ms)
|
void FMenu::mouseMoveOverList (const FPoint& mouse_pos, MouseStates& ms)
|
||||||
{
|
{
|
||||||
FPoint pos{mouse_pos};
|
FPoint pos{mouse_pos};
|
||||||
pos -= FPoint{getRightPadding(), getTopPadding()};
|
pos -= FPoint{getRightPadding(), getTopPadding()};
|
||||||
|
@ -845,7 +840,7 @@ void FMenu::mouseMoveOverList (const FPoint& mouse_pos, mouseStates& ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenu::mouseMoveSelection (FMenuItem* m_item, mouseStates& ms)
|
void FMenu::mouseMoveSelection (FMenuItem* m_item, MouseStates& ms)
|
||||||
{
|
{
|
||||||
if ( ! m_item->isEnabled()
|
if ( ! m_item->isEnabled()
|
||||||
|| m_item->isSelected()
|
|| m_item->isSelected()
|
||||||
|
@ -878,7 +873,7 @@ void FMenu::mouseMoveSelection (FMenuItem* m_item, mouseStates& ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenu::mouseMoveDeselection (FMenuItem* m_item, mouseStates& ms)
|
void FMenu::mouseMoveDeselection (FMenuItem* m_item, MouseStates& ms)
|
||||||
{
|
{
|
||||||
if ( ! ms.mouse_over_menu
|
if ( ! ms.mouse_over_menu
|
||||||
|| ! m_item->isEnabled()
|
|| ! m_item->isEnabled()
|
||||||
|
@ -907,7 +902,7 @@ void FMenu::mouseUpOverBorder()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenu::mouseMoveOverBorder (mouseStates& ms) const
|
void FMenu::mouseMoveOverBorder (MouseStates& ms) const
|
||||||
{
|
{
|
||||||
// Mouse is moved over border or separator line
|
// Mouse is moved over border or separator line
|
||||||
|
|
||||||
|
@ -989,9 +984,8 @@ void FMenu::passEventToMenuBar (FMouseEvent* const& ev) const
|
||||||
const auto& _ev = \
|
const auto& _ev = \
|
||||||
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
|
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
|
||||||
setClickedWidget(menu_bar);
|
setClickedWidget(menu_bar);
|
||||||
auto& mbar = *(static_cast<FMenuBar*>(menu_bar));
|
menu_bar->mouse_down = true;
|
||||||
mbar.mouse_down = true;
|
menu_bar->onMouseMove(_ev.get());
|
||||||
mbar.onMouseMove(_ev.get());
|
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
|
@ -1060,7 +1054,7 @@ bool FMenu::selectNextItem()
|
||||||
++next_element;
|
++next_element;
|
||||||
if ( next_element == list.end() )
|
if ( next_element == list.end() )
|
||||||
next_element = list.begin();
|
next_element = list.begin();
|
||||||
next = static_cast<FMenuItem*>(*next_element);
|
next = *next_element;
|
||||||
}
|
}
|
||||||
while ( ! next->isEnabled()
|
while ( ! next->isEnabled()
|
||||||
|| ! next->acceptFocus()
|
|| ! next->acceptFocus()
|
||||||
|
@ -1110,7 +1104,7 @@ bool FMenu::selectPrevItem()
|
||||||
if ( prev_element == list.begin() )
|
if ( prev_element == list.begin() )
|
||||||
prev_element = list.end();
|
prev_element = list.end();
|
||||||
--prev_element;
|
--prev_element;
|
||||||
prev = static_cast<FMenuItem*>(*prev_element);
|
prev = *prev_element;
|
||||||
}
|
}
|
||||||
while ( ! prev->isEnabled()
|
while ( ! prev->isEnabled()
|
||||||
|| ! prev->acceptFocus()
|
|| ! prev->acceptFocus()
|
||||||
|
@ -1277,7 +1271,7 @@ inline void FMenu::drawSeparator (int y)
|
||||||
inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
|
inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
|
||||||
{
|
{
|
||||||
FString txt{m_item->getText()};
|
FString txt{m_item->getText()};
|
||||||
menuText txtdata{};
|
MenuText txtdata{};
|
||||||
std::size_t column_width = getColumnWidth(txt);
|
std::size_t column_width = getColumnWidth(txt);
|
||||||
const FKey accel_key = m_item->accel_key;
|
const FKey accel_key = m_item->accel_key;
|
||||||
const bool is_enabled = m_item->isEnabled();
|
const bool is_enabled = m_item->isEnabled();
|
||||||
|
@ -1367,7 +1361,7 @@ inline void FMenu::drawCheckMarkPrefix (const FMenuItem* m_item)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMenu::drawMenuText (menuText& data)
|
inline void FMenu::drawMenuText (MenuText& data)
|
||||||
{
|
{
|
||||||
// Print menu text
|
// Print menu text
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ FMenuBar::FMenuBar(FWidget* parent)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FMenuBar::~FMenuBar() // destructor
|
FMenuBar::~FMenuBar() // destructor
|
||||||
{
|
{
|
||||||
setMenuBar(nullptr);
|
FWidget::setMenuBar(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -256,6 +256,7 @@ void FMenuBar::init()
|
||||||
|
|
||||||
addAccelerator (fc::Fkey_f10);
|
addAccelerator (fc::Fkey_f10);
|
||||||
addAccelerator (fc::Fckey_space);
|
addAccelerator (fc::Fckey_space);
|
||||||
|
addAccelerator (fc::Fkey_menu);
|
||||||
resetColors();
|
resetColors();
|
||||||
unsetFocusable();
|
unsetFocusable();
|
||||||
}
|
}
|
||||||
|
@ -268,17 +269,17 @@ void FMenuBar::calculateDimensions() const
|
||||||
// find the maximum item width
|
// find the maximum item width
|
||||||
for (auto&& item : getItemList())
|
for (auto&& item : getItemList())
|
||||||
{
|
{
|
||||||
int len = int(item->getTextWidth());
|
auto len = item->getTextWidth();
|
||||||
int item_width = len + 2;
|
auto item_width = len + 2;
|
||||||
|
|
||||||
// set item geometry
|
// set item geometry
|
||||||
item->setGeometry (item_pos, FSize{std::size_t(item_width), 1}, false);
|
item->setGeometry (item_pos, FSize{item_width, 1}, false);
|
||||||
|
|
||||||
// set menu position
|
// set menu position
|
||||||
if ( item->hasMenu() )
|
if ( item->hasMenu() )
|
||||||
item->getMenu()->setPos (item_pos, false);
|
item->getMenu()->setPos (item_pos, false);
|
||||||
|
|
||||||
item_pos.x_ref() += item_width;
|
item_pos.x_ref() += int(item_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +303,7 @@ bool FMenuBar::selectNextItem()
|
||||||
if ( next_element == list.end() )
|
if ( next_element == list.end() )
|
||||||
next_element = list.begin();
|
next_element = list.begin();
|
||||||
|
|
||||||
next = static_cast<FMenuItem*>(*next_element);
|
next = *next_element;
|
||||||
} while ( ! next->isEnabled()
|
} while ( ! next->isEnabled()
|
||||||
|| ! next->acceptFocus()
|
|| ! next->acceptFocus()
|
||||||
|| ! next->isShown()
|
|| ! next->isShown()
|
||||||
|
@ -365,7 +366,7 @@ bool FMenuBar::selectPrevItem()
|
||||||
prev_element = list.end();
|
prev_element = list.end();
|
||||||
|
|
||||||
--prev_element;
|
--prev_element;
|
||||||
prev = static_cast<FMenuItem*>(*prev_element);
|
prev = *prev_element;
|
||||||
}
|
}
|
||||||
while ( ! prev->isEnabled()
|
while ( ! prev->isEnabled()
|
||||||
|| ! prev->acceptFocus()
|
|| ! prev->acceptFocus()
|
||||||
|
@ -681,7 +682,7 @@ void FMenuBar::adjustItems() const
|
||||||
for (auto&& item : getItemList())
|
for (auto&& item : getItemList())
|
||||||
{
|
{
|
||||||
// get item width
|
// get item width
|
||||||
int item_width = int(item->getWidth());
|
auto item_width = item->getWidth();
|
||||||
|
|
||||||
if ( item->hasMenu() )
|
if ( item->hasMenu() )
|
||||||
{
|
{
|
||||||
|
@ -694,7 +695,7 @@ void FMenuBar::adjustItems() const
|
||||||
menu->adjustItems();
|
menu->adjustItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
item_X += item_width;
|
item_X += int(item_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -605,11 +605,8 @@ void FMenuItem::createDialogList (FMenu* winmenu) const
|
||||||
while ( iter != getDialogList()->end() && *iter )
|
while ( iter != getDialogList()->end() && *iter )
|
||||||
{
|
{
|
||||||
auto win = static_cast<FDialog*>(*iter);
|
auto win = static_cast<FDialog*>(*iter);
|
||||||
|
|
||||||
if ( win )
|
|
||||||
{
|
|
||||||
FMenuItem* win_item{};
|
FMenuItem* win_item{};
|
||||||
const uInt32 n = uInt32(std::distance(first, iter));
|
const auto n = uInt32(std::distance(first, iter));
|
||||||
// get the dialog title
|
// get the dialog title
|
||||||
const auto& name = win->getText();
|
const auto& name = win->getText();
|
||||||
|
|
||||||
|
@ -644,8 +641,6 @@ void FMenuItem::createDialogList (FMenu* winmenu) const
|
||||||
);
|
);
|
||||||
|
|
||||||
win_item->associated_window = win;
|
win_item->associated_window = win;
|
||||||
}
|
|
||||||
|
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "final/fapplication.h"
|
#include "final/fapplication.h"
|
||||||
#include "final/fbutton.h"
|
#include "final/fbutton.h"
|
||||||
|
@ -30,8 +31,8 @@
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
{
|
{
|
||||||
|
|
||||||
static const char* const button_text[] =
|
constexpr std::array<const char* const, 8> button_text =
|
||||||
{
|
{{
|
||||||
nullptr,
|
nullptr,
|
||||||
"&OK",
|
"&OK",
|
||||||
"&Cancel",
|
"&Cancel",
|
||||||
|
@ -39,9 +40,8 @@ static const char* const button_text[] =
|
||||||
"&No",
|
"&No",
|
||||||
"&Abort",
|
"&Abort",
|
||||||
"&Retry",
|
"&Retry",
|
||||||
"&Ignore",
|
"&Ignore"
|
||||||
nullptr
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// class FMessageBox
|
// class FMessageBox
|
||||||
|
@ -51,7 +51,7 @@ static const char* const button_text[] =
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FMessageBox::FMessageBox (FWidget* parent)
|
FMessageBox::FMessageBox (FWidget* parent)
|
||||||
: FDialog{parent}
|
: FDialog{parent}
|
||||||
, button_digit{FMessageBox::Ok, 0, 0}
|
, button_digit{FMessageBox::Ok, FMessageBox::Reject, FMessageBox::Reject}
|
||||||
{
|
{
|
||||||
setTitlebarText("Message for you");
|
setTitlebarText("Message for you");
|
||||||
init();
|
init();
|
||||||
|
@ -79,9 +79,9 @@ FMessageBox::FMessageBox (const FMessageBox& mbox)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FMessageBox::FMessageBox ( const FString& caption
|
FMessageBox::FMessageBox ( const FString& caption
|
||||||
, const FString& message
|
, const FString& message
|
||||||
, int button0
|
, ButtonType button0
|
||||||
, int button1
|
, ButtonType button1
|
||||||
, int button2
|
, ButtonType button2
|
||||||
, FWidget* parent )
|
, FWidget* parent )
|
||||||
: FDialog{parent}
|
: FDialog{parent}
|
||||||
, text{message}
|
, text{message}
|
||||||
|
@ -158,10 +158,10 @@ void FMessageBox::setText (const FString& txt)
|
||||||
if ( button[0] )
|
if ( button[0] )
|
||||||
button[0]->setY (int(getHeight()) - 4, false);
|
button[0]->setY (int(getHeight()) - 4, false);
|
||||||
|
|
||||||
if ( button[1] && button_digit[1] != 0 )
|
if ( button[1] && button_digit[1] != FMessageBox::Reject )
|
||||||
button[1]->setY (int(getHeight()) - 4, false);
|
button[1]->setY (int(getHeight()) - 4, false);
|
||||||
|
|
||||||
if ( button[2] && button_digit[2] != 0 )
|
if ( button[2] && button_digit[2] != FMessageBox::Reject )
|
||||||
button[2]->setY (int(getHeight()) - 4, false);
|
button[2]->setY (int(getHeight()) - 4, false);
|
||||||
|
|
||||||
adjustButtons();
|
adjustButtons();
|
||||||
|
@ -195,9 +195,9 @@ void FMessageBox::adjustSize()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMessageBox::cb_processClick (int reply)
|
void FMessageBox::cb_processClick (ButtonType reply)
|
||||||
{
|
{
|
||||||
done(reply);
|
done(int(reply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -207,18 +207,21 @@ void FMessageBox::init()
|
||||||
{
|
{
|
||||||
calculateDimensions();
|
calculateDimensions();
|
||||||
|
|
||||||
if ( (button_digit[2] && ! button_digit[1])
|
if ( (button_digit[2] != Reject && button_digit[1] == Reject)
|
||||||
|| (button_digit[1] && ! button_digit[0]) )
|
|| (button_digit[1] != Reject && button_digit[0] == Reject) )
|
||||||
{
|
{
|
||||||
button_digit[0] = button_digit[1] = button_digit[2] = 0;
|
button_digit[0] = button_digit[1] \
|
||||||
|
= button_digit[2] \
|
||||||
|
= FMessageBox::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( button_digit[0] == 0 )
|
if ( button_digit[0] == FMessageBox::Reject )
|
||||||
button_digit[0] = FMessageBox::Ok;
|
button_digit[0] = FMessageBox::Ok;
|
||||||
|
|
||||||
if ( button_digit[1] == 0 && button_digit[2] == 0 )
|
if ( button_digit[1] == FMessageBox::Reject
|
||||||
|
&& button_digit[2] == FMessageBox::Reject )
|
||||||
num_buttons = 1;
|
num_buttons = 1;
|
||||||
else if ( button_digit[2] == 0 )
|
else if ( button_digit[2] == FMessageBox::Reject )
|
||||||
num_buttons = 2;
|
num_buttons = 2;
|
||||||
else
|
else
|
||||||
num_buttons = 3;
|
num_buttons = 3;
|
||||||
|
@ -242,7 +245,7 @@ inline void FMessageBox::allocation()
|
||||||
button[0]->setHeight(1, false);
|
button[0]->setHeight(1, false);
|
||||||
button[0]->setFocus();
|
button[0]->setFocus();
|
||||||
|
|
||||||
if ( button_digit[1] > 0 )
|
if ( button_digit[1] > FMessageBox::Reject )
|
||||||
{
|
{
|
||||||
button[1] = new FButton(this);
|
button[1] = new FButton(this);
|
||||||
button[1]->setText(button_text[button_digit[1]]);
|
button[1]->setText(button_text[button_digit[1]]);
|
||||||
|
@ -251,7 +254,7 @@ inline void FMessageBox::allocation()
|
||||||
button[1]->setHeight(1, false);
|
button[1]->setHeight(1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( button_digit[2] > 0 )
|
if ( button_digit[2] > FMessageBox::Reject )
|
||||||
{
|
{
|
||||||
button[2] = new FButton(this);
|
button[2] = new FButton(this);
|
||||||
button[2]->setText(button_text[button_digit[2]]);
|
button[2]->setText(button_text[button_digit[2]]);
|
||||||
|
@ -278,7 +281,7 @@ inline void FMessageBox::deallocation()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMessageBox::initCallbacks()
|
inline void FMessageBox::initCallbacks()
|
||||||
{
|
{
|
||||||
if ( button[0] && button_digit[0] != 0 )
|
if ( button[0] && button_digit[0] != FMessageBox::Reject )
|
||||||
{
|
{
|
||||||
button[0]->addCallback
|
button[0]->addCallback
|
||||||
(
|
(
|
||||||
|
@ -288,7 +291,7 @@ inline void FMessageBox::initCallbacks()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( button[1] && button_digit[1] != 0 )
|
if ( button[1] && button_digit[1] != FMessageBox::Reject )
|
||||||
{
|
{
|
||||||
button[1]->addCallback
|
button[1]->addCallback
|
||||||
(
|
(
|
||||||
|
@ -298,7 +301,7 @@ inline void FMessageBox::initCallbacks()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( button[2] && button_digit[2] != 0 )
|
if ( button[2] && button_digit[2] != FMessageBox::Reject )
|
||||||
{
|
{
|
||||||
button[2]->addCallback
|
button[2]->addCallback
|
||||||
(
|
(
|
||||||
|
@ -350,7 +353,7 @@ void FMessageBox::draw()
|
||||||
int head_offset{0};
|
int head_offset{0};
|
||||||
int center_x{0};
|
int center_x{0};
|
||||||
// center the whole block
|
// center the whole block
|
||||||
const int msg_x = int((getWidth() - max_line_width) / 2);
|
const auto msg_x = int((getWidth() - max_line_width) / 2);
|
||||||
|
|
||||||
if ( FTerm::isMonochron() )
|
if ( FTerm::isMonochron() )
|
||||||
setReverse(true);
|
setReverse(true);
|
||||||
|
@ -388,7 +391,7 @@ void FMessageBox::draw()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMessageBox::resizeButtons() const
|
void FMessageBox::resizeButtons() const
|
||||||
{
|
{
|
||||||
std::size_t len[3]{};
|
std::array<std::size_t, 3> len{};
|
||||||
std::size_t max_size{};
|
std::size_t max_size{};
|
||||||
|
|
||||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||||
|
@ -447,7 +450,7 @@ void FMessageBox::adjustButtons()
|
||||||
setX (int((max_width - getWidth()) / 2));
|
setX (int((max_width - getWidth()) / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
const int btn_x = int((getWidth() - btn_width) / 2);
|
const auto btn_x = int((getWidth() - btn_width) / 2);
|
||||||
|
|
||||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||||
{
|
{
|
||||||
|
@ -458,7 +461,7 @@ void FMessageBox::adjustButtons()
|
||||||
button[n]->setX(btn_x);
|
button[n]->setX(btn_x);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int btn_size = int(button[n]->getWidth());
|
const auto btn_size = int(button[n]->getWidth());
|
||||||
button[n]->setX(btn_x + int(n) * (btn_size + int(gap)));
|
button[n]->setX(btn_x + int(n) * (btn_size + int(gap)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ FMouse::FMouse()
|
||||||
|
|
||||||
// public methods of FMouse
|
// public methods of FMouse
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FMouse::getClassName() const
|
FString FMouse::getClassName() const
|
||||||
{
|
{
|
||||||
return "FMouse";
|
return "FMouse";
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ FMouseGPM::~FMouseGPM() // destructor
|
||||||
|
|
||||||
// public methods of FMouseX11
|
// public methods of FMouseX11
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FMouseGPM::getClassName() const
|
FString FMouseGPM::getClassName() const
|
||||||
{
|
{
|
||||||
return "FMouseGPM";
|
return "FMouseGPM";
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,9 @@ bool FMouseGPM::hasData()
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMouseGPM::setRawData (FKeyboard::keybuffer&)
|
void FMouseGPM::setRawData (FKeyboard::keybuffer&)
|
||||||
{ }
|
{
|
||||||
|
// This method need not be implemented for FMouseGPM
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMouseGPM::processEvent (struct timeval*)
|
void FMouseGPM::processEvent (struct timeval*)
|
||||||
|
@ -520,7 +522,7 @@ int FMouseGPM::gpmEvent (bool clear) const
|
||||||
|
|
||||||
// public methods of FMouseX11
|
// public methods of FMouseX11
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FMouseX11::getClassName() const
|
FString FMouseX11::getClassName() const
|
||||||
{
|
{
|
||||||
return "FMouseX11";
|
return "FMouseX11";
|
||||||
}
|
}
|
||||||
|
@ -563,8 +565,8 @@ void FMouseX11::processEvent (struct timeval* time)
|
||||||
// Parse and interpret the X11 xterm mouse string
|
// Parse and interpret the X11 xterm mouse string
|
||||||
|
|
||||||
const auto& mouse_position = getPos();
|
const auto& mouse_position = getPos();
|
||||||
const uChar x = uChar(x11_mouse[1] - 0x20);
|
const auto x = uChar(x11_mouse[1] - 0x20);
|
||||||
const uChar y = uChar(x11_mouse[2] - 0x20);
|
const auto y = uChar(x11_mouse[2] - 0x20);
|
||||||
const int btn = x11_mouse[0];
|
const int btn = x11_mouse[0];
|
||||||
setNewPos (x, y);
|
setNewPos (x, y);
|
||||||
clearButtonState();
|
clearButtonState();
|
||||||
|
@ -698,7 +700,7 @@ void FMouseX11::setButtonState (const int btn, const struct timeval* time)
|
||||||
|
|
||||||
// public methods of FMouseSGR
|
// public methods of FMouseSGR
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FMouseSGR::getClassName() const
|
FString FMouseSGR::getClassName() const
|
||||||
{
|
{
|
||||||
return "FMouseSGR";
|
return "FMouseSGR";
|
||||||
}
|
}
|
||||||
|
@ -928,7 +930,7 @@ void FMouseSGR::setReleasedButtonState (const int btn)
|
||||||
|
|
||||||
// public methods of FMouseUrxvt
|
// public methods of FMouseUrxvt
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FMouseUrxvt::getClassName() const
|
FString FMouseUrxvt::getClassName() const
|
||||||
{
|
{
|
||||||
return "FMouseUrxvt";
|
return "FMouseUrxvt";
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ FObject::FObject (FObject* parent)
|
||||||
if ( parent ) // add object to parent
|
if ( parent ) // add object to parent
|
||||||
{
|
{
|
||||||
parent->addChild(this);
|
parent->addChild(this);
|
||||||
has_parent = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -107,7 +106,7 @@ FObject* FObject::getChild (int index) const
|
||||||
if ( ! hasChildren() )
|
if ( ! hasChildren() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if ( index <= 0 || index > numOfChildren() )
|
if ( index <= 0 || index > int(numOfChildren()) )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto iter = begin();
|
auto iter = begin();
|
||||||
|
@ -148,6 +147,9 @@ void FObject::addChild (FObject* obj)
|
||||||
if ( ! obj )
|
if ( ! obj )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ( max_children != UNLIMITED && max_children <= numOfChildren() )
|
||||||
|
throw std::length_error ("max. child objects reached");
|
||||||
|
|
||||||
if ( obj->parent_obj )
|
if ( obj->parent_obj )
|
||||||
obj->parent_obj->delChild(obj);
|
obj->parent_obj->delChild(obj);
|
||||||
|
|
||||||
|
@ -252,7 +254,7 @@ bool FObject::isTimeout (const timeval* time, uInt64 timeout)
|
||||||
diff.tv_usec += 1000000;
|
diff.tv_usec += 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uInt64 diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec);
|
const auto diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec);
|
||||||
return ( diff_usec > timeout );
|
return ( diff_usec > timeout );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,11 +382,17 @@ bool FObject::delAllTimers() const
|
||||||
// protected methods of FObject
|
// protected methods of FObject
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FObject::onTimer (FTimerEvent*)
|
void FObject::onTimer (FTimerEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive timer events for this object
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FObject::onUserEvent (FUserEvent*)
|
void FObject::onUserEvent (FUserEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive user events for this object
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
uInt FObject::processTimerEvent()
|
uInt FObject::processTimerEvent()
|
||||||
|
@ -427,6 +435,9 @@ uInt FObject::processTimerEvent()
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FObject::performTimerAction (FObject*, FEvent*)
|
void FObject::performTimerAction (FObject*, FEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This method must be reimplemented in a subclass
|
||||||
|
// to process the passed object and timer event
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "final/fc.h"
|
#include "final/fc.h"
|
||||||
|
@ -53,7 +54,7 @@ FOptiAttr::~FOptiAttr() // destructor
|
||||||
|
|
||||||
// public methods of FOptiAttr
|
// public methods of FOptiAttr
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FOptiAttr::setTermEnvironment (const termEnv& term_env)
|
void FOptiAttr::setTermEnvironment (const TermEnv& term_env)
|
||||||
{
|
{
|
||||||
// Set all required termcap values at once
|
// Set all required termcap values at once
|
||||||
// and initialize the FOptiAttr environment
|
// and initialize the FOptiAttr environment
|
||||||
|
@ -531,11 +532,11 @@ FColor FOptiAttr::vga2ansi (FColor color)
|
||||||
color = 0;
|
color = 0;
|
||||||
else if ( color < 16 )
|
else if ( color < 16 )
|
||||||
{
|
{
|
||||||
static const FColor lookup_table[] =
|
constexpr std::array<FColor, 16> lookup_table =
|
||||||
{
|
{{
|
||||||
0, 4, 2, 6, 1, 5, 3, 7,
|
0, 4, 2, 6, 1, 5, 3, 7,
|
||||||
8, 12, 10, 14, 9, 13, 11, 15
|
8, 12, 10, 14, 9, 13, 11, 15
|
||||||
};
|
}};
|
||||||
|
|
||||||
color = lookup_table[color];
|
color = lookup_table[color];
|
||||||
}
|
}
|
||||||
|
@ -551,7 +552,7 @@ const char* FOptiAttr::changeAttribute (FChar*& term, FChar*& next)
|
||||||
attr_buf[0] = '\0';
|
attr_buf[0] = '\0';
|
||||||
|
|
||||||
if ( ! (term && next) )
|
if ( ! (term && next) )
|
||||||
return attr_buf;
|
return attr_buf.data();
|
||||||
|
|
||||||
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);
|
||||||
|
@ -583,7 +584,7 @@ const char* FOptiAttr::changeAttribute (FChar*& term, FChar*& next)
|
||||||
if ( FStartOptions::getFStartOptions().sgr_optimizer )
|
if ( FStartOptions::getFStartOptions().sgr_optimizer )
|
||||||
sgr_optimizer.optimize();
|
sgr_optimizer.optimize();
|
||||||
|
|
||||||
return attr_buf;
|
return attr_buf.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1086,8 +1087,8 @@ bool FOptiAttr::setTermDefaultColor (FChar*& term)
|
||||||
return true;
|
return true;
|
||||||
else if ( ansi_default_color )
|
else if ( ansi_default_color )
|
||||||
{
|
{
|
||||||
char sgr_39_49[] = CSI "39;49m";
|
std::string sgr_39_49{CSI "39;49m"};
|
||||||
append_sequence (sgr_39_49);
|
append_sequence (sgr_39_49.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1453,8 +1454,8 @@ inline void FOptiAttr::change_to_default_color ( FChar*& term
|
||||||
}
|
}
|
||||||
else if ( fg == fc::Default && term->fg_color != fc::Default )
|
else if ( fg == fc::Default && term->fg_color != fc::Default )
|
||||||
{
|
{
|
||||||
char sgr_39[]{ CSI "39m" };
|
std::string sgr_39{CSI "39m"};
|
||||||
append_sequence (sgr_39);
|
append_sequence (sgr_39.c_str());
|
||||||
term->fg_color = fc::Default;
|
term->fg_color = fc::Default;
|
||||||
}
|
}
|
||||||
else if ( bg == fc::Default && term->bg_color != fc::Default )
|
else if ( bg == fc::Default && term->bg_color != fc::Default )
|
||||||
|
@ -1667,8 +1668,9 @@ inline bool FOptiAttr::append_sequence (const char seq[])
|
||||||
if ( ! seq )
|
if ( ! seq )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::strncat (attr_ptr, seq, sizeof(attr_buf) - std::strlen(attr_ptr));
|
char* attr_ptr{attr_buf.data()};
|
||||||
attr_buf[sizeof(attr_buf) - 1] = '\0';
|
std::strncat (attr_ptr, seq, attr_buf.size() - std::strlen(attr_ptr));
|
||||||
|
attr_buf[attr_buf.size() - 1] = '\0';
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "final/fapplication.h"
|
#include "final/fapplication.h"
|
||||||
#include "final/fc.h"
|
#include "final/fc.h"
|
||||||
#include "final/flog.h"
|
|
||||||
#include "final/foptimove.h"
|
#include "final/foptimove.h"
|
||||||
#include "final/ftermcap.h"
|
#include "final/ftermcap.h"
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ void FOptiMove::setTermSize (std::size_t w, std::size_t h)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FOptiMove::setTermEnvironment (const termEnv& term_env)
|
void FOptiMove::setTermEnvironment (const TermEnv& term_env)
|
||||||
{
|
{
|
||||||
// Set all required termcap values at once
|
// Set all required termcap values at once
|
||||||
|
|
||||||
|
@ -607,7 +607,7 @@ int FOptiMove::capDurationToLength (int duration) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int FOptiMove::repeatedAppend ( const capability& o
|
int FOptiMove::repeatedAppend ( const Capability& o
|
||||||
, volatile int count
|
, volatile int count
|
||||||
, char* dst ) const
|
, char* dst ) const
|
||||||
{
|
{
|
||||||
|
@ -801,7 +801,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
|
||||||
|
|
||||||
if ( F_cursor_right.cap )
|
if ( F_cursor_right.cap )
|
||||||
{
|
{
|
||||||
char str[BUF_SIZE]{};
|
std::array<char, BUF_SIZE> str{};
|
||||||
int htime_r{0};
|
int htime_r{0};
|
||||||
str[0] = '\0';
|
str[0] = '\0';
|
||||||
|
|
||||||
|
@ -817,7 +817,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
|
||||||
if ( tab_pos > to_x )
|
if ( tab_pos > to_x )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
htime_r += repeatedAppend (F_tab, 1, str);
|
htime_r += repeatedAppend (F_tab, 1, str.data());
|
||||||
|
|
||||||
if ( htime_r >= LONG_DURATION )
|
if ( htime_r >= LONG_DURATION )
|
||||||
break;
|
break;
|
||||||
|
@ -828,11 +828,11 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
|
||||||
num = to_x - pos;
|
num = to_x - pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
htime_r += repeatedAppend (F_cursor_right, num, str);
|
htime_r += repeatedAppend (F_cursor_right, num, str.data());
|
||||||
|
|
||||||
if ( htime_r < htime )
|
if ( htime_r < htime )
|
||||||
{
|
{
|
||||||
std::strncpy (hmove, str, BUF_SIZE);
|
std::strncpy (hmove, str.data(), BUF_SIZE);
|
||||||
hmove[BUF_SIZE - 1] = '\0';
|
hmove[BUF_SIZE - 1] = '\0';
|
||||||
htime = htime_r;
|
htime = htime_r;
|
||||||
}
|
}
|
||||||
|
@ -856,7 +856,7 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
|
||||||
|
|
||||||
if ( F_cursor_left.cap )
|
if ( F_cursor_left.cap )
|
||||||
{
|
{
|
||||||
char str[BUF_SIZE]{};
|
std::array<char, BUF_SIZE> str{};
|
||||||
int htime_l{0};
|
int htime_l{0};
|
||||||
str[0] = '\0';
|
str[0] = '\0';
|
||||||
|
|
||||||
|
@ -872,7 +872,7 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
|
||||||
if ( tab_pos < to_x )
|
if ( tab_pos < to_x )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
htime_l += repeatedAppend (F_back_tab, 1, str);
|
htime_l += repeatedAppend (F_back_tab, 1, str.data());
|
||||||
|
|
||||||
if ( htime_l >= LONG_DURATION )
|
if ( htime_l >= LONG_DURATION )
|
||||||
break;
|
break;
|
||||||
|
@ -883,11 +883,11 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
|
||||||
num = pos - to_x;
|
num = pos - to_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
htime_l += repeatedAppend (F_cursor_left, num, str);
|
htime_l += repeatedAppend (F_cursor_left, num, str.data());
|
||||||
|
|
||||||
if ( htime_l < htime )
|
if ( htime_l < htime )
|
||||||
{
|
{
|
||||||
std::strncpy (hmove, str, BUF_SIZE);
|
std::strncpy (hmove, str.data(), BUF_SIZE);
|
||||||
hmove[BUF_SIZE - 1] = '\0';
|
hmove[BUF_SIZE - 1] = '\0';
|
||||||
htime = htime_l;
|
htime = htime_l;
|
||||||
}
|
}
|
||||||
|
@ -933,8 +933,8 @@ inline bool FOptiMove::isMethod1Faster ( int& move_time
|
||||||
|
|
||||||
if ( xold >= 0 && yold >= 0 )
|
if ( xold >= 0 && yold >= 0 )
|
||||||
{
|
{
|
||||||
char null_result[BUF_SIZE];
|
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 )
|
||||||
{
|
{
|
||||||
|
@ -955,8 +955,8 @@ inline bool FOptiMove::isMethod2Faster ( int& move_time
|
||||||
|
|
||||||
if ( yold >= 0 && F_carriage_return.cap )
|
if ( yold >= 0 && F_carriage_return.cap )
|
||||||
{
|
{
|
||||||
char null_result[BUF_SIZE];
|
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 )
|
||||||
|
@ -977,8 +977,8 @@ inline bool FOptiMove::isMethod3Faster ( int& move_time
|
||||||
|
|
||||||
if ( F_cursor_home.cap )
|
if ( F_cursor_home.cap )
|
||||||
{
|
{
|
||||||
char null_result[BUF_SIZE];
|
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 )
|
||||||
|
@ -998,8 +998,8 @@ 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 )
|
||||||
{
|
{
|
||||||
char null_result[BUF_SIZE];
|
std::array<char, BUF_SIZE> null_result{};
|
||||||
const int new_time = relativeMove ( null_result
|
const int new_time = relativeMove ( null_result.data()
|
||||||
, 0, int(screen_height) - 1
|
, 0, int(screen_height) - 1
|
||||||
, xnew, ynew );
|
, xnew, ynew );
|
||||||
|
|
||||||
|
@ -1025,8 +1025,8 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
|
||||||
&& yold > 0
|
&& yold > 0
|
||||||
&& F_cursor_left.cap )
|
&& F_cursor_left.cap )
|
||||||
{
|
{
|
||||||
char null_result[BUF_SIZE];
|
std::array<char, BUF_SIZE> null_result{};
|
||||||
const int new_time = relativeMove ( null_result
|
const int new_time = relativeMove ( null_result.data()
|
||||||
, int(screen_width) - 1, yold - 1
|
, int(screen_width) - 1, yold - 1
|
||||||
, xnew, ynew );
|
, xnew, ynew );
|
||||||
|
|
||||||
|
@ -1107,42 +1107,41 @@ void FOptiMove::moveByMethod ( int method
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void printDurations (const FOptiMove& om)
|
void printDurations (const FOptiMove& om)
|
||||||
{
|
{
|
||||||
finalcut::FLog& log = *FApplication::getLog();
|
std::clog << " speed: "
|
||||||
log << " speed: "
|
|
||||||
<< om.baudrate << " baud" << std::flush;
|
<< om.baudrate << " baud" << std::flush;
|
||||||
log << " char_duration: "
|
std::clog << " char_duration: "
|
||||||
<< om.char_duration << " ms" << std::flush;
|
<< om.char_duration << " ms" << std::flush;
|
||||||
log << " cursor_home: "
|
std::clog << " cursor_home: "
|
||||||
<< om.F_cursor_home.duration << " ms" << std::flush;
|
<< om.F_cursor_home.duration << " ms" << std::flush;
|
||||||
log << " cursor_to_ll: "
|
std::clog << " cursor_to_ll: "
|
||||||
<< om.F_cursor_to_ll.duration << " ms" << std::flush;
|
<< om.F_cursor_to_ll.duration << " ms" << std::flush;
|
||||||
log << " carriage_return: "
|
std::clog << " carriage_return: "
|
||||||
<< om.F_carriage_return.duration << " ms" << std::flush;
|
<< om.F_carriage_return.duration << " ms" << std::flush;
|
||||||
log << " tab: "
|
std::clog << " tab: "
|
||||||
<< om.F_tab.duration << " ms" << std::flush;
|
<< om.F_tab.duration << " ms" << std::flush;
|
||||||
log << " back_tab: "
|
std::clog << " back_tab: "
|
||||||
<< om.F_back_tab.duration << " ms" << std::flush;
|
<< om.F_back_tab.duration << " ms" << std::flush;
|
||||||
log << " cursor_up: "
|
std::clog << " cursor_up: "
|
||||||
<< om.F_cursor_up.duration << " ms" << std::flush;
|
<< om.F_cursor_up.duration << " ms" << std::flush;
|
||||||
log << " cursor_down: "
|
std::clog << " cursor_down: "
|
||||||
<< om.F_cursor_down.duration << " ms" << std::flush;
|
<< om.F_cursor_down.duration << " ms" << std::flush;
|
||||||
log << " cursor_left: "
|
std::clog << " cursor_left: "
|
||||||
<< om.F_cursor_left.duration << " ms" << std::flush;
|
<< om.F_cursor_left.duration << " ms" << std::flush;
|
||||||
log << " cursor_right: "
|
std::clog << " cursor_right: "
|
||||||
<< om.F_cursor_right.duration << " ms" << std::flush;
|
<< om.F_cursor_right.duration << " ms" << std::flush;
|
||||||
log << " cursor_address: "
|
std::clog << " cursor_address: "
|
||||||
<< om.F_cursor_address.duration << " ms" << std::flush;
|
<< om.F_cursor_address.duration << " ms" << std::flush;
|
||||||
log << " column_address: "
|
std::clog << " column_address: "
|
||||||
<< om.F_column_address.duration << " ms" << std::flush;
|
<< om.F_column_address.duration << " ms" << std::flush;
|
||||||
log << " row_address: "
|
std::clog << " row_address: "
|
||||||
<< om.F_row_address.duration << " ms" << std::flush;
|
<< om.F_row_address.duration << " ms" << std::flush;
|
||||||
log << " parm_up_cursor: "
|
std::clog << " parm_up_cursor: "
|
||||||
<< om.F_parm_up_cursor.duration << " ms" << std::flush;
|
<< om.F_parm_up_cursor.duration << " ms" << std::flush;
|
||||||
log << " parm_down_cursor: "
|
std::clog << " parm_down_cursor: "
|
||||||
<< om.F_parm_down_cursor.duration << " ms" << std::flush;
|
<< om.F_parm_down_cursor.duration << " ms" << std::flush;
|
||||||
log << " parm_left_cursor: "
|
std::clog << " parm_left_cursor: "
|
||||||
<< om.F_parm_left_cursor.duration << " ms" << std::flush;
|
<< om.F_parm_left_cursor.duration << " ms" << std::flush;
|
||||||
log << "parm_right_cursor: "
|
std::clog << "parm_right_cursor: "
|
||||||
<< om.F_parm_right_cursor.duration << " ms" << std::flush;
|
<< om.F_parm_right_cursor.duration << " ms" << std::flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,37 +84,37 @@ bool FRect::isEmpty() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FPoint FRect::getPos() const
|
FPoint FRect::getPos() const
|
||||||
{
|
{
|
||||||
return { X1, Y1 };
|
return { X1, Y1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FPoint FRect::getUpperLeftPos() const
|
FPoint FRect::getUpperLeftPos() const
|
||||||
{
|
{
|
||||||
return { X1, Y1 };
|
return { X1, Y1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FPoint FRect::getUpperRightPos() const
|
FPoint FRect::getUpperRightPos() const
|
||||||
{
|
{
|
||||||
return { X2, Y1 };
|
return { X2, Y1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FPoint FRect::getLowerLeftPos() const
|
FPoint FRect::getLowerLeftPos() const
|
||||||
{
|
{
|
||||||
return { X1, Y2 };
|
return { X1, Y2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FPoint FRect::getLowerRightPos() const
|
FPoint FRect::getLowerRightPos() const
|
||||||
{
|
{
|
||||||
return { X2, Y2 };
|
return { X2, Y2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FSize FRect::getSize() const
|
FSize FRect::getSize() const
|
||||||
{
|
{
|
||||||
return { getWidth(), getHeight() };
|
return { getWidth(), getHeight() };
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ FRect FRect::combined (const FRect& r) const
|
||||||
|
|
||||||
// FRect non-member operators
|
// FRect non-member operators
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FRect operator + (const FRect& r, const FSize& s)
|
FRect operator + (const FRect& r, const FSize& s)
|
||||||
{
|
{
|
||||||
return { r.X1
|
return { r.X1
|
||||||
, r.Y1
|
, r.Y1
|
||||||
|
@ -347,7 +347,7 @@ const FRect operator + (const FRect& r, const FSize& s)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FRect operator - (const FRect& r, const FSize& s)
|
FRect operator - (const FRect& r, const FSize& s)
|
||||||
{
|
{
|
||||||
return { r.X1
|
return { r.X1
|
||||||
, r.Y1
|
, r.Y1
|
||||||
|
|
|
@ -40,7 +40,7 @@ FScrollbar::FScrollbar(FWidget* parent)
|
||||||
: FWidget{parent}
|
: FWidget{parent}
|
||||||
{
|
{
|
||||||
// The default scrollbar orientation is vertical
|
// The default scrollbar orientation is vertical
|
||||||
setGeometry(FPoint{1, 1}, FSize{1, length}, false);
|
FScrollbar::setGeometry(FPoint{1, 1}, FSize{1, length}, false);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ void FScrollbar::onTimer (FTimerEvent*)
|
||||||
|| ( scroll_type == FScrollbar::scrollPageForward
|
|| ( scroll_type == FScrollbar::scrollPageForward
|
||||||
&& slider_pos == slider_click_stop_pos ) )
|
&& slider_pos == slider_click_stop_pos ) )
|
||||||
{
|
{
|
||||||
const int max_slider_pos = int(bar_length - slider_length);
|
const auto max_slider_pos = int(bar_length - slider_length);
|
||||||
|
|
||||||
if ( scroll_type == FScrollbar::scrollPageBackward
|
if ( scroll_type == FScrollbar::scrollPageBackward
|
||||||
&& slider_pos == 0 )
|
&& slider_pos == 0 )
|
||||||
|
|
|
@ -139,8 +139,8 @@ void FScrollView::setScrollSize (const FSize& size)
|
||||||
setChildPrintArea (viewport);
|
setChildPrintArea (viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int xoffset_end = int(getScrollWidth() - getViewportWidth());
|
const auto xoffset_end = int(getScrollWidth() - getViewportWidth());
|
||||||
const int yoffset_end = int(getScrollHeight() - getViewportHeight());
|
const auto yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||||
setTopPadding (1 - getScrollY());
|
setTopPadding (1 - getScrollY());
|
||||||
setLeftPadding (1 - getScrollX());
|
setLeftPadding (1 - getScrollX());
|
||||||
setBottomPadding (1 - (yoffset_end - getScrollY()));
|
setBottomPadding (1 - (yoffset_end - getScrollY()));
|
||||||
|
@ -352,8 +352,8 @@ void FScrollView::scrollTo (int x, int y)
|
||||||
int& yoffset = viewport_geometry.y1_ref();
|
int& yoffset = viewport_geometry.y1_ref();
|
||||||
const int xoffset_before = xoffset;
|
const int xoffset_before = xoffset;
|
||||||
const int yoffset_before = yoffset;
|
const int yoffset_before = yoffset;
|
||||||
const int xoffset_end = int(getScrollWidth() - getViewportWidth());
|
const auto xoffset_end = int(getScrollWidth() - getViewportWidth());
|
||||||
const int yoffset_end = int(getScrollHeight() - getViewportHeight());
|
const auto yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||||
const std::size_t save_width = viewport_geometry.getWidth();
|
const std::size_t save_width = viewport_geometry.getWidth();
|
||||||
const std::size_t save_height = viewport_geometry.getHeight();
|
const std::size_t save_height = viewport_geometry.getHeight();
|
||||||
x--;
|
x--;
|
||||||
|
@ -462,7 +462,7 @@ void FScrollView::drawBorder()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FScrollView::onKeyPress (FKeyEvent* ev)
|
void FScrollView::onKeyPress (FKeyEvent* ev)
|
||||||
{
|
{
|
||||||
const int idx = int(ev->key());
|
const auto idx = int(ev->key());
|
||||||
|
|
||||||
if ( key_map.find(idx) != key_map.end() )
|
if ( key_map.find(idx) != key_map.end() )
|
||||||
{
|
{
|
||||||
|
@ -658,8 +658,8 @@ void FScrollView::copy2area()
|
||||||
const int ay = getTermY() - printarea->offset_top;
|
const int ay = getTermY() - printarea->offset_top;
|
||||||
const int dx = viewport_geometry.getX();
|
const int dx = viewport_geometry.getX();
|
||||||
const int dy = viewport_geometry.getY();
|
const int dy = viewport_geometry.getY();
|
||||||
int y_end = int(getViewportHeight());
|
auto y_end = int(getViewportHeight());
|
||||||
int x_end = int(getViewportWidth());
|
auto x_end = int(getViewportWidth());
|
||||||
|
|
||||||
// viewport width does not fit into the printarea
|
// viewport width does not fit into the printarea
|
||||||
if ( printarea->width <= ax + x_end )
|
if ( printarea->width <= ax + x_end )
|
||||||
|
@ -694,7 +694,7 @@ void FScrollView::copy2area()
|
||||||
|
|
||||||
// private methods of FScrollView
|
// private methods of FScrollView
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FPoint FScrollView::getViewportCursorPos() const
|
inline FPoint FScrollView::getViewportCursorPos() const
|
||||||
{
|
{
|
||||||
const auto& window = FWindow::getWindowWidget(this);
|
const auto& window = FWindow::getWindowWidget(this);
|
||||||
|
|
||||||
|
@ -726,8 +726,8 @@ void FScrollView::init()
|
||||||
resetColors();
|
resetColors();
|
||||||
setGeometry (FPoint{1, 1}, FSize{4, 4});
|
setGeometry (FPoint{1, 1}, FSize{4, 4});
|
||||||
setMinimumSize (FSize{4, 4});
|
setMinimumSize (FSize{4, 4});
|
||||||
const int xoffset_end = int(getScrollWidth() - getViewportWidth());
|
const auto xoffset_end = int(getScrollWidth() - getViewportWidth());
|
||||||
const int yoffset_end = int(getScrollHeight() - getViewportHeight());
|
const auto yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||||
nf_offset = FTerm::isNewFont() ? 1 : 0;
|
nf_offset = FTerm::isNewFont() ? 1 : 0;
|
||||||
setTopPadding (1 - getScrollY());
|
setTopPadding (1 - getScrollY());
|
||||||
setLeftPadding (1 - getScrollX());
|
setLeftPadding (1 - getScrollX());
|
||||||
|
@ -767,7 +767,7 @@ inline void FScrollView::mapKeyFunctions()
|
||||||
key_map[fc::Fkey_end] = \
|
key_map[fc::Fkey_end] = \
|
||||||
[this] ()
|
[this] ()
|
||||||
{
|
{
|
||||||
int yoffset_end = int(getScrollHeight() - getViewportHeight());
|
auto yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||||
scrollToY (1 + yoffset_end);
|
scrollToY (1 + yoffset_end);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,7 +516,7 @@ void FStatusBar::init()
|
||||||
{
|
{
|
||||||
const auto& r = getRootWidget();
|
const auto& r = getRootWidget();
|
||||||
const std::size_t w = r->getWidth();
|
const std::size_t w = r->getWidth();
|
||||||
const int h = int(r->getHeight());
|
const auto h = int(r->getHeight());
|
||||||
// initialize geometry values
|
// initialize geometry values
|
||||||
setGeometry (FPoint{1, h}, FSize{w, 1}, false);
|
setGeometry (FPoint{1, h}, FSize{w, 1}, false);
|
||||||
setAlwaysOnTop();
|
setAlwaysOnTop();
|
||||||
|
@ -602,7 +602,7 @@ void FStatusBar::drawKeys()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FStatusBar::drawKey (keyList::const_iterator iter)
|
void FStatusBar::drawKey (FKeyList::const_iterator iter)
|
||||||
{
|
{
|
||||||
// Draw not active key
|
// Draw not active key
|
||||||
|
|
||||||
|
@ -660,7 +660,7 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FStatusBar::drawActiveKey (keyList::const_iterator iter)
|
void FStatusBar::drawActiveKey (FKeyList::const_iterator iter)
|
||||||
{
|
{
|
||||||
// Draw active key
|
// Draw active key
|
||||||
|
|
||||||
|
|
|
@ -409,13 +409,13 @@ char* FString::c_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const std::string FString::toString() const
|
std::string FString::toString() const
|
||||||
{
|
{
|
||||||
return std::string(c_str(), length);
|
return std::string(c_str(), length);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FString::toLower() const
|
FString FString::toLower() const
|
||||||
{
|
{
|
||||||
FString s{*this};
|
FString s{*this};
|
||||||
auto to_lower = [] (wchar_t& c)
|
auto to_lower = [] (wchar_t& c)
|
||||||
|
@ -427,7 +427,7 @@ const FString FString::toLower() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FString::toUpper() const
|
FString FString::toUpper() const
|
||||||
{
|
{
|
||||||
FString s{*this};
|
FString s{*this};
|
||||||
auto to_upper = [] (wchar_t& c)
|
auto to_upper = [] (wchar_t& c)
|
||||||
|
@ -455,7 +455,7 @@ sInt16 FString::toShort() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
uInt16 FString::toUShort() const
|
uInt16 FString::toUShort() const
|
||||||
{
|
{
|
||||||
const uLong num = uLong(toULong());
|
const uLong num = toULong();
|
||||||
|
|
||||||
if ( num > USHRT_MAX )
|
if ( num > USHRT_MAX )
|
||||||
throw std::overflow_error ("overflow");
|
throw std::overflow_error ("overflow");
|
||||||
|
@ -466,7 +466,7 @@ uInt16 FString::toUShort() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int FString::toInt() const
|
int FString::toInt() const
|
||||||
{
|
{
|
||||||
long num = toLong();
|
const long num = toLong();
|
||||||
|
|
||||||
if ( num > INT_MAX )
|
if ( num > INT_MAX )
|
||||||
throw std::overflow_error ("overflow");
|
throw std::overflow_error ("overflow");
|
||||||
|
@ -480,7 +480,7 @@ int FString::toInt() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
uInt FString::toUInt() const
|
uInt FString::toUInt() const
|
||||||
{
|
{
|
||||||
const uLong num = uLong(toULong());
|
const uLong num = toULong();
|
||||||
|
|
||||||
if ( num > UINT_MAX )
|
if ( num > UINT_MAX )
|
||||||
throw std::overflow_error ("overflow");
|
throw std::overflow_error ("overflow");
|
||||||
|
@ -518,7 +518,7 @@ long FString::toLong() const
|
||||||
|
|
||||||
while ( std::iswdigit(std::wint_t(*p)) )
|
while ( std::iswdigit(std::wint_t(*p)) )
|
||||||
{
|
{
|
||||||
uChar d = uChar(*p - L'0');
|
auto d = uChar(*p - L'0');
|
||||||
|
|
||||||
if ( num > tenth_limit
|
if ( num > tenth_limit
|
||||||
|| (num == tenth_limit && d > tenth_limit_digit) )
|
|| (num == tenth_limit && d > tenth_limit_digit) )
|
||||||
|
@ -568,7 +568,7 @@ uLong FString::toULong() const
|
||||||
|
|
||||||
while ( std::iswdigit(std::wint_t(*p)) )
|
while ( std::iswdigit(std::wint_t(*p)) )
|
||||||
{
|
{
|
||||||
const uChar d = uChar(*p - L'0');
|
const auto d = uChar(*p - L'0');
|
||||||
|
|
||||||
if ( num > tenth_limit
|
if ( num > tenth_limit
|
||||||
|| (num == tenth_limit && d > tenth_limit_digit) )
|
|| (num == tenth_limit && d > tenth_limit_digit) )
|
||||||
|
@ -628,7 +628,7 @@ double FString::toDouble() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FString::ltrim() const
|
FString FString::ltrim() const
|
||||||
{
|
{
|
||||||
const FString s{*this};
|
const FString s{*this};
|
||||||
|
|
||||||
|
@ -645,7 +645,7 @@ const FString FString::ltrim() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FString::rtrim() const
|
FString FString::rtrim() const
|
||||||
{
|
{
|
||||||
FString s{*this};
|
FString s{*this};
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ const FString FString::rtrim() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FString::trim() const
|
FString FString::trim() const
|
||||||
{
|
{
|
||||||
// handle NULL and empty string
|
// handle NULL and empty string
|
||||||
if ( ! (string && *string) )
|
if ( ! (string && *string) )
|
||||||
|
@ -679,7 +679,7 @@ const FString FString::trim() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FString::left (std::size_t len) const
|
FString FString::left (std::size_t len) const
|
||||||
{
|
{
|
||||||
FString s{*this};
|
FString s{*this};
|
||||||
|
|
||||||
|
@ -697,7 +697,7 @@ const FString FString::left (std::size_t len) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FString::right (std::size_t len) const
|
FString FString::right (std::size_t len) const
|
||||||
{
|
{
|
||||||
const FString s{*this};
|
const FString s{*this};
|
||||||
|
|
||||||
|
@ -714,7 +714,7 @@ const FString FString::right (std::size_t len) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FString::mid (std::size_t pos, std::size_t len) const
|
FString FString::mid (std::size_t pos, std::size_t len) const
|
||||||
{
|
{
|
||||||
const FString s{*this};
|
const FString s{*this};
|
||||||
|
|
||||||
|
@ -771,7 +771,7 @@ FString& FString::setNumber (sInt64 num)
|
||||||
{
|
{
|
||||||
wchar_t buf[30]{};
|
wchar_t buf[30]{};
|
||||||
wchar_t* s = &buf[29]; // Pointer to the last character
|
wchar_t* s = &buf[29]; // Pointer to the last character
|
||||||
uInt64 abs_num = static_cast<uInt64>(num);
|
auto abs_num = static_cast<uInt64>(num);
|
||||||
|
|
||||||
if ( num < 0 )
|
if ( num < 0 )
|
||||||
abs_num = static_cast<uInt64>(-num);
|
abs_num = static_cast<uInt64>(-num);
|
||||||
|
@ -847,7 +847,7 @@ FString& FString::setFormatedNumber (sInt64 num, char separator)
|
||||||
int n{0};
|
int n{0};
|
||||||
wchar_t buf[30]{};
|
wchar_t buf[30]{};
|
||||||
wchar_t* s = &buf[29]; // Pointer to the last character
|
wchar_t* s = &buf[29]; // Pointer to the last character
|
||||||
uInt64 abs_num = static_cast<uInt64>(num);
|
auto abs_num = static_cast<uInt64>(num);
|
||||||
|
|
||||||
if ( separator == 0 )
|
if ( separator == 0 )
|
||||||
separator = ' ';
|
separator = ' ';
|
||||||
|
@ -1001,7 +1001,7 @@ const FString& FString::insert (const FString& s, std::size_t pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FString const FString::replace (const FString& from, const FString& to) const
|
FString FString::replace (const FString& from, const FString& to) const
|
||||||
{
|
{
|
||||||
FString s{*this};
|
FString s{*this};
|
||||||
|
|
||||||
|
@ -1040,7 +1040,7 @@ FString const FString::replace (const FString& from, const FString& to) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FString::replaceControlCodes() const
|
FString FString::replaceControlCodes() const
|
||||||
{
|
{
|
||||||
FString s{*this};
|
FString s{*this};
|
||||||
|
|
||||||
|
@ -1066,7 +1066,7 @@ const FString FString::replaceControlCodes() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FString::expandTabs (int tabstop) const
|
FString FString::expandTabs (int tabstop) const
|
||||||
{
|
{
|
||||||
FString instr{string};
|
FString instr{string};
|
||||||
FString outstr{};
|
FString outstr{};
|
||||||
|
@ -1079,8 +1079,8 @@ const FString FString::expandTabs (int tabstop) const
|
||||||
|
|
||||||
for (std::size_t i{0}; i < last; i++)
|
for (std::size_t i{0}; i < last; i++)
|
||||||
{
|
{
|
||||||
const std::size_t len = tab_split[i].getLength();
|
const auto len = tab_split[i].getLength();
|
||||||
const std::size_t tab_len = std::size_t(tabstop);
|
const auto tab_len = std::size_t(tabstop);
|
||||||
|
|
||||||
if ( i == last - 1 )
|
if ( i == last - 1 )
|
||||||
outstr += tab_split[i];
|
outstr += tab_split[i];
|
||||||
|
@ -1212,7 +1212,7 @@ inline void FString::_initLength (std::size_t len)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string = new wchar_t[bufsize]();
|
string = new wchar_t[bufsize];
|
||||||
std::wmemset (string, L'\0', bufsize);
|
std::wmemset (string, L'\0', bufsize);
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
|
@ -1244,7 +1244,7 @@ void FString::_assign (const wchar_t s[])
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string = new wchar_t[bufsize]();
|
string = new wchar_t[bufsize];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
|
@ -1272,7 +1272,7 @@ void FString::_insert (std::size_t len, const wchar_t s[])
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string = new wchar_t[bufsize]();
|
string = new wchar_t[bufsize];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
|
@ -1319,7 +1319,7 @@ void FString::_insert ( std::size_t pos
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sptr = new wchar_t[bufsize](); // generate new string
|
sptr = new wchar_t[bufsize]; // generate new string
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
|
@ -1363,7 +1363,7 @@ void FString::_remove (std::size_t pos, std::size_t len)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sptr = new wchar_t[bufsize](); // generate new string
|
sptr = new wchar_t[bufsize]; // generate new string
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
|
@ -1417,7 +1417,7 @@ inline const char* FString::_to_cstring (const wchar_t s[]) const
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
c_string = new char[size]();
|
c_string = new char[size];
|
||||||
|
|
||||||
// pre-initialiaze the whole string with '\0'
|
// pre-initialiaze the whole string with '\0'
|
||||||
std::memset (c_string, '\0', size);
|
std::memset (c_string, '\0', size);
|
||||||
|
@ -1467,7 +1467,7 @@ inline const wchar_t* FString::_to_wcstring (const char s[]) const
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dest = new wchar_t[size]();
|
dest = new wchar_t[size];
|
||||||
// pre-initialiaze the whole string with '\0'
|
// pre-initialiaze the whole string with '\0'
|
||||||
std::wmemset (dest, L'\0', size);
|
std::wmemset (dest, L'\0', size);
|
||||||
}
|
}
|
||||||
|
@ -1527,7 +1527,7 @@ inline const wchar_t* FString::_extractToken ( wchar_t* rest[]
|
||||||
|
|
||||||
// FString non-member operators
|
// FString non-member operators
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString operator + (const FString& s1, const FString& s2)
|
FString operator + (const FString& s1, const FString& s2)
|
||||||
{
|
{
|
||||||
FString tmp{s1};
|
FString tmp{s1};
|
||||||
tmp._insert (tmp.length, s2.length, s2.wc_str());
|
tmp._insert (tmp.length, s2.length, s2.wc_str());
|
||||||
|
@ -1535,15 +1535,18 @@ const FString operator + (const FString& s1, const FString& s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString operator + (const FString& s, const wchar_t c)
|
FString operator + (const FString& s, const wchar_t c)
|
||||||
{
|
{
|
||||||
FString tmp{s};
|
FString tmp1{s};
|
||||||
tmp._insert (tmp.length, 1, &c);
|
wchar_t tmp2[2];
|
||||||
return tmp;
|
tmp2[0] = c;
|
||||||
|
tmp2[1] = L'\0';
|
||||||
|
tmp1._insert (tmp1.length, 1, tmp2);
|
||||||
|
return tmp1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString operator + (const std::wstring& s1, const FString& s2)
|
FString operator + (const std::wstring& s1, const FString& s2)
|
||||||
{
|
{
|
||||||
FString tmp{s1};
|
FString tmp{s1};
|
||||||
tmp._insert (tmp.length, s2.length, s2.wc_str());
|
tmp._insert (tmp.length, s2.length, s2.wc_str());
|
||||||
|
@ -1551,7 +1554,7 @@ const FString operator + (const std::wstring& s1, const FString& s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString operator + (const wchar_t s1[], const FString& s2)
|
FString operator + (const wchar_t s1[], const FString& s2)
|
||||||
{
|
{
|
||||||
FString tmp{s1};
|
FString tmp{s1};
|
||||||
tmp._insert (tmp.length, s2.length, s2.wc_str());
|
tmp._insert (tmp.length, s2.length, s2.wc_str());
|
||||||
|
@ -1559,7 +1562,7 @@ const FString operator + (const wchar_t s1[], const FString& s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString operator + (const std::string& s1, const FString& s2)
|
FString operator + (const std::string& s1, const FString& s2)
|
||||||
{
|
{
|
||||||
FString tmp{s1};
|
FString tmp{s1};
|
||||||
tmp._insert (tmp.length, s2.length, s2.wc_str());
|
tmp._insert (tmp.length, s2.length, s2.wc_str());
|
||||||
|
@ -1567,7 +1570,7 @@ const FString operator + (const std::string& s1, const FString& s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString operator + (const char s1[], const FString& s2)
|
FString operator + (const char s1[], const FString& s2)
|
||||||
{
|
{
|
||||||
FString tmp{s1};
|
FString tmp{s1};
|
||||||
tmp._insert (tmp.length, s2.length, s2.wc_str());
|
tmp._insert (tmp.length, s2.length, s2.wc_str());
|
||||||
|
@ -1575,7 +1578,7 @@ const FString operator + (const char s1[], const FString& s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString operator + (const wchar_t c, const FString& s)
|
FString operator + (const wchar_t c, const FString& s)
|
||||||
{
|
{
|
||||||
FString tmp{c};
|
FString tmp{c};
|
||||||
tmp._insert (1, s.length, s.wc_str());
|
tmp._insert (1, s.length, s.wc_str());
|
||||||
|
@ -1583,7 +1586,7 @@ const FString operator + (const wchar_t c, const FString& s)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString operator + (const char c, const FString& s)
|
FString operator + (const char c, const FString& s)
|
||||||
{
|
{
|
||||||
FString tmp{c};
|
FString tmp{c};
|
||||||
tmp._insert (1, s.length, s.wc_str());
|
tmp._insert (1, s.length, s.wc_str());
|
||||||
|
@ -1591,20 +1594,20 @@ const FString operator + (const char c, const FString& s)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString operator + (const FString& s, const char c)
|
FString operator + (const FString& s, const char c)
|
||||||
{
|
{
|
||||||
FString tmp1{s};
|
FString tmp1{s};
|
||||||
wchar_t tmp2[2];
|
wchar_t tmp2[2];
|
||||||
tmp2[0] = wchar_t(c & 0xff);
|
tmp2[0] = wchar_t(c & 0xff);
|
||||||
tmp2[1] = L'\0';
|
tmp2[1] = L'\0';
|
||||||
tmp1._insert (s.length, 1, tmp2);
|
tmp1._insert (tmp1.length, 1, tmp2);
|
||||||
return tmp1;
|
return tmp1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
std::ostream& operator << (std::ostream& outstr, const FString& s)
|
std::ostream& operator << (std::ostream& outstr, const FString& s)
|
||||||
{
|
{
|
||||||
const std::size_t width = std::size_t(outstr.width());
|
const auto width = std::size_t(outstr.width());
|
||||||
|
|
||||||
if ( s.length > 0 )
|
if ( s.length > 0 )
|
||||||
{
|
{
|
||||||
|
@ -1638,7 +1641,7 @@ std::istream& operator >> (std::istream& instr, FString& s)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
std::wostream& operator << (std::wostream& outstr, const FString& s)
|
std::wostream& operator << (std::wostream& outstr, const FString& s)
|
||||||
{
|
{
|
||||||
const std::size_t width = std::size_t(outstr.width());
|
const auto width = std::size_t(outstr.width());
|
||||||
|
|
||||||
if ( s.length > 0 )
|
if ( s.length > 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -141,15 +141,15 @@ void FSwitch::drawCheckButton()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FSwitch::drawChecked()
|
inline void FSwitch::drawChecked()
|
||||||
{
|
{
|
||||||
wchar_t on[6]{L" On "};
|
FString on{L" On "};
|
||||||
const wchar_t off[6]{L" Off "};
|
const FString off{L" Off "};
|
||||||
const auto& wc = getColorTheme();
|
const auto& wc = getColorTheme();
|
||||||
|
|
||||||
if ( hasFocus() && ! button_pressed )
|
if ( hasFocus() && ! button_pressed )
|
||||||
{
|
{
|
||||||
if ( FTerm::isMonochron() )
|
if ( FTerm::isMonochron() )
|
||||||
{
|
{
|
||||||
std::wcsncpy (on, L" <On>", 6);
|
on.setString(L" <On>");
|
||||||
setBold(true);
|
setBold(true);
|
||||||
}
|
}
|
||||||
else if ( FTerm::getMaxColor() < 16 )
|
else if ( FTerm::getMaxColor() < 16 )
|
||||||
|
@ -191,8 +191,8 @@ inline void FSwitch::drawChecked()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FSwitch::drawUnchecked()
|
inline void FSwitch::drawUnchecked()
|
||||||
{
|
{
|
||||||
const wchar_t on[6]{L" On "};
|
const FString on{L" On "};
|
||||||
wchar_t off[6]{L" Off "};
|
FString off{L" Off "};
|
||||||
|
|
||||||
const auto& wc = getColorTheme();
|
const auto& wc = getColorTheme();
|
||||||
setColor (wc->button_inactive_fg, wc->button_inactive_bg);
|
setColor (wc->button_inactive_fg, wc->button_inactive_bg);
|
||||||
|
@ -206,7 +206,7 @@ inline void FSwitch::drawUnchecked()
|
||||||
{
|
{
|
||||||
if ( FTerm::isMonochron() )
|
if ( FTerm::isMonochron() )
|
||||||
{
|
{
|
||||||
std::wcsncpy (off, L"<Off>", 6);
|
off.setString(L"<Off>");
|
||||||
setBold(true);
|
setBold(true);
|
||||||
}
|
}
|
||||||
else if ( FTerm::getMaxColor() < 16 )
|
else if ( FTerm::getMaxColor() < 16 )
|
||||||
|
|
119
src/fterm.cpp
119
src/fterm.cpp
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -158,7 +159,7 @@ std::size_t FTerm::getColumnNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FTerm::getKeyName (FKey keynum)
|
FString FTerm::getKeyName (FKey keynum)
|
||||||
{
|
{
|
||||||
return keyboard->getKeyName (keynum);
|
return keyboard->getKeyName (keynum);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +203,7 @@ int FTerm::getMaxColor()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FTerm::FColorPalettePtr& FTerm::getColorPaletteTheme()
|
FTerm::FColorPalettePtr& FTerm::getColorPaletteTheme()
|
||||||
{
|
{
|
||||||
static FColorPalettePtr* color_theme = new FColorPalettePtr();
|
static auto color_theme = new FColorPalettePtr();
|
||||||
return *color_theme;
|
return *color_theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,6 +713,7 @@ bool FTerm::setVGAFont()
|
||||||
data->setVGAFont(true);
|
data->setVGAFont(true);
|
||||||
// Set font in xterm to vga
|
// Set font in xterm to vga
|
||||||
getFTermXTerminal()->setFont("vga");
|
getFTermXTerminal()->setFont("vga");
|
||||||
|
data->setTermEncoding (fc::PC);
|
||||||
data->setNewFont(false);
|
data->setNewFont(false);
|
||||||
}
|
}
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
|
@ -767,7 +769,7 @@ bool FTerm::setNewFont()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FTerm::setOldFont()
|
bool FTerm::resetFont()
|
||||||
{
|
{
|
||||||
bool retval{false};
|
bool retval{false};
|
||||||
|
|
||||||
|
@ -820,16 +822,15 @@ int FTerm::openConsole()
|
||||||
int fd = data->getTTYFileDescriptor();
|
int fd = data->getTTYFileDescriptor();
|
||||||
const char* termfilename = data->getTermFileName();
|
const char* termfilename = data->getTermFileName();
|
||||||
|
|
||||||
static const char* terminal_devices[] =
|
constexpr std::array<const char*, 6> terminal_devices =
|
||||||
{
|
{{
|
||||||
"/proc/self/fd/0",
|
"/proc/self/fd/0",
|
||||||
"/dev/tty",
|
"/dev/tty",
|
||||||
"/dev/tty0",
|
"/dev/tty0",
|
||||||
"/dev/vc/0",
|
"/dev/vc/0",
|
||||||
"/dev/systty",
|
"/dev/systty",
|
||||||
"/dev/console",
|
"/dev/console"
|
||||||
nullptr
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
if ( fd >= 0 ) // console is already opened
|
if ( fd >= 0 ) // console is already opened
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -837,9 +838,9 @@ int FTerm::openConsole()
|
||||||
if ( ! *termfilename || ! fsys )
|
if ( ! *termfilename || ! fsys )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (std::size_t i{0}; terminal_devices[i] != nullptr; i++)
|
for (auto&& entry : terminal_devices)
|
||||||
{
|
{
|
||||||
fd = fsys->open(terminal_devices[i], O_RDWR, 0);
|
fd = fsys->open(entry, O_RDWR, 0);
|
||||||
data->setTTYFileDescriptor(fd);
|
data->setTTYFileDescriptor(fd);
|
||||||
|
|
||||||
if ( fd >= 0 )
|
if ( fd >= 0 )
|
||||||
|
@ -1191,11 +1192,11 @@ wchar_t FTerm::charEncode (wchar_t c, fc::encoding enc)
|
||||||
{
|
{
|
||||||
wchar_t ch_enc = c;
|
wchar_t ch_enc = c;
|
||||||
|
|
||||||
for (std::size_t i{0}; i <= fc::lastCharItem; i++)
|
for (auto&& entry : fc::character)
|
||||||
{
|
{
|
||||||
if ( fc::character[i][fc::UTF8] == uInt(c) )
|
if ( entry[fc::UTF8] == uInt(c) )
|
||||||
{
|
{
|
||||||
ch_enc = wchar_t(fc::character[i][enc]);
|
ch_enc = wchar_t(entry[enc]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1235,7 +1236,7 @@ bool FTerm::scrollTermReverse()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FTerm::defaultPutChar& FTerm::putchar()
|
FTerm::defaultPutChar& FTerm::putchar()
|
||||||
{
|
{
|
||||||
static defaultPutChar* fputchar = new defaultPutChar();
|
static auto fputchar = new defaultPutChar();
|
||||||
return *fputchar;
|
return *fputchar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1362,13 +1363,13 @@ void FTerm::init_global_values()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTerm::init_terminal_device_path()
|
void FTerm::init_terminal_device_path()
|
||||||
{
|
{
|
||||||
char termfilename[256]{};
|
std::array<char, 256> termfilename{};
|
||||||
const int stdout_no = FTermios::getStdOut();
|
const int stdout_no = FTermios::getStdOut();
|
||||||
|
|
||||||
if ( ttyname_r(stdout_no, termfilename, sizeof(termfilename)) )
|
if ( ttyname_r(stdout_no, termfilename.data(), termfilename.size()) )
|
||||||
termfilename[0] = '\0';
|
termfilename[0] = '\0';
|
||||||
|
|
||||||
data->setTermFileName(termfilename);
|
data->setTermFileName(termfilename.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1408,8 +1409,8 @@ void FTerm::init_alt_charset()
|
||||||
for (std::size_t n{0}; TCAP(fc::t_acs_chars)[n]; n += 2)
|
for (std::size_t n{0}; TCAP(fc::t_acs_chars)[n]; n += 2)
|
||||||
{
|
{
|
||||||
// insert the VT100 key/value pairs into a map
|
// insert the VT100 key/value pairs into a map
|
||||||
const uChar p1 = uChar(TCAP(fc::t_acs_chars)[n]);
|
const auto p1 = uChar(TCAP(fc::t_acs_chars)[n]);
|
||||||
const uChar p2 = uChar(TCAP(fc::t_acs_chars)[n + 1]);
|
const auto p2 = uChar(TCAP(fc::t_acs_chars)[n + 1]);
|
||||||
vt100_alt_char[p1] = p2;
|
vt100_alt_char[p1] = p2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1421,19 +1422,18 @@ void FTerm::init_alt_charset()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update array 'character' with discovered VT100 pairs
|
// Update array 'character' with discovered VT100 pairs
|
||||||
for (std::size_t n{0}; n <= fc::lastKeyItem; n++ )
|
for (auto&& pair : fc::vt100_key_to_utf8)
|
||||||
{
|
{
|
||||||
const uChar keyChar = uChar(fc::vt100_key_to_utf8[n][vt100_key]);
|
const auto keyChar = uChar(pair[vt100_key]);
|
||||||
const uChar altChar = uChar(vt100_alt_char[keyChar]);
|
const auto altChar = uChar(vt100_alt_char[keyChar]);
|
||||||
const uInt utf8char = uInt(fc::vt100_key_to_utf8[n][utf8_char]);
|
const auto utf8char = uInt(pair[utf8_char]);
|
||||||
const fc::encoding num{fc::NUM_OF_ENCODINGS};
|
const auto p = std::find_if ( fc::character.begin()
|
||||||
|
, fc::character.end()
|
||||||
uInt* p = std::find ( fc::character[0]
|
, [&utf8char] (std::array<uInt, 4> entry)
|
||||||
, fc::character[fc::lastCharItem] + num
|
{ return entry[0] == utf8char; } );
|
||||||
, utf8char );
|
if ( p != fc::character.end() ) // found in character
|
||||||
if ( p != fc::character[fc::lastCharItem] + num ) // found in character
|
|
||||||
{
|
{
|
||||||
const int item = int(std::distance(fc::character[0], p) / num);
|
const auto item = std::size_t(std::distance(fc::character.begin(), p));
|
||||||
|
|
||||||
if ( altChar ) // update alternate character set
|
if ( altChar ) // update alternate character set
|
||||||
fc::character[item][fc::VT100] = altChar;
|
fc::character[item][fc::VT100] = altChar;
|
||||||
|
@ -1506,24 +1506,24 @@ void FTerm::init_cygwin_charmap()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// PC encoding changes
|
// PC encoding changes
|
||||||
for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
|
for (auto&& entry : fc::character)
|
||||||
{
|
{
|
||||||
if ( fc::character[i][fc::UTF8] == fc::BlackUpPointingTriangle ) // ▲
|
if ( entry[fc::UTF8] == fc::BlackUpPointingTriangle ) // ▲
|
||||||
fc::character[i][fc::PC] = 0x18;
|
entry[fc::PC] = 0x18;
|
||||||
|
|
||||||
if ( fc::character[i][fc::UTF8] == fc::BlackDownPointingTriangle ) // ▼
|
if ( entry[fc::UTF8] == fc::BlackDownPointingTriangle ) // ▼
|
||||||
fc::character[i][fc::PC] = 0x19;
|
entry[fc::PC] = 0x19;
|
||||||
|
|
||||||
if ( fc::character[i][fc::UTF8] == fc::InverseBullet // ◘
|
if ( entry[fc::UTF8] == fc::InverseBullet // ◘
|
||||||
|| fc::character[i][fc::UTF8] == fc::InverseWhiteCircle // ◙
|
|| entry[fc::UTF8] == fc::InverseWhiteCircle // ◙
|
||||||
|| fc::character[i][fc::UTF8] == fc::UpDownArrow // ↕
|
|| entry[fc::UTF8] == fc::UpDownArrow // ↕
|
||||||
|| fc::character[i][fc::UTF8] == fc::LeftRightArrow // ↔
|
|| entry[fc::UTF8] == fc::LeftRightArrow // ↔
|
||||||
|| fc::character[i][fc::UTF8] == fc::DoubleExclamationMark // ‼
|
|| entry[fc::UTF8] == fc::DoubleExclamationMark // ‼
|
||||||
|| fc::character[i][fc::UTF8] == fc::BlackRectangle // ▬
|
|| entry[fc::UTF8] == fc::BlackRectangle // ▬
|
||||||
|| fc::character[i][fc::UTF8] == fc::RightwardsArrow // →
|
|| entry[fc::UTF8] == fc::RightwardsArrow // →
|
||||||
|| fc::character[i][fc::UTF8] == fc::Section // §
|
|| entry[fc::UTF8] == fc::Section // §
|
||||||
|| fc::character[i][fc::UTF8] == fc::SquareRoot ) // SquareRoot √
|
|| entry[fc::UTF8] == fc::SquareRoot ) // SquareRoot √
|
||||||
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
|
entry[fc::PC] = entry[fc::ASCII];
|
||||||
}
|
}
|
||||||
|
|
||||||
// General encoding changes
|
// General encoding changes
|
||||||
|
@ -1560,9 +1560,9 @@ void FTerm::init_teraterm_charmap()
|
||||||
if ( ! isTeraTerm() )
|
if ( ! isTeraTerm() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
|
for (auto&& entry : fc::character)
|
||||||
if ( fc::character[i][fc::PC] < 0x20 )
|
if ( entry[fc::PC] < 0x20 )
|
||||||
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
|
entry[fc::PC] = entry[fc::ASCII];
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1592,7 +1592,7 @@ void FTerm::init_optiMove()
|
||||||
{
|
{
|
||||||
// Duration precalculation of the cursor movement strings
|
// Duration precalculation of the cursor movement strings
|
||||||
|
|
||||||
FOptiMove::termEnv optimove_env =
|
FOptiMove::TermEnv optimove_env =
|
||||||
{
|
{
|
||||||
TCAP(fc::t_cursor_home),
|
TCAP(fc::t_cursor_home),
|
||||||
TCAP(fc::t_carriage_return),
|
TCAP(fc::t_carriage_return),
|
||||||
|
@ -1627,7 +1627,7 @@ void FTerm::init_optiAttr()
|
||||||
{
|
{
|
||||||
// Setting video attribute optimization
|
// Setting video attribute optimization
|
||||||
|
|
||||||
FOptiAttr::termEnv optiattr_env =
|
FOptiAttr::TermEnv optiattr_env =
|
||||||
{
|
{
|
||||||
TCAP(fc::t_enter_bold_mode),
|
TCAP(fc::t_enter_bold_mode),
|
||||||
TCAP(fc::t_exit_bold_mode),
|
TCAP(fc::t_exit_bold_mode),
|
||||||
|
@ -2006,21 +2006,22 @@ const char* FTerm::enableCursorString()
|
||||||
// Returns the cursor enable string
|
// Returns the cursor enable string
|
||||||
|
|
||||||
static constexpr std::size_t SIZE = 32;
|
static constexpr std::size_t SIZE = 32;
|
||||||
static char enable_str[SIZE]{};
|
static std::array<char, SIZE> enable_str{};
|
||||||
const auto& vs = TCAP(fc::t_cursor_visible);
|
const auto& vs = TCAP(fc::t_cursor_visible);
|
||||||
const auto& ve = TCAP(fc::t_cursor_normal);
|
const auto& ve = TCAP(fc::t_cursor_normal);
|
||||||
|
|
||||||
if ( ve )
|
if ( ve )
|
||||||
std::strncpy (enable_str, ve, SIZE - 1);
|
std::strncpy (enable_str.data(), ve, SIZE - 1);
|
||||||
else if ( vs )
|
else if ( vs )
|
||||||
std::strncpy (enable_str, vs, SIZE - 1);
|
std::strncpy (enable_str.data(), vs, SIZE - 1);
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
if ( isLinuxTerm() )
|
if ( isLinuxTerm() )
|
||||||
{
|
{
|
||||||
// Restore the last used Linux console cursor style
|
// Restore the last used Linux console cursor style
|
||||||
const char* cstyle = linux->getCursorStyleString();
|
const char* cstyle = linux->getCursorStyleString();
|
||||||
std::strncat (enable_str, cstyle, SIZE - std::strlen(enable_str) - 1);
|
std::size_t length = std::strlen(enable_str.data());
|
||||||
|
std::strncat (enable_str.data(), cstyle, SIZE - length - 1);
|
||||||
}
|
}
|
||||||
#endif // defined(__linux__)
|
#endif // defined(__linux__)
|
||||||
|
|
||||||
|
@ -2034,7 +2035,7 @@ const char* FTerm::enableCursorString()
|
||||||
}
|
}
|
||||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||||
|
|
||||||
return enable_str;
|
return enable_str.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -2471,12 +2472,10 @@ void FTerm::initBaudRate() const
|
||||||
void FTerm::finish() const
|
void FTerm::finish() const
|
||||||
{
|
{
|
||||||
// Set default signal handler
|
// Set default signal handler
|
||||||
|
|
||||||
const auto& title = data->getXtermTitle();
|
|
||||||
resetSignalHandler();
|
resetSignalHandler();
|
||||||
|
|
||||||
if ( title && isXTerminal() && ! isRxvtTerminal() )
|
if ( isXTerminal() && ! isRxvtTerminal() )
|
||||||
setTermTitle (title);
|
getFTermXTerminal()->resetTitle();
|
||||||
|
|
||||||
// Restore the saved termios settings
|
// Restore the saved termios settings
|
||||||
FTermios::restoreTTYsettings();
|
FTermios::restoreTTYsettings();
|
||||||
|
@ -2531,7 +2530,7 @@ void FTerm::finish() const
|
||||||
finish_encoding();
|
finish_encoding();
|
||||||
|
|
||||||
if ( data->isNewFont() || data->isVGAFont() )
|
if ( data->isNewFont() || data->isVGAFont() )
|
||||||
setOldFont();
|
resetFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -32,8 +33,10 @@
|
||||||
#include "final/fapplication.h"
|
#include "final/fapplication.h"
|
||||||
#include "final/fcharmap.h"
|
#include "final/fcharmap.h"
|
||||||
#include "final/flog.h"
|
#include "final/flog.h"
|
||||||
|
#include "final/fpoint.h"
|
||||||
#include "final/fterm.h"
|
#include "final/fterm.h"
|
||||||
#include "final/ftermbuffer.h"
|
#include "final/ftermbuffer.h"
|
||||||
|
#include "final/ftermios.h"
|
||||||
|
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
|
@ -274,11 +277,11 @@ wchar_t cp437_to_unicode (uChar c)
|
||||||
constexpr std::size_t UNICODE = 1;
|
constexpr std::size_t UNICODE = 1;
|
||||||
wchar_t ucs = c;
|
wchar_t ucs = c;
|
||||||
|
|
||||||
for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
|
for (auto&& entry : fc::cp437_ucs)
|
||||||
{
|
{
|
||||||
if ( fc::cp437_ucs[i][CP437] == c ) // found
|
if ( entry[CP437] == c ) // found
|
||||||
{
|
{
|
||||||
ucs = fc::cp437_ucs[i][UNICODE];
|
ucs = entry[UNICODE];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,11 +296,11 @@ uChar unicode_to_cp437 (wchar_t ucs)
|
||||||
constexpr std::size_t UNICODE = 1;
|
constexpr std::size_t UNICODE = 1;
|
||||||
uChar c{'?'};
|
uChar c{'?'};
|
||||||
|
|
||||||
for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
|
for (auto&& entry : fc::cp437_ucs)
|
||||||
{
|
{
|
||||||
if ( fc::cp437_ucs[i][UNICODE] == ucs ) // found
|
if ( entry[UNICODE] == ucs ) // found
|
||||||
{
|
{
|
||||||
c = uChar(fc::cp437_ucs[i][CP437]);
|
c = uChar(entry[CP437]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,7 +309,7 @@ uChar unicode_to_cp437 (wchar_t ucs)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString getFullWidth (const FString& str)
|
FString getFullWidth (const FString& str)
|
||||||
{
|
{
|
||||||
// Converts half-width to full-width characters
|
// Converts half-width to full-width characters
|
||||||
|
|
||||||
|
@ -322,10 +325,10 @@ const FString getFullWidth (const FString& str)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
|
for (auto&& entry : fc::halfwidth_fullwidth)
|
||||||
{
|
{
|
||||||
if ( fc::halfWidth_fullWidth[i][HALF] == c ) // found
|
if ( entry[HALF] == c ) // found
|
||||||
c = fc::halfWidth_fullWidth[i][FULL];
|
c = entry[FULL];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,7 +337,7 @@ const FString getFullWidth (const FString& str)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString getHalfWidth (const FString& str)
|
FString getHalfWidth (const FString& str)
|
||||||
{
|
{
|
||||||
// Converts full-width to half-width characters
|
// Converts full-width to half-width characters
|
||||||
|
|
||||||
|
@ -350,10 +353,10 @@ const FString getHalfWidth (const FString& str)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
|
for (auto&& entry : fc::halfwidth_fullwidth)
|
||||||
{
|
{
|
||||||
if ( fc::halfWidth_fullWidth[i][FULL] == c ) // found
|
if ( entry[FULL] == c ) // found
|
||||||
c = fc::halfWidth_fullWidth[i][HALF];
|
c = entry[HALF];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,7 +365,7 @@ const FString getHalfWidth (const FString& str)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString getColumnSubString ( const FString& str
|
FString getColumnSubString ( const FString& str
|
||||||
, std::size_t col_pos
|
, std::size_t col_pos
|
||||||
, std::size_t col_len )
|
, std::size_t col_len )
|
||||||
{
|
{
|
||||||
|
@ -457,7 +460,7 @@ std::size_t getColumnWidth (const FString& s, std::size_t pos)
|
||||||
}
|
}
|
||||||
catch (const std::out_of_range& ex)
|
catch (const std::out_of_range& ex)
|
||||||
{
|
{
|
||||||
*FApplication::getLog() << FLog::Error
|
std::clog << FLog::Error
|
||||||
<< "Out of Range error: " << ex.what() << std::endl;
|
<< "Out of Range error: " << ex.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -530,4 +533,52 @@ std::size_t getColumnWidth (const FTermBuffer& tb)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
FPoint readCursorPos()
|
||||||
|
{
|
||||||
|
int x{-1};
|
||||||
|
int y{-1};
|
||||||
|
const int stdin_no{FTermios::getStdIn()};
|
||||||
|
const int stdout_no{FTermios::getStdOut()};
|
||||||
|
fd_set ifds{};
|
||||||
|
struct timeval tv{};
|
||||||
|
constexpr auto& DECXCPR{ESC "[6n"};
|
||||||
|
|
||||||
|
// Report Cursor Position (DECXCPR)
|
||||||
|
if ( write(stdout_no, DECXCPR, std::strlen(DECXCPR)) < 1 )
|
||||||
|
return FPoint{x, y};
|
||||||
|
|
||||||
|
std::fflush(stdout);
|
||||||
|
FD_ZERO(&ifds);
|
||||||
|
FD_SET(stdin_no, &ifds);
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 100000; // 100 ms
|
||||||
|
std::array<char, 20> temp{};
|
||||||
|
std::size_t pos{0};
|
||||||
|
|
||||||
|
// Read the answer
|
||||||
|
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) != 1 )
|
||||||
|
return FPoint{x, y};
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
std::size_t bytes_free = temp.size() - pos - 1;
|
||||||
|
const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free);
|
||||||
|
|
||||||
|
if ( bytes <= 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
pos += std::size_t(bytes);
|
||||||
|
}
|
||||||
|
while ( pos < temp.size() && ! std::strchr(temp.data(), 'R') );
|
||||||
|
|
||||||
|
if ( pos > 4 )
|
||||||
|
{
|
||||||
|
constexpr auto parse = "\033[%4d;%4dR";
|
||||||
|
std::sscanf(temp.data(), parse, &x, &y);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FPoint{x, y};
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
|
@ -43,7 +43,7 @@ FTermBuffer::~FTermBuffer() // destructor
|
||||||
|
|
||||||
// public methods of FTermBuffer
|
// public methods of FTermBuffer
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FTermBuffer::toString() const
|
FString FTermBuffer::toString() const
|
||||||
{
|
{
|
||||||
std::wstring wide_string{};
|
std::wstring wide_string{};
|
||||||
wide_string.reserve(data.size());
|
wide_string.reserve(data.size());
|
||||||
|
@ -62,7 +62,7 @@ const FString FTermBuffer::toString() const
|
||||||
int FTermBuffer::write (const FString& string)
|
int FTermBuffer::write (const FString& string)
|
||||||
{
|
{
|
||||||
assert ( ! string.isNull() );
|
assert ( ! string.isNull() );
|
||||||
const int len = int(string.getLength());
|
const auto len = int(string.getLength());
|
||||||
|
|
||||||
for (auto&& c : string)
|
for (auto&& c : string)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "final/emptyfstring.h"
|
#include "final/emptyfstring.h"
|
||||||
#include "final/fc.h"
|
#include "final/fc.h"
|
||||||
#include "final/fkey_map.h"
|
#include "final/fkey_map.h"
|
||||||
|
#include "final/flog.h"
|
||||||
#include "final/fsystem.h"
|
#include "final/fsystem.h"
|
||||||
#include "final/fterm.h"
|
#include "final/fterm.h"
|
||||||
#include "final/ftermdata.h"
|
#include "final/ftermdata.h"
|
||||||
|
@ -90,7 +91,7 @@ void FTermcap::termcap()
|
||||||
|
|
||||||
// Open termcap file
|
// Open termcap file
|
||||||
#if defined(__sun) && defined(__SVR4)
|
#if defined(__sun) && defined(__SVR4)
|
||||||
char* termtype = fterm_data->getTermType();
|
char* termtype = const_cast<char*>(fterm_data->getTermType());
|
||||||
#else
|
#else
|
||||||
const char* termtype = fterm_data->getTermType();
|
const char* termtype = fterm_data->getTermType();
|
||||||
#endif
|
#endif
|
||||||
|
@ -127,12 +128,11 @@ void FTermcap::termcapError (int status)
|
||||||
static constexpr int no_entry = 0;
|
static constexpr int no_entry = 0;
|
||||||
static constexpr int db_not_found = -1;
|
static constexpr int db_not_found = -1;
|
||||||
static constexpr int uninitialized = -2;
|
static constexpr int uninitialized = -2;
|
||||||
finalcut::FLog& log = *FApplication::getLog();
|
|
||||||
|
|
||||||
if ( status == no_entry || status == uninitialized )
|
if ( status == no_entry || status == uninitialized )
|
||||||
{
|
{
|
||||||
const char* termtype = fterm_data->getTermType();
|
const char* termtype = fterm_data->getTermType();
|
||||||
log << FLog::Error
|
std::clog << FLog::Error
|
||||||
<< "Unknown terminal: \"" << termtype << "\". "
|
<< "Unknown terminal: \"" << termtype << "\". "
|
||||||
<< "Check the TERM environment variable. "
|
<< "Check the TERM environment variable. "
|
||||||
<< "Also make sure that the terminal "
|
<< "Also make sure that the terminal "
|
||||||
|
@ -142,7 +142,7 @@ void FTermcap::termcapError (int status)
|
||||||
}
|
}
|
||||||
else if ( status == db_not_found )
|
else if ( status == db_not_found )
|
||||||
{
|
{
|
||||||
log << "The termcap/terminfo database could not be found."
|
std::clog << "The termcap/terminfo database could not be found."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
@ -224,8 +224,9 @@ void FTermcap::termcapStrings()
|
||||||
// Get termcap strings
|
// Get termcap strings
|
||||||
|
|
||||||
// Read termcap output strings
|
// Read termcap output strings
|
||||||
for (std::size_t i{0}; strings[i].tname[0] != 0; i++)
|
|
||||||
strings[i].string = getString(strings[i].tname);
|
for (auto&& entry : strings)
|
||||||
|
entry.string = getString(entry.tname);
|
||||||
|
|
||||||
const auto& ho = TCAP(fc::t_cursor_home);
|
const auto& ho = TCAP(fc::t_cursor_home);
|
||||||
|
|
||||||
|
@ -239,10 +240,13 @@ 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 ( std::size_t i{0};
|
for (auto&& entry : fc::fkey)
|
||||||
fc::fkey[i].string == nullptr && fc::fkey[i].tname[0] != 0;
|
{
|
||||||
i++ )
|
if ( entry.string != nullptr )
|
||||||
fc::fkey[i].string = getString(fc::fkey[i].tname);
|
break;
|
||||||
|
|
||||||
|
entry.string = getString(entry.tname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -257,8 +261,8 @@ int FTermcap::_tputs (const char* str, int affcnt, fn_putc putc)
|
||||||
|
|
||||||
// private Data Member of FTermcap - termcap capabilities
|
// private Data Member of FTermcap - termcap capabilities
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FTermcap::tcap_map FTermcap::strings[] =
|
FTermcap::TCapMapType FTermcap::strings =
|
||||||
{
|
{{
|
||||||
// .------------- term string
|
// .------------- term string
|
||||||
// | .-------- Tcap-code
|
// | .-------- Tcap-code
|
||||||
// | | // variable name -> description
|
// | | // variable name -> description
|
||||||
|
@ -347,9 +351,8 @@ FTermcap::tcap_map FTermcap::strings[] =
|
||||||
{ nullptr, "ac" }, // acs_chars -> graphics charset pairs (vt100)
|
{ nullptr, "ac" }, // acs_chars -> graphics charset pairs (vt100)
|
||||||
{ nullptr, "ks" }, // keypad_xmit -> enter 'key-board_transmit' mode
|
{ nullptr, "ks" }, // keypad_xmit -> enter 'key-board_transmit' mode
|
||||||
{ nullptr, "ke" }, // keypad_local -> leave 'key-board_transmit' mode
|
{ nullptr, "ke" }, // keypad_local -> leave 'key-board_transmit' mode
|
||||||
{ nullptr, "Km" }, // key_mouse -> Mouse event has occurred
|
{ nullptr, "Km" } // key_mouse -> Mouse event has occurred
|
||||||
{ nullptr, "\0" }
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (P) indicates that padding may be specified
|
* (P) indicates that padding may be specified
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "final/fc.h"
|
#include "final/fc.h"
|
||||||
|
@ -267,6 +268,25 @@ void FTermcapQuirks::vte()
|
||||||
// set exit underline for gnome terminal
|
// set exit underline for gnome terminal
|
||||||
TCAP(fc::t_exit_underline_mode) = \
|
TCAP(fc::t_exit_underline_mode) = \
|
||||||
CSI "24m";
|
CSI "24m";
|
||||||
|
|
||||||
|
if ( term_detection->getGnomeTerminalID() >= 5300 ) // vte >= 0.53.0
|
||||||
|
{
|
||||||
|
if ( ! std::strstr(TCAP(fc::t_enter_ca_mode), "\033[22;0;0t") )
|
||||||
|
{
|
||||||
|
// Save the cursor position, enter alternate screen buffer
|
||||||
|
// and save xterm icon and window title on stack
|
||||||
|
TCAP(fc::t_enter_ca_mode) = \
|
||||||
|
CSI "?1049h" CSI "22;0;0t";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! std::strstr(TCAP(fc::t_exit_ca_mode), "\033[23;0;0t") )
|
||||||
|
{
|
||||||
|
// Use normal screen buffer, restore the cursor position
|
||||||
|
// and restore xterm icon and window title from stack
|
||||||
|
TCAP(fc::t_exit_ca_mode) = \
|
||||||
|
CSI "?1049l" CSI "23;0;0t";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -24,10 +24,13 @@
|
||||||
#include "final/fconfig.h" // includes _GNU_SOURCE for fd_set
|
#include "final/fconfig.h" // includes _GNU_SOURCE for fd_set
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "final/emptyfstring.h"
|
#include "final/emptyfstring.h"
|
||||||
#include "final/fapplication.h"
|
#include "final/fapplication.h"
|
||||||
#include "final/fc.h"
|
#include "final/fc.h"
|
||||||
#include "final/flog.h"
|
#include "final/flog.h"
|
||||||
|
#include "final/fkeyboard.h"
|
||||||
#include "final/fsystem.h"
|
#include "final/fsystem.h"
|
||||||
#include "final/fterm.h"
|
#include "final/fterm.h"
|
||||||
#include "final/ftermcap.h"
|
#include "final/ftermcap.h"
|
||||||
|
@ -53,6 +56,7 @@ FTermDetection::colorEnv FTermDetection::color_env{};
|
||||||
FTermDetection::secondaryDA FTermDetection::secondary_da{};
|
FTermDetection::secondaryDA FTermDetection::secondary_da{};
|
||||||
FTermData* FTermDetection::fterm_data{nullptr};
|
FTermData* FTermDetection::fterm_data{nullptr};
|
||||||
FSystem* FTermDetection::fsystem{nullptr};
|
FSystem* FTermDetection::fsystem{nullptr};
|
||||||
|
FKeyboard* FTermDetection::keyboard{nullptr};
|
||||||
char FTermDetection::termtype[256]{};
|
char FTermDetection::termtype[256]{};
|
||||||
char FTermDetection::ttytypename[256]{};
|
char FTermDetection::ttytypename[256]{};
|
||||||
bool FTermDetection::decscusr_support{};
|
bool FTermDetection::decscusr_support{};
|
||||||
|
@ -130,6 +134,7 @@ void FTermDetection::detect()
|
||||||
{
|
{
|
||||||
fterm_data = FTerm::getFTermData();
|
fterm_data = FTerm::getFTermData();
|
||||||
fsystem = FTerm::getFSystem();
|
fsystem = FTerm::getFSystem();
|
||||||
|
keyboard = FTerm::getFKeyboard();
|
||||||
deallocation();
|
deallocation();
|
||||||
|
|
||||||
// Set the variable 'termtype' to the predefined type of the terminal
|
// Set the variable 'termtype' to the predefined type of the terminal
|
||||||
|
@ -320,6 +325,14 @@ void FTermDetection::termtypeAnalysis()
|
||||||
if ( std::strncmp(termtype, "mlterm", 6) == 0 )
|
if ( std::strncmp(termtype, "mlterm", 6) == 0 )
|
||||||
terminal_type.mlterm = true;
|
terminal_type.mlterm = true;
|
||||||
|
|
||||||
|
// rxvt
|
||||||
|
if ( std::strncmp(termtype, "rxvt", 4) == 0 )
|
||||||
|
terminal_type.rxvt = true;
|
||||||
|
|
||||||
|
// urxvt
|
||||||
|
if ( std::strncmp(termtype, "rxvt-unicode", 12) == 0 )
|
||||||
|
terminal_type.urxvt = true;
|
||||||
|
|
||||||
// screen/tmux
|
// screen/tmux
|
||||||
if ( std::strncmp(termtype, "screen", 6) == 0 )
|
if ( std::strncmp(termtype, "screen", 6) == 0 )
|
||||||
{
|
{
|
||||||
|
@ -350,6 +363,7 @@ void FTermDetection::detectTerminal()
|
||||||
if ( terminal_detection )
|
if ( terminal_detection )
|
||||||
{
|
{
|
||||||
FTermios::setCaptureSendCharacters();
|
FTermios::setCaptureSendCharacters();
|
||||||
|
keyboard->setNonBlockingInput();
|
||||||
|
|
||||||
// Initialize 256 colors terminals
|
// Initialize 256 colors terminals
|
||||||
new_termtype = init_256colorTerminal();
|
new_termtype = init_256colorTerminal();
|
||||||
|
@ -363,6 +377,7 @@ void FTermDetection::detectTerminal()
|
||||||
// Determines the maximum number of colors
|
// Determines the maximum number of colors
|
||||||
new_termtype = determineMaxColor(new_termtype);
|
new_termtype = determineMaxColor(new_termtype);
|
||||||
|
|
||||||
|
keyboard->unsetNonBlockingInput();
|
||||||
FTermios::unsetCaptureSendCharacters();
|
FTermios::unsetCaptureSendCharacters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,6 +532,7 @@ 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
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
const char* new_termtype = current_termtype;
|
||||||
|
keyboard->setNonBlockingInput();
|
||||||
|
|
||||||
if ( ! color256
|
if ( ! color256
|
||||||
&& ! isCygwinTerminal()
|
&& ! isCygwinTerminal()
|
||||||
|
@ -544,13 +560,15 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keyboard->unsetNonBlockingInput();
|
||||||
return new_termtype;
|
return new_termtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FTermDetection::getXTermColorName (FColor color)
|
FString FTermDetection::getXTermColorName (FColor color)
|
||||||
{
|
{
|
||||||
FString color_str{""};
|
FString color_str{""};
|
||||||
|
std::array<char, 30> buf{};
|
||||||
fd_set ifds{};
|
fd_set ifds{};
|
||||||
struct timeval tv{};
|
struct timeval tv{};
|
||||||
const int stdin_no = FTermios::getStdIn();
|
const int stdin_no = FTermios::getStdIn();
|
||||||
|
@ -558,28 +576,44 @@ const FString FTermDetection::getXTermColorName (FColor color)
|
||||||
// get color
|
// get color
|
||||||
std::fprintf (stdout, OSC "4;%hu;?" BEL, color);
|
std::fprintf (stdout, OSC "4;%hu;?" BEL, color);
|
||||||
std::fflush (stdout);
|
std::fflush (stdout);
|
||||||
|
|
||||||
char temp[512]{};
|
|
||||||
FD_ZERO(&ifds);
|
FD_ZERO(&ifds);
|
||||||
FD_SET(stdin_no, &ifds);
|
FD_SET(stdin_no, &ifds);
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 150000; // 150 ms
|
tv.tv_usec = 150000; // 150 ms
|
||||||
|
|
||||||
// read the terminal answer
|
// read the terminal answer
|
||||||
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0
|
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 )
|
||||||
&& std::scanf("\033]4;%10hu;%509[^\n]s", &color, temp) == 2 )
|
return color_str;
|
||||||
|
|
||||||
|
constexpr auto parse = "\033]4;%10hu;%509[^\n]s";
|
||||||
|
std::array<char, 35> temp{};
|
||||||
|
std::size_t pos{0};
|
||||||
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
std::size_t n = std::strlen(temp);
|
std::size_t bytes_free = temp.size() - pos - 1;
|
||||||
|
const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free);
|
||||||
|
|
||||||
|
if ( bytes <= 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
pos += std::size_t(bytes);
|
||||||
|
}
|
||||||
|
while ( pos < temp.size() );
|
||||||
|
|
||||||
|
if ( pos > 4 && std::sscanf(temp.data(), parse, &color, buf.data()) == 2 )
|
||||||
|
{
|
||||||
|
std::size_t n = std::strlen(buf.data());
|
||||||
|
|
||||||
// BEL + '\0' = string terminator
|
// BEL + '\0' = string terminator
|
||||||
if ( n >= 6 && temp[n - 1] == BEL[0] && temp[n] == '\0' )
|
if ( n >= 6 && buf[n - 1] == BEL[0] && buf[n] == '\0' )
|
||||||
temp[n - 1] = '\0';
|
buf[n - 1] = '\0';
|
||||||
|
|
||||||
// Esc + \ = OSC string terminator (mintty)
|
// Esc + \ = OSC string terminator (mintty)
|
||||||
if ( n >= 6 && temp[n - 2] == ESC[0] && temp[n - 1] == '\\' )
|
if ( n >= 6 && buf[n - 2] == ESC[0] && buf[n - 1] == '\\' )
|
||||||
temp[n - 2] = '\0';
|
buf[n - 2] = '\0';
|
||||||
|
|
||||||
color_str = temp;
|
color_str = buf.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
return color_str;
|
return color_str;
|
||||||
|
@ -589,11 +623,14 @@ const FString FTermDetection::getXTermColorName (FColor color)
|
||||||
const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
||||||
{
|
{
|
||||||
const char* new_termtype = current_termtype;
|
const char* new_termtype = current_termtype;
|
||||||
|
keyboard->setNonBlockingInput();
|
||||||
// send ENQ and read the answerback message
|
// send ENQ and read the answerback message
|
||||||
|
const auto& ans = getAnswerbackMsg();
|
||||||
|
keyboard->unsetNonBlockingInput();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
answer_back = new FString(getAnswerbackMsg());
|
answer_back = new FString(ans);
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
|
@ -611,9 +648,10 @@ const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
||||||
new_termtype = "putty";
|
new_termtype = "putty";
|
||||||
}
|
}
|
||||||
|
|
||||||
// cygwin needs a backspace to delete the '♣' char
|
// Some terminals like cygwin or the Windows terminal
|
||||||
if ( isCygwinTerminal() || isWindowsTerminal() )
|
// have to delete the printed character '♣'
|
||||||
FTerm::putstring (BS " " BS);
|
std::fprintf (stdout, "\r " BS);
|
||||||
|
std::fflush (stdout);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if ( new_termtype )
|
if ( new_termtype )
|
||||||
|
@ -629,26 +667,41 @@ const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FTermDetection::getAnswerbackMsg()
|
FString FTermDetection::getAnswerbackMsg()
|
||||||
{
|
{
|
||||||
FString answerback{""};
|
FString answerback{""};
|
||||||
fd_set ifds{};
|
fd_set ifds{};
|
||||||
struct timeval tv{};
|
struct timeval tv{};
|
||||||
char temp[10]{};
|
|
||||||
const int stdin_no = FTermios::getStdIn();
|
const int stdin_no = FTermios::getStdIn();
|
||||||
|
// Send enquiry character
|
||||||
std::putchar (ENQ[0]); // Send enquiry character
|
std::putchar (ENQ[0]);
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
|
|
||||||
FD_ZERO(&ifds);
|
FD_ZERO(&ifds);
|
||||||
FD_SET(stdin_no, &ifds);
|
FD_SET(stdin_no, &ifds);
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 150000; // 150 ms
|
tv.tv_usec = 150000; // 150 ms
|
||||||
|
|
||||||
// Read the answerback message
|
// Read the answerback message
|
||||||
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0
|
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 )
|
||||||
&& std::fgets (temp, sizeof(temp) - 1, stdin) != nullptr )
|
return answerback;
|
||||||
answerback = temp;
|
|
||||||
|
std::array<char, 10> temp{};
|
||||||
|
std::size_t pos{0};
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
std::size_t bytes_free = temp.size() - pos - 1;
|
||||||
|
const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free);
|
||||||
|
|
||||||
|
if ( bytes <= 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
pos += std::size_t(bytes);
|
||||||
|
}
|
||||||
|
while ( pos < temp.size() );
|
||||||
|
|
||||||
|
if ( pos > 0 )
|
||||||
|
answerback = temp.data();
|
||||||
|
|
||||||
return answerback;
|
return answerback;
|
||||||
}
|
}
|
||||||
|
@ -660,10 +713,13 @@ const char* FTermDetection::parseSecDA (const char current_termtype[])
|
||||||
if ( isLinuxTerm() || isCygwinTerminal() )
|
if ( isLinuxTerm() || isCygwinTerminal() )
|
||||||
return current_termtype;
|
return current_termtype;
|
||||||
|
|
||||||
|
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
||||||
|
const auto& ans = getSecDA();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
||||||
sec_da = new FString(getSecDA());
|
sec_da = new FString(ans);
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
|
@ -746,7 +802,7 @@ int FTermDetection::str2int (const FString& s)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FTermDetection::getSecDA()
|
FString FTermDetection::getSecDA()
|
||||||
{
|
{
|
||||||
FString sec_da_str{""};
|
FString sec_da_str{""};
|
||||||
|
|
||||||
|
@ -757,11 +813,10 @@ const FString FTermDetection::getSecDA()
|
||||||
const int stdout_no{FTermios::getStdOut()};
|
const int stdout_no{FTermios::getStdOut()};
|
||||||
fd_set ifds{};
|
fd_set ifds{};
|
||||||
struct timeval tv{};
|
struct timeval tv{};
|
||||||
|
constexpr auto& SECDA{ESC "[>c"};
|
||||||
|
|
||||||
// Get the secondary device attributes
|
// Get the secondary device attributes
|
||||||
const ssize_t ret = write(stdout_no, SECDA, std::strlen(SECDA));
|
if ( write(stdout_no, SECDA, std::strlen(SECDA)) == -1 )
|
||||||
|
|
||||||
if ( ret == -1 )
|
|
||||||
return sec_da_str;
|
return sec_da_str;
|
||||||
|
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
|
@ -771,8 +826,26 @@ const FString FTermDetection::getSecDA()
|
||||||
tv.tv_usec = 600000; // 600 ms
|
tv.tv_usec = 600000; // 600 ms
|
||||||
|
|
||||||
// Read the answer
|
// Read the answer
|
||||||
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) == 1
|
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 )
|
||||||
&& std::scanf("\033[>%10d;%10d;%10dc", &a, &b, &c) == 3 )
|
return sec_da_str;
|
||||||
|
|
||||||
|
constexpr auto parse = "\033[>%10d;%10d;%10dc";
|
||||||
|
std::array<char, 40> temp{};
|
||||||
|
std::size_t pos{0};
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
std::size_t bytes_free = temp.size() - pos - 1;
|
||||||
|
const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free);
|
||||||
|
|
||||||
|
if ( bytes <= 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
pos += std::size_t(bytes);
|
||||||
|
}
|
||||||
|
while ( pos < temp.size() && ! std::strchr(temp.data(), 'c') );
|
||||||
|
|
||||||
|
if ( pos > 3 && std::sscanf(temp.data(), parse, &a, &b, &c) == 3 )
|
||||||
sec_da_str.sprintf("\033[>%d;%d;%dc", a, b, c);
|
sec_da_str.sprintf("\033[>%d;%d;%dc", a, b, c);
|
||||||
|
|
||||||
return sec_da_str;
|
return sec_da_str;
|
||||||
|
|
|
@ -171,9 +171,9 @@ void FTermFreeBSD::initCharMap()
|
||||||
if ( ! isFreeBSDConsole() )
|
if ( ! isFreeBSDConsole() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (std::size_t i{0}; i <= fc::lastCharItem; i++)
|
for (auto&& entry : fc::character)
|
||||||
if ( fc::character[i][fc::PC] < 0x1c )
|
if ( entry[fc::PC] < 0x1c )
|
||||||
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
|
entry[fc::PC] = entry[fc::ASCII];
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -195,7 +195,7 @@ void FTermFreeBSD::finish()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermFreeBSD::warnNotInitialized()
|
void FTermFreeBSD::warnNotInitialized()
|
||||||
{
|
{
|
||||||
*FApplication::getLog() << FLog::Warn
|
std::clog << FLog::Warn
|
||||||
<< "The FTermFreeBSD object has "
|
<< "The FTermFreeBSD object has "
|
||||||
<< "not yet been initialized! "
|
<< "not yet been initialized! "
|
||||||
<< "Please call the init() method first."
|
<< "Please call the init() method first."
|
||||||
|
|
|
@ -153,7 +153,7 @@ void FTermios::setCaptureSendCharacters()
|
||||||
struct termios t{};
|
struct termios t{};
|
||||||
tcgetattr (stdin_no, &t);
|
tcgetattr (stdin_no, &t);
|
||||||
t.c_lflag &= uInt(~(ICANON | ECHO));
|
t.c_lflag &= uInt(~(ICANON | ECHO));
|
||||||
t.c_cc[VTIME] = 1; // Timeout in deciseconds
|
t.c_cc[VTIME] = 10; // Timeout in deciseconds
|
||||||
t.c_cc[VMIN] = 0; // Minimum number of characters
|
t.c_cc[VMIN] = 0; // Minimum number of characters
|
||||||
tcsetattr (stdin_no, TCSANOW, &t);
|
tcsetattr (stdin_no, TCSANOW, &t);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "final/fapplication.h"
|
#include "final/fapplication.h"
|
||||||
|
@ -75,10 +76,10 @@ char* FTermLinux::getCursorStyleString()
|
||||||
{
|
{
|
||||||
// Gets the current cursor style string of the Linux console
|
// Gets the current cursor style string of the Linux console
|
||||||
|
|
||||||
static char buf[16]{};
|
static std::array<char, 16> buf{};
|
||||||
std::fill (std::begin(buf), std::end(buf), '\0');
|
std::fill (std::begin(buf), std::end(buf), '\0');
|
||||||
std::snprintf (buf, sizeof(buf), CSI "?%dc", getCursorStyle());
|
std::snprintf (buf.data(), buf.size(), CSI "?%dc", getCursorStyle());
|
||||||
return buf;
|
return buf.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -202,7 +203,7 @@ void FTermLinux::init()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FApplication::getLog()->error("Can not open the console.");
|
std::clog << FLog::Error << "Can not open the console." << std::endl;
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,14 +218,14 @@ void FTermLinux::initCharMap()
|
||||||
|
|
||||||
if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries )
|
if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries )
|
||||||
{
|
{
|
||||||
for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
|
for (auto&& entry : fc::character)
|
||||||
{
|
{
|
||||||
const auto ucs = wchar_t(fc::character[i][fc::UTF8]);
|
const auto ucs = wchar_t(entry[fc::UTF8]);
|
||||||
const sInt16 fontpos = getFontPos(ucs);
|
const sInt16 fontpos = getFontPos(ucs);
|
||||||
|
|
||||||
// Fix for a non-cp437 Linux console with PC charset encoding
|
// Fix for a non-cp437 Linux console with PC charset encoding
|
||||||
if ( fontpos > 255 || fontpos == NOT_FOUND )
|
if ( fontpos > 255 || fontpos == NOT_FOUND )
|
||||||
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
|
entry[fc::PC] = entry[fc::ASCII];
|
||||||
|
|
||||||
// Character substitutions for missing characters
|
// Character substitutions for missing characters
|
||||||
if ( fontpos == NOT_FOUND )
|
if ( fontpos == NOT_FOUND )
|
||||||
|
@ -278,7 +279,7 @@ bool FTermLinux::loadVGAFont()
|
||||||
struct unimapdesc unimap;
|
struct unimapdesc unimap;
|
||||||
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_cp437_pairs)
|
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_cp437_pairs)
|
||||||
/ sizeof(unipair) );
|
/ sizeof(unipair) );
|
||||||
unimap.entries = &fc::unicode_cp437_pairs[0];
|
unimap.entries = const_cast<unipair*>(&fc::unicode_cp437_pairs[0]);
|
||||||
setUnicodeMap(&unimap);
|
setUnicodeMap(&unimap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -315,9 +316,11 @@ bool FTermLinux::loadNewFont()
|
||||||
// Set the graphical font
|
// Set the graphical font
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
#if defined(ISA_SYSCTL_SUPPORT)
|
||||||
if ( has9BitCharacters() )
|
if ( has9BitCharacters() )
|
||||||
ret = setScreenFont(fc::__9x16graph, 256, 8, 16); // set 9×16
|
ret = setScreenFont(fc::__9x16graph, 256, 8, 16); // set 9×16
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
ret = setScreenFont(fc::__8x16graph, 256, 8, 16); // set 8×16
|
ret = setScreenFont(fc::__8x16graph, 256, 8, 16); // set 8×16
|
||||||
|
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
|
@ -327,7 +330,7 @@ bool FTermLinux::loadNewFont()
|
||||||
struct unimapdesc unimap;
|
struct unimapdesc unimap;
|
||||||
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_newfont_pairs)
|
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_newfont_pairs)
|
||||||
/ sizeof(unipair) );
|
/ sizeof(unipair) );
|
||||||
unimap.entries = &fc::unicode_newfont_pairs[0];
|
unimap.entries = const_cast<unipair*>(&fc::unicode_newfont_pairs[0]);
|
||||||
setUnicodeMap(&unimap);
|
setUnicodeMap(&unimap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -460,7 +463,7 @@ FKey FTermLinux::modifierKeyCorrection (const FKey& key_id)
|
||||||
if ( ! fsystem )
|
if ( ! fsystem )
|
||||||
fsystem = FTerm::getFSystem();
|
fsystem = FTerm::getFSystem();
|
||||||
|
|
||||||
const modifier_key& m = getModifierKey();
|
const ModifierKey& m = getModifierKey();
|
||||||
|
|
||||||
if ( ! (m.shift || m.ctrl || m.alt) )
|
if ( ! (m.shift || m.ctrl || m.alt) )
|
||||||
{
|
{
|
||||||
|
@ -631,7 +634,7 @@ bool FTermLinux::getUnicodeMap()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FTermLinux::modifier_key& FTermLinux::getModifierKey()
|
FTermLinux::ModifierKey& FTermLinux::getModifierKey()
|
||||||
{
|
{
|
||||||
// Get Linux console shift state
|
// Get Linux console shift state
|
||||||
|
|
||||||
|
@ -660,7 +663,7 @@ FTermLinux::modifier_key& FTermLinux::getModifierKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
|
int FTermLinux::setScreenFont ( const uChar fontdata[], uInt count
|
||||||
, uInt fontwidth, uInt fontheight
|
, uInt fontwidth, uInt fontheight
|
||||||
, bool direct)
|
, bool direct)
|
||||||
{
|
{
|
||||||
|
@ -681,7 +684,7 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
|
||||||
font.charcount = count;
|
font.charcount = count;
|
||||||
|
|
||||||
if ( direct )
|
if ( direct )
|
||||||
font.data = fontdata;
|
font.data = const_cast<uChar*>(fontdata);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const std::size_t bytes_per_line = font.width / 8;
|
const std::size_t bytes_per_line = font.width / 8;
|
||||||
|
@ -698,9 +701,9 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t i{0}; i < count; i++)
|
for (std::size_t i{0}; i < count; i++)
|
||||||
std::memcpy ( const_cast<uChar*>(font.data + bytes_per_line * 32 * i)
|
std::memcpy ( font.data + bytes_per_line * 32 * i
|
||||||
, &fontdata[i * font.height]
|
, &fontdata[i * font.height]
|
||||||
, font.height);
|
, font.height );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font operation
|
// Font operation
|
||||||
|
@ -932,8 +935,8 @@ void FTermLinux::getVGAPalette()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermLinux::setVGADefaultPalette()
|
void FTermLinux::setVGADefaultPalette()
|
||||||
{
|
{
|
||||||
constexpr rgb defaultColor[16] =
|
constexpr std::array<RGB, 16> defaultColor =
|
||||||
{
|
{{
|
||||||
{0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00},
|
{0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00},
|
||||||
{0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00},
|
{0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00},
|
||||||
{0x00, 0x00, 0xaa}, {0xaa, 0x00, 0xaa},
|
{0x00, 0x00, 0xaa}, {0xaa, 0x00, 0xaa},
|
||||||
|
@ -942,7 +945,7 @@ void FTermLinux::setVGADefaultPalette()
|
||||||
{0x55, 0xff, 0x55}, {0xff, 0xff, 0x55},
|
{0x55, 0xff, 0x55}, {0xff, 0xff, 0x55},
|
||||||
{0x55, 0x55, 0xff}, {0xff, 0x55, 0xff},
|
{0x55, 0x55, 0xff}, {0xff, 0x55, 0xff},
|
||||||
{0x55, 0xff, 0xff}, {0xff, 0xff, 0xff}
|
{0x55, 0xff, 0xff}, {0xff, 0xff, 0xff}
|
||||||
};
|
}};
|
||||||
|
|
||||||
for (std::size_t index{0}; index < 16; index++)
|
for (std::size_t index{0}; index < 16; index++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,7 +162,7 @@ bool FTermOpenBSD::resetBeep()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermOpenBSD::warnNotInitialized()
|
void FTermOpenBSD::warnNotInitialized()
|
||||||
{
|
{
|
||||||
*FApplication::getLog() << FLog::Warn
|
std::clog << FLog::Warn
|
||||||
<< "The FTermOpenBSD object has "
|
<< "The FTermOpenBSD object has "
|
||||||
<< "not yet been initialized! "
|
<< "not yet been initialized! "
|
||||||
<< "Please call the init() method first."
|
<< "Please call the init() method first."
|
||||||
|
|
|
@ -24,9 +24,12 @@
|
||||||
#include "final/fconfig.h" // includes _GNU_SOURCE for fd_set
|
#include "final/fconfig.h" // includes _GNU_SOURCE for fd_set
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "final/fapplication.h"
|
#include "final/fapplication.h"
|
||||||
#include "final/fc.h"
|
#include "final/fc.h"
|
||||||
#include "final/flog.h"
|
#include "final/flog.h"
|
||||||
|
#include "final/fkeyboard.h"
|
||||||
#include "final/fstring.h"
|
#include "final/fstring.h"
|
||||||
#include "final/fterm.h"
|
#include "final/fterm.h"
|
||||||
#include "final/ftermcap.h"
|
#include "final/ftermcap.h"
|
||||||
|
@ -51,6 +54,7 @@ namespace finalcut
|
||||||
// static class attributes
|
// static class attributes
|
||||||
bool FTermXTerminal::mouse_support{false};
|
bool FTermXTerminal::mouse_support{false};
|
||||||
FSystem* FTermXTerminal::fsystem{nullptr};
|
FSystem* FTermXTerminal::fsystem{nullptr};
|
||||||
|
FKeyboard* FTermXTerminal::keyboard{nullptr};
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -63,6 +67,7 @@ FTermXTerminal::FTermXTerminal()
|
||||||
{
|
{
|
||||||
// Get FSystem object
|
// Get FSystem object
|
||||||
fsystem = FTerm::getFSystem();
|
fsystem = FTerm::getFSystem();
|
||||||
|
keyboard = FTerm::getFKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -290,6 +295,13 @@ void FTermXTerminal::resetDefaults()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermXTerminal::resetTitle()
|
||||||
|
{
|
||||||
|
if ( title_was_changed )
|
||||||
|
setTitle(xterm_title);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermXTerminal::captureFontAndTitle()
|
void FTermXTerminal::captureFontAndTitle()
|
||||||
{
|
{
|
||||||
|
@ -300,8 +312,10 @@ void FTermXTerminal::captureFontAndTitle()
|
||||||
&& ! term_detection->isRxvtTerminal() )
|
&& ! term_detection->isRxvtTerminal() )
|
||||||
{
|
{
|
||||||
FTermios::setCaptureSendCharacters();
|
FTermios::setCaptureSendCharacters();
|
||||||
|
keyboard->setNonBlockingInput();
|
||||||
xterm_font = captureXTermFont();
|
xterm_font = captureXTermFont();
|
||||||
xterm_title = captureXTermTitle();
|
xterm_title = captureXTermTitle();
|
||||||
|
keyboard->unsetNonBlockingInput();
|
||||||
FTermios::unsetCaptureSendCharacters();
|
FTermios::unsetCaptureSendCharacters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,7 +325,7 @@ void FTermXTerminal::captureFontAndTitle()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermXTerminal::warnNotInitialized() const
|
void FTermXTerminal::warnNotInitialized() const
|
||||||
{
|
{
|
||||||
*FApplication::getLog() << FLog::Warn
|
std::clog << FLog::Warn
|
||||||
<< "The FTermXTerminal object has "
|
<< "The FTermXTerminal object has "
|
||||||
<< "not yet been initialized! "
|
<< "not yet been initialized! "
|
||||||
<< "Please call the init() method first."
|
<< "Please call the init() method first."
|
||||||
|
@ -356,15 +370,21 @@ void FTermXTerminal::setXTermTitle()
|
||||||
|
|
||||||
if ( term_detection->isXTerminal()
|
if ( term_detection->isXTerminal()
|
||||||
|| term_detection->isScreenTerm()
|
|| term_detection->isScreenTerm()
|
||||||
|
|| term_detection->isUrxvtTerminal()
|
||||||
|| term_detection->isCygwinTerminal()
|
|| term_detection->isCygwinTerminal()
|
||||||
|| term_detection->isMinttyTerm()
|
|| term_detection->isMinttyTerm()
|
||||||
|| term_detection->isPuttyTerminal()
|
|| term_detection->isPuttyTerminal()
|
||||||
|| 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);
|
||||||
|
title_was_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,51 +763,69 @@ void FTermXTerminal::oscPostfix() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FTermXTerminal::captureXTermFont() const
|
FString FTermXTerminal::captureXTermFont() const
|
||||||
{
|
{
|
||||||
initCheck(FString{});
|
initCheck(FString{});
|
||||||
|
|
||||||
if ( term_detection->isXTerminal()
|
if ( ! term_detection->isXTerminal()
|
||||||
|| term_detection->isScreenTerm()
|
&& ! term_detection->isScreenTerm()
|
||||||
|| FTermcap::osc_support )
|
&& ! FTermcap::osc_support )
|
||||||
{
|
{
|
||||||
|
return FString{};
|
||||||
|
}
|
||||||
|
|
||||||
fd_set ifds{};
|
fd_set ifds{};
|
||||||
struct timeval tv{};
|
struct timeval tv{};
|
||||||
const int stdin_no = FTermios::getStdIn();
|
const int stdin_no = FTermios::getStdIn();
|
||||||
|
|
||||||
|
// Querying the terminal font
|
||||||
oscPrefix();
|
oscPrefix();
|
||||||
FTerm::putstring (OSC "50;?" BEL); // get font
|
FTerm::putstring (OSC "50;?" BEL);
|
||||||
oscPostfix();
|
oscPostfix();
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
|
|
||||||
FD_ZERO(&ifds);
|
FD_ZERO(&ifds);
|
||||||
FD_SET(stdin_no, &ifds);
|
FD_SET(stdin_no, &ifds);
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 150000; // 150 ms
|
tv.tv_usec = 150000; // 150 ms
|
||||||
|
|
||||||
// Read the terminal answer
|
// Read the terminal answer
|
||||||
if ( select(stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 )
|
if ( select(stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 )
|
||||||
{
|
return FString{};
|
||||||
char temp[150]{};
|
|
||||||
|
|
||||||
if ( std::scanf("\033]50;%148[^\n]s", temp) == 1 )
|
std::array<char, 150> temp{};
|
||||||
|
std::size_t pos{0};
|
||||||
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
const std::size_t n = std::strlen(temp);
|
std::size_t bytes_free = temp.size() - pos - 1;
|
||||||
|
const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free);
|
||||||
|
|
||||||
|
if ( bytes <= 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
pos += std::size_t(bytes);
|
||||||
|
}
|
||||||
|
while ( pos < temp.size() && ! std::strchr(temp.data(), '\a') );
|
||||||
|
|
||||||
|
if ( pos > 5 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == '5'
|
||||||
|
&& temp[3] == '0' && temp[4] == ';' )
|
||||||
|
{
|
||||||
|
// Skip leading Esc ] 5 0 ;
|
||||||
|
char* str = &temp[5];
|
||||||
|
const std::size_t n = std::strlen(str);
|
||||||
|
|
||||||
// BEL + '\0' = string terminator
|
// BEL + '\0' = string terminator
|
||||||
if ( n >= 5 && temp[n - 1] == BEL[0] && temp[n] == '\0' )
|
if ( n >= 5 && str[n - 1] == BEL[0] && str[n] == '\0' )
|
||||||
temp[n - 1] = '\0';
|
str[n - 1] = '\0';
|
||||||
|
|
||||||
return FString{temp};
|
return FString{str};
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FString{};
|
return FString{};
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FTermXTerminal::captureXTermTitle() const
|
FString FTermXTerminal::captureXTermTitle() const
|
||||||
{
|
{
|
||||||
initCheck(FString{});
|
initCheck(FString{});
|
||||||
|
|
||||||
|
@ -796,34 +834,49 @@ const FString FTermXTerminal::captureXTermTitle() const
|
||||||
|
|
||||||
fd_set ifds{};
|
fd_set ifds{};
|
||||||
struct timeval tv{};
|
struct timeval tv{};
|
||||||
const int stdin_no = FTermios::getStdIn();
|
const int stdin_no{FTermios::getStdIn()};
|
||||||
|
|
||||||
FTerm::putstring (CSI "21t"); // get title
|
// Report window title
|
||||||
|
FTerm::putstring (CSI "21t");
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
|
|
||||||
FD_ZERO(&ifds);
|
FD_ZERO(&ifds);
|
||||||
FD_SET(stdin_no, &ifds);
|
FD_SET(stdin_no, &ifds);
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 150000; // 150 ms
|
tv.tv_usec = 150000; // 150 ms
|
||||||
|
|
||||||
// read the terminal answer
|
// read the terminal answer
|
||||||
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 )
|
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 )
|
||||||
{
|
return FString{};
|
||||||
char temp[512]{};
|
|
||||||
|
|
||||||
if ( std::scanf("\033]l%509[^\n]s", temp) == 1 )
|
std::array<char, 512> temp{};
|
||||||
|
std::size_t pos{0};
|
||||||
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
const std::size_t n = std::strlen(temp);
|
std::size_t bytes_free = temp.size() - pos - 1;
|
||||||
|
const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free);
|
||||||
|
|
||||||
|
if ( bytes <= 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
pos += std::size_t(bytes);
|
||||||
|
}
|
||||||
|
while ( pos < temp.size() && std::strstr(temp.data(), ESC "\\") == nullptr );
|
||||||
|
|
||||||
|
if ( pos > 6 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == 'l' )
|
||||||
|
{
|
||||||
|
// Skip leading Esc + ] + l = OSC l
|
||||||
|
char* str = &temp[3];
|
||||||
|
const std::size_t n = std::strlen(str);
|
||||||
|
|
||||||
// Esc + \ = OSC string terminator
|
// Esc + \ = OSC string terminator
|
||||||
if ( n >= 2 && temp[n - 2] == ESC[0] && temp[n - 1] == '\\' )
|
if ( n >= 2 && str[n - 2] == ESC[0] && str[n - 1] == '\\' )
|
||||||
{
|
{
|
||||||
if ( n < 4 )
|
if ( n < 4 )
|
||||||
return FString{};
|
return FString{};
|
||||||
|
|
||||||
temp[n - 2] = '\0';
|
str[n - 2] = '\0';
|
||||||
return FString{temp};
|
return FString{str};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ FTextView::~FTextView() // destructor
|
||||||
|
|
||||||
// public methods of FTextView
|
// public methods of FTextView
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString FTextView::getText() const
|
FString FTextView::getText() const
|
||||||
{
|
{
|
||||||
if ( data.empty() )
|
if ( data.empty() )
|
||||||
return FString{""};
|
return FString{""};
|
||||||
|
@ -149,7 +149,7 @@ void FTextView::scrollTo (int x, int y)
|
||||||
|
|
||||||
if ( changeX && isHorizontallyScrollable() )
|
if ( changeX && isHorizontallyScrollable() )
|
||||||
{
|
{
|
||||||
const int xoffset_end = int(max_line_width - getTextWidth());
|
const auto xoffset_end = int(max_line_width - getTextWidth());
|
||||||
xoffset = x;
|
xoffset = x;
|
||||||
|
|
||||||
if ( xoffset < 0 )
|
if ( xoffset < 0 )
|
||||||
|
@ -167,7 +167,7 @@ void FTextView::scrollTo (int x, int y)
|
||||||
|
|
||||||
if ( changeY && isVerticallyScrollable() )
|
if ( changeY && isVerticallyScrollable() )
|
||||||
{
|
{
|
||||||
const int yoffset_end = int(getRows() - getTextHeight());
|
const auto yoffset_end = int(getRows() - getTextHeight());
|
||||||
yoffset = y;
|
yoffset = y;
|
||||||
|
|
||||||
if ( yoffset < 0 )
|
if ( yoffset < 0 )
|
||||||
|
@ -335,7 +335,7 @@ void FTextView::clear()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTextView::onKeyPress (FKeyEvent* ev)
|
void FTextView::onKeyPress (FKeyEvent* ev)
|
||||||
{
|
{
|
||||||
const int idx = int(ev->key());
|
const auto idx = int(ev->key());
|
||||||
|
|
||||||
if ( key_map.find(idx) != key_map.end() )
|
if ( key_map.find(idx) != key_map.end() )
|
||||||
{
|
{
|
||||||
|
@ -504,8 +504,8 @@ void FTextView::adjustSize()
|
||||||
FWidget::adjustSize();
|
FWidget::adjustSize();
|
||||||
const std::size_t width = getWidth();
|
const std::size_t width = getWidth();
|
||||||
const std::size_t height = getHeight();
|
const std::size_t height = getHeight();
|
||||||
const int last_line = int(getRows());
|
const auto last_line = int(getRows());
|
||||||
const int max_width = int(max_line_width);
|
const auto max_width = int(max_line_width);
|
||||||
|
|
||||||
if ( xoffset >= max_width - int(width) - nf_offset )
|
if ( xoffset >= max_width - int(width) - nf_offset )
|
||||||
xoffset = max_width - int(width) - nf_offset - 1;
|
xoffset = max_width - int(width) - nf_offset - 1;
|
||||||
|
@ -535,7 +535,7 @@ void FTextView::adjustSize()
|
||||||
if ( width < 3 )
|
if ( width < 3 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int hmax = ( max_width > int(width) - nf_offset - 2 )
|
const int hmax = ( max_width >= int(width) - nf_offset - 1 )
|
||||||
? max_width - int(width) + nf_offset + 2
|
? max_width - int(width) + nf_offset + 2
|
||||||
: 0;
|
: 0;
|
||||||
hbar->setMaximum (hmax);
|
hbar->setMaximum (hmax);
|
||||||
|
|
|
@ -111,7 +111,7 @@ FVTerm& FVTerm::operator << (const FTermBuffer& term_buffer)
|
||||||
|
|
||||||
// public methods of FVTerm
|
// public methods of FVTerm
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FPoint FVTerm::getPrintCursor()
|
FPoint FVTerm::getPrintCursor()
|
||||||
{
|
{
|
||||||
const auto& win = getPrintArea();
|
const auto& win = getPrintArea();
|
||||||
|
|
||||||
|
@ -130,8 +130,8 @@ void FVTerm::setTermXY (int x, int y) const
|
||||||
if ( term_pos->getX() == x && term_pos->getY() == y )
|
if ( term_pos->getX() == x && term_pos->getY() == y )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int term_width = int(FTerm::getColumnNumber());
|
const auto term_width = int(FTerm::getColumnNumber());
|
||||||
const int term_height = int(FTerm::getLineNumber());
|
const auto term_height = int(FTerm::getLineNumber());
|
||||||
|
|
||||||
if ( x >= term_width && term_width > 0 )
|
if ( x >= term_width && term_width > 0 )
|
||||||
{
|
{
|
||||||
|
@ -434,7 +434,7 @@ int FVTerm::print (const std::vector<FChar>& term_string)
|
||||||
int FVTerm::print (FTermArea* area, const std::vector<FChar>& term_string)
|
int FVTerm::print (FTermArea* area, const std::vector<FChar>& term_string)
|
||||||
{
|
{
|
||||||
int len{0};
|
int len{0};
|
||||||
const uInt tabstop = uInt(FTerm::getTabstop());
|
const auto tabstop = uInt(FTerm::getTabstop());
|
||||||
|
|
||||||
if ( ! area )
|
if ( ! area )
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -734,10 +734,10 @@ void FVTerm::resizeArea ( const FRect& box
|
||||||
|
|
||||||
const int offset_left = box.getX();
|
const int offset_left = box.getX();
|
||||||
const int offset_top = box.getY();
|
const int offset_top = box.getY();
|
||||||
const int width = int(box.getWidth());
|
const auto width = int(box.getWidth());
|
||||||
const int height = int(box.getHeight());
|
const auto height = int(box.getHeight());
|
||||||
const int rsw = int(shadow.getWidth());
|
const auto rsw = int(shadow.getWidth());
|
||||||
const int bsh = int(shadow.getHeight());
|
const auto bsh = int(shadow.getHeight());
|
||||||
|
|
||||||
assert ( offset_top >= 0 );
|
assert ( offset_top >= 0 );
|
||||||
assert ( width > 0 && width + rsw > 0 );
|
assert ( width > 0 && width + rsw > 0 );
|
||||||
|
@ -800,8 +800,9 @@ void FVTerm::removeArea (FTermArea*& area)
|
||||||
{
|
{
|
||||||
// remove the virtual window
|
// remove the virtual window
|
||||||
|
|
||||||
if ( area != nullptr )
|
if ( area == nullptr )
|
||||||
{
|
return;
|
||||||
|
|
||||||
if ( area->changes != nullptr )
|
if ( area->changes != nullptr )
|
||||||
{
|
{
|
||||||
delete[] area->changes;
|
delete[] area->changes;
|
||||||
|
@ -816,7 +817,6 @@ void FVTerm::removeArea (FTermArea*& area)
|
||||||
|
|
||||||
delete area;
|
delete area;
|
||||||
area = nullptr;
|
area = nullptr;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -827,8 +827,8 @@ void FVTerm::restoreVTerm (const FRect& box)
|
||||||
|
|
||||||
int x = box.getX() - 1;
|
int x = box.getX() - 1;
|
||||||
int y = box.getY() - 1;
|
int y = box.getY() - 1;
|
||||||
int w = int(box.getWidth());
|
auto w = int(box.getWidth());
|
||||||
int h = int(box.getHeight());
|
auto h = int(box.getHeight());
|
||||||
|
|
||||||
if ( x < 0 )
|
if ( x < 0 )
|
||||||
x = 0;
|
x = 0;
|
||||||
|
@ -876,7 +876,7 @@ bool FVTerm::updateVTermCursor (const FTermArea* area) const
|
||||||
if ( ! area )
|
if ( ! area )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( area != active_area )
|
if ( ! isActive(area) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( ! area->visible )
|
if ( ! area->visible )
|
||||||
|
@ -970,8 +970,8 @@ void FVTerm::getArea (const FRect& box, const FTermArea* area)
|
||||||
|
|
||||||
const int x = box.getX();
|
const int x = box.getX();
|
||||||
const int y = box.getY();
|
const int y = box.getY();
|
||||||
const int w = int(box.getWidth());
|
const auto w = int(box.getWidth());
|
||||||
const int h = int(box.getHeight());
|
const auto h = int(box.getHeight());
|
||||||
const int dx = x - area->offset_left + 1;
|
const int dx = x - area->offset_left + 1;
|
||||||
const int dy = y - area->offset_top + 1;
|
const int dy = y - area->offset_top + 1;
|
||||||
int y_end{};
|
int y_end{};
|
||||||
|
@ -1040,8 +1040,8 @@ void FVTerm::putArea (const FTermArea* area) const
|
||||||
for (int y{0}; y < y_end; y++) // Line loop
|
for (int y{0}; y < y_end; y++) // Line loop
|
||||||
{
|
{
|
||||||
bool modified{false};
|
bool modified{false};
|
||||||
int line_xmin = int(area->changes[y].xmin);
|
auto line_xmin = int(area->changes[y].xmin);
|
||||||
int line_xmax = int(area->changes[y].xmax);
|
auto line_xmax = int(area->changes[y].xmax);
|
||||||
|
|
||||||
if ( line_xmin > line_xmax )
|
if ( line_xmin > line_xmax )
|
||||||
continue;
|
continue;
|
||||||
|
@ -1289,7 +1289,7 @@ void FVTerm::clearArea (FTermArea* area, int fillchar) const
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uInt w = uInt(area->width + area->right_shadow);
|
const auto w = uInt(area->width + area->right_shadow);
|
||||||
|
|
||||||
if ( area->right_shadow == 0 )
|
if ( area->right_shadow == 0 )
|
||||||
{
|
{
|
||||||
|
@ -1471,20 +1471,17 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos
|
||||||
|
|
||||||
if ( FWidget::getWindowList() && ! FWidget::getWindowList()->empty() )
|
if ( FWidget::getWindowList() && ! FWidget::getWindowList()->empty() )
|
||||||
{
|
{
|
||||||
bool found( area == vdesktop );
|
bool found{ area == vdesktop };
|
||||||
|
|
||||||
for (auto& win_obj : *FWidget::getWindowList())
|
for (auto& win_obj : *FWidget::getWindowList())
|
||||||
{
|
{
|
||||||
const auto& win = win_obj->getVWin();
|
const auto& win = win_obj->getVWin();
|
||||||
|
|
||||||
if ( ! win )
|
if ( ! (win && win->visible) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( ! win->visible )
|
const int& win_x = win->offset_left;
|
||||||
continue;
|
const int& win_y = win->offset_top;
|
||||||
|
|
||||||
const int win_x = win->offset_left;
|
|
||||||
const int win_y = win->offset_top;
|
|
||||||
const FRect geometry { win_x , win_y
|
const FRect geometry { win_x , win_y
|
||||||
, std::size_t(win->width) + std::size_t(win->right_shadow)
|
, std::size_t(win->width) + std::size_t(win->right_shadow)
|
||||||
, std::size_t(win->height) + std::size_t(win->bottom_shadow) };
|
, std::size_t(win->height) + std::size_t(win->bottom_shadow) };
|
||||||
|
@ -1492,9 +1489,9 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos
|
||||||
if ( found && geometry.contains(pos) )
|
if ( found && geometry.contains(pos) )
|
||||||
{
|
{
|
||||||
const int width = win->width + win->right_shadow;
|
const int width = win->width + win->right_shadow;
|
||||||
const int x = pos.getX();
|
const int& x = pos.getX();
|
||||||
const int y = pos.getY();
|
const int& y = pos.getY();
|
||||||
auto tmp = &win->data[(y - win_y) * width + (x - win_x)];
|
const auto& tmp = &win->data[(y - win_y) * width + (x - win_x)];
|
||||||
|
|
||||||
if ( tmp->attr.bit.color_overlay )
|
if ( tmp->attr.bit.color_overlay )
|
||||||
{
|
{
|
||||||
|
@ -1709,9 +1706,10 @@ void FVTerm::updateVTerm() const
|
||||||
vdesktop->has_changes = false;
|
vdesktop->has_changes = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FWidget* widget = static_cast<FWidget*>(vterm->widget);
|
const FWidget* widget = vterm->widget;
|
||||||
|
|
||||||
if ( ! widget->getWindowList() || widget->getWindowList()->empty() )
|
if ( ! widget || ! widget->getWindowList()
|
||||||
|
|| widget->getWindowList()->empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto&& window : *(widget->getWindowList()))
|
for (auto&& window : *(widget->getWindowList()))
|
||||||
|
@ -1797,7 +1795,7 @@ bool FVTerm::isInsideArea (const FPoint& pos, const FTermArea* area)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FChar FVTerm::generateCharacter (const FPoint& pos)
|
FChar FVTerm::generateCharacter (const FPoint& pos)
|
||||||
{
|
{
|
||||||
// Generates characters for a given position considering all areas
|
// Generates characters for a given position considering all areas
|
||||||
|
|
||||||
|
@ -1867,7 +1865,7 @@ const FChar FVTerm::generateCharacter (const FPoint& pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FChar FVTerm::getCharacter ( character_type char_type
|
FChar FVTerm::getCharacter ( character_type char_type
|
||||||
, const FPoint& pos
|
, const FPoint& pos
|
||||||
, FVTerm* obj )
|
, FVTerm* obj )
|
||||||
{
|
{
|
||||||
|
@ -1927,14 +1925,14 @@ const FChar FVTerm::getCharacter ( character_type char_type
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FChar FVTerm::getCoveredCharacter (const FPoint& pos, FVTerm* obj)
|
FChar FVTerm::getCoveredCharacter (const FPoint& pos, FVTerm* obj)
|
||||||
{
|
{
|
||||||
// Gets the covered character for a given position
|
// Gets the covered character for a given position
|
||||||
return getCharacter (covered_character, pos, obj);
|
return getCharacter (covered_character, pos, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FChar FVTerm::getOverlappedCharacter (const FPoint& pos, FVTerm* obj)
|
FChar FVTerm::getOverlappedCharacter (const FPoint& pos, FVTerm* obj)
|
||||||
{
|
{
|
||||||
// Gets the overlapped character for a given position
|
// Gets the overlapped character for a given position
|
||||||
return getCharacter (overlapped_character, pos, obj);
|
return getCharacter (overlapped_character, pos, obj);
|
||||||
|
|
142
src/fwidget.cpp
142
src/fwidget.cpp
|
@ -102,13 +102,16 @@ FWidget::~FWidget() // destructor
|
||||||
{
|
{
|
||||||
processDestroy();
|
processDestroy();
|
||||||
delCallback();
|
delCallback();
|
||||||
auto app_object = FApplication::getApplicationObject();
|
removeQueuedEvent();
|
||||||
app_object->removeQueuedEvent(this);
|
|
||||||
|
|
||||||
// unset clicked widget
|
// unset clicked widget
|
||||||
if ( this == getClickedWidget() )
|
if ( this == getClickedWidget() )
|
||||||
setClickedWidget(nullptr);
|
setClickedWidget(nullptr);
|
||||||
|
|
||||||
|
// unset keyboard widget
|
||||||
|
if ( this == FApplication::getKeyboardWidget() )
|
||||||
|
FApplication::setKeyboardWidget(nullptr);
|
||||||
|
|
||||||
// unset the local window widget focus
|
// unset the local window widget focus
|
||||||
if ( flags.focus )
|
if ( flags.focus )
|
||||||
{
|
{
|
||||||
|
@ -239,7 +242,7 @@ std::vector<bool>& FWidget::doubleFlatLine_ref (fc::sides side)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FPoint FWidget::getPrintPos()
|
FPoint FWidget::getPrintPos()
|
||||||
{
|
{
|
||||||
const auto& cur = getPrintCursor();
|
const auto& cur = getPrintCursor();
|
||||||
return { cur.getX() - woffset.getX1() - getX() + 1
|
return { cur.getX() - woffset.getX1() - getX() + 1
|
||||||
|
@ -635,7 +638,7 @@ bool FWidget::setCursorPos (const FPoint& pos)
|
||||||
|
|
||||||
widget_cursor_position.setPoint(pos);
|
widget_cursor_position.setPoint(pos);
|
||||||
|
|
||||||
if ( ! flags.focus || isWindowWidget() )
|
if ( ! flags.focus || flags.hidden || isWindowWidget() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( ! FWindow::getWindowWidget(this) )
|
if ( ! FWindow::getWindowWidget(this) )
|
||||||
|
@ -718,7 +721,7 @@ void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
|
||||||
assert ( pos >= 1 );
|
assert ( pos >= 1 );
|
||||||
|
|
||||||
uLong length{};
|
uLong length{};
|
||||||
const uLong index = uLong(pos - 1);
|
const auto index = uLong(pos - 1);
|
||||||
|
|
||||||
switch ( side )
|
switch ( side )
|
||||||
{
|
{
|
||||||
|
@ -954,6 +957,7 @@ void FWidget::show()
|
||||||
show_root_widget = this;
|
show_root_widget = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adjustSize(); // Alignment before drawing
|
||||||
draw(); // Draw the widget
|
draw(); // Draw the widget
|
||||||
flags.hidden = false;
|
flags.hidden = false;
|
||||||
flags.shown = true;
|
flags.shown = true;
|
||||||
|
@ -961,16 +965,13 @@ void FWidget::show()
|
||||||
if ( hasChildren() )
|
if ( hasChildren() )
|
||||||
{
|
{
|
||||||
for (auto&& child : getChildren())
|
for (auto&& child : getChildren())
|
||||||
{
|
|
||||||
if ( child->isWidget() )
|
|
||||||
{
|
{
|
||||||
auto widget = static_cast<FWidget*>(child);
|
auto widget = static_cast<FWidget*>(child);
|
||||||
|
|
||||||
if ( ! widget->flags.hidden )
|
if ( child->isWidget() && ! widget->flags.hidden )
|
||||||
widget->show();
|
widget->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( show_root_widget && show_root_widget == this )
|
if ( show_root_widget && show_root_widget == this )
|
||||||
{
|
{
|
||||||
|
@ -995,6 +996,11 @@ void FWidget::hide()
|
||||||
{
|
{
|
||||||
flags.shown = false;
|
flags.shown = false;
|
||||||
|
|
||||||
|
if ( flags.visible_cursor && FWidget::getFocusWidget() == this )
|
||||||
|
{
|
||||||
|
getPrintArea()->input_cursor_visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! isDialogWidget()
|
if ( ! isDialogWidget()
|
||||||
&& FWidget::getFocusWidget() == this
|
&& FWidget::getFocusWidget() == this
|
||||||
&& ! focusPrevChild() )
|
&& ! focusPrevChild() )
|
||||||
|
@ -1206,8 +1212,8 @@ void FWidget::setParentOffset()
|
||||||
void FWidget::setTermOffset()
|
void FWidget::setTermOffset()
|
||||||
{
|
{
|
||||||
const auto& r = getRootWidget();
|
const auto& r = getRootWidget();
|
||||||
const int w = int(r->getWidth());
|
const auto w = int(r->getWidth());
|
||||||
const int h = int(r->getHeight());
|
const auto h = int(r->getHeight());
|
||||||
woffset.setCoordinates (0, 0, w - 1, h - 1);
|
woffset.setCoordinates (0, 0, w - 1, h - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1306,16 +1312,13 @@ void FWidget::adjustSize()
|
||||||
if ( hasChildren() )
|
if ( hasChildren() )
|
||||||
{
|
{
|
||||||
for (auto&& child : getChildren())
|
for (auto&& child : getChildren())
|
||||||
{
|
|
||||||
if ( child->isWidget() )
|
|
||||||
{
|
{
|
||||||
auto widget = static_cast<FWidget*>(child);
|
auto widget = static_cast<FWidget*>(child);
|
||||||
|
|
||||||
if ( ! widget->isWindowWidget() )
|
if ( child->isWidget() && ! widget->isWindowWidget() )
|
||||||
widget->adjustSize();
|
widget->adjustSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1582,55 +1585,94 @@ bool FWidget::event (FEvent* ev)
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onKeyPress (FKeyEvent*)
|
void FWidget::onKeyPress (FKeyEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive key press events for the widget
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onKeyUp (FKeyEvent*)
|
void FWidget::onKeyUp (FKeyEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive key up events for the widget
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onKeyDown (FKeyEvent*)
|
void FWidget::onKeyDown (FKeyEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive key down events for the widget
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onMouseDown (FMouseEvent*)
|
void FWidget::onMouseDown (FMouseEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive mouse down events for the widget
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onMouseUp (FMouseEvent*)
|
void FWidget::onMouseUp (FMouseEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive mouse up events for the widget
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onMouseDoubleClick (FMouseEvent*)
|
void FWidget::onMouseDoubleClick (FMouseEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive mouse double clicks events for the widget
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onWheel (FWheelEvent*)
|
void FWidget::onWheel (FWheelEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive mouse wheel events for the widget
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onMouseMove (FMouseEvent*)
|
void FWidget::onMouseMove (FMouseEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive mouse move events for the widget
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onFocusIn (FFocusEvent*)
|
void FWidget::onFocusIn (FFocusEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive a widget focus event (get focus)
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onFocusOut (FFocusEvent*)
|
void FWidget::onFocusOut (FFocusEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive a widget focus event (lost focus)
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onChildFocusIn (FFocusEvent*)
|
void FWidget::onChildFocusIn (FFocusEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive a child widget focus event (get focus)
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onChildFocusOut (FFocusEvent*)
|
void FWidget::onChildFocusOut (FFocusEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive a child widget focus event (lost focus)
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onAccel (FAccelEvent*)
|
void FWidget::onAccel (FAccelEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass to receive
|
||||||
|
// an event when an acceleration key is pressed for this widget
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onResize (FResizeEvent* ev)
|
void FWidget::onResize (FResizeEvent* ev)
|
||||||
|
@ -1643,15 +1685,23 @@ void FWidget::onResize (FResizeEvent* ev)
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onShow (FShowEvent*)
|
void FWidget::onShow (FShowEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive a widget show event
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onHide (FHideEvent*)
|
void FWidget::onHide (FHideEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive a widget hide event
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::onClose (FCloseEvent* ev)
|
void FWidget::onClose (FCloseEvent* ev)
|
||||||
{
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive a widget close event
|
||||||
ev->accept();
|
ev->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1742,21 +1792,23 @@ inline void FWidget::insufficientSpaceAdjust()
|
||||||
// move left if not enough space
|
// move left if not enough space
|
||||||
while ( getTermX() + int(getWidth()) - padding.right > woffset.getX2() + 2 )
|
while ( getTermX() + int(getWidth()) - padding.right > woffset.getX2() + 2 )
|
||||||
{
|
{
|
||||||
adjust_wsize.x1_ref()--;
|
if ( adjust_wsize.x1_ref() < 2 )
|
||||||
adjust_wsize.x2_ref()--;
|
|
||||||
|
|
||||||
if ( adjust_wsize.x1_ref() < 1 )
|
|
||||||
adjust_wsize.x1_ref() = 1;
|
adjust_wsize.x1_ref() = 1;
|
||||||
|
else
|
||||||
|
adjust_wsize.x1_ref()--;
|
||||||
|
|
||||||
|
adjust_wsize.x2_ref()--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// move up if not enough space
|
// move up if not enough space
|
||||||
while ( getTermY() + int(getHeight()) - padding.bottom > woffset.getY2() + 2 )
|
while ( getTermY() + int(getHeight()) - padding.bottom > woffset.getY2() + 2 )
|
||||||
{
|
{
|
||||||
adjust_wsize.y1_ref()--;
|
if ( adjust_wsize.y1_ref() < 2 )
|
||||||
adjust_wsize.y2_ref()--;
|
|
||||||
|
|
||||||
if ( adjust_wsize.y1_ref() < 1 )
|
|
||||||
adjust_wsize.y1_ref() = 1;
|
adjust_wsize.y1_ref() = 1;
|
||||||
|
else
|
||||||
|
adjust_wsize.y1_ref()--;
|
||||||
|
|
||||||
|
adjust_wsize.y2_ref()--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reduce the width if not enough space
|
// reduce the width if not enough space
|
||||||
|
@ -1911,7 +1963,10 @@ bool FWidget::changeFocus ( FWidget* follower, FWidget* parent
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::draw()
|
void FWidget::draw()
|
||||||
{ }
|
{
|
||||||
|
// This method must be reimplemented in a subclass
|
||||||
|
// for drawing the widget
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::drawWindows() const
|
void FWidget::drawWindows() const
|
||||||
|
@ -2011,6 +2066,15 @@ void FWidget::destroyColorTheme()
|
||||||
delete theme;
|
delete theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FWidget::removeQueuedEvent() const
|
||||||
|
{
|
||||||
|
auto app_object = FApplication::getApplicationObject();
|
||||||
|
|
||||||
|
if ( app_object )
|
||||||
|
app_object->removeQueuedEvent(this);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::setStatusbarText (bool enable) const
|
void FWidget::setStatusbarText (bool enable) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,7 +97,7 @@ std::size_t getHotkeyPos (const FString& src, FString& dest)
|
||||||
// Find hotkey position in string
|
// Find hotkey position in string
|
||||||
// + generate a new string without the '&'-sign
|
// + generate a new string without the '&'-sign
|
||||||
|
|
||||||
constexpr std::size_t NOT_SET = static_cast<std::size_t>(-1);
|
constexpr auto NOT_SET = static_cast<std::size_t>(-1);
|
||||||
std::size_t hotkeypos{NOT_SET};
|
std::size_t hotkeypos{NOT_SET};
|
||||||
std::size_t i{0};
|
std::size_t i{0};
|
||||||
|
|
||||||
|
|
|
@ -278,8 +278,17 @@ void FWindow::show()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWindow::hide()
|
void FWindow::hide()
|
||||||
{
|
{
|
||||||
|
const auto& virtual_win = getVWin();
|
||||||
|
|
||||||
|
if ( isActive(virtual_win)
|
||||||
|
&& virtual_win->visible
|
||||||
|
&& virtual_win->input_cursor_visible )
|
||||||
|
{
|
||||||
|
hideVTermCursor();
|
||||||
|
}
|
||||||
|
|
||||||
if ( isVirtualWindow() )
|
if ( isVirtualWindow() )
|
||||||
getVWin()->visible = false;
|
virtual_win->visible = false;
|
||||||
|
|
||||||
FWidget::hide();
|
FWidget::hide();
|
||||||
const auto& t_geometry = getTermGeometryWithShadow();
|
const auto& t_geometry = getTermGeometryWithShadow();
|
||||||
|
@ -428,12 +437,11 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
--iter;
|
--iter;
|
||||||
if ( *iter )
|
|
||||||
{
|
|
||||||
auto w = static_cast<FWindow*>(*iter);
|
auto w = static_cast<FWindow*>(*iter);
|
||||||
|
|
||||||
if ( ! w->isWindowHidden()
|
if ( *iter && ! w->isWindowHidden()
|
||||||
&& w->getTermGeometry().contains(x, y) )
|
&& w->getTermGeometry().contains(x, y) )
|
||||||
|
{
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -681,7 +689,6 @@ void FWindow::switchToPrevWindow (const FWidget* widget)
|
||||||
const bool is_activated = activatePrevWindow();
|
const bool is_activated = activatePrevWindow();
|
||||||
auto active_win = static_cast<FWindow*>(getActiveWindow());
|
auto active_win = static_cast<FWindow*>(getActiveWindow());
|
||||||
|
|
||||||
|
|
||||||
if ( ! is_activated
|
if ( ! is_activated
|
||||||
&& getWindowList() && getWindowList()->size() > 1 )
|
&& getWindowList() && getWindowList()->size() > 1 )
|
||||||
{
|
{
|
||||||
|
@ -815,19 +822,31 @@ bool FWindow::event (FEvent* ev)
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWindow::onWindowActive (FEvent*)
|
void FWindow::onWindowActive (FEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive activation events for this window
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWindow::onWindowInactive (FEvent*)
|
void FWindow::onWindowInactive (FEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive deactivation events for this window
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWindow::onWindowRaised (FEvent*)
|
void FWindow::onWindowRaised (FEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive window raising events for this window
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWindow::onWindowLowered (FEvent*)
|
void FWindow::onWindowLowered (FEvent*)
|
||||||
{ }
|
{
|
||||||
|
// This event handler can be reimplemented in a subclass
|
||||||
|
// to receive window lowering events for this window
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// private methods of FWindow
|
// private methods of FWindow
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
#error "Only <final/final.h> can be included directly."
|
#error "Only <final/final.h> can be included directly."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "final/fapplication.h"
|
#include <iostream>
|
||||||
|
|
||||||
#include "final/flog.h"
|
#include "final/flog.h"
|
||||||
#include "final/fstring.h"
|
#include "final/fstring.h"
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ public:
|
||||||
// Disable copy assignment operator (=)
|
// Disable copy assignment operator (=)
|
||||||
emptyFString& operator = (const emptyFString&) = delete;
|
emptyFString& operator = (const emptyFString&) = delete;
|
||||||
|
|
||||||
static const FString getClassName();
|
static FString getClassName();
|
||||||
static bool isNull();
|
static bool isNull();
|
||||||
static const FString& get();
|
static const FString& get();
|
||||||
static void clear();
|
static void clear();
|
||||||
|
@ -73,7 +74,7 @@ private:
|
||||||
|
|
||||||
// emptyFString inline functions
|
// emptyFString inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString emptyFString::getClassName()
|
inline FString emptyFString::getClassName()
|
||||||
{ return "emptyFString"; }
|
{ return "emptyFString"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -64,6 +64,8 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "final/ftypes.h"
|
#include "final/ftypes.h"
|
||||||
#include "final/fwidget.h"
|
#include "final/fwidget.h"
|
||||||
|
@ -110,10 +112,11 @@ class FApplication : public FWidget
|
||||||
FApplication& operator = (const FApplication&) = delete;
|
FApplication& operator = (const FApplication&) = delete;
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
const FString getClassName() const override;
|
FString getClassName() const override;
|
||||||
int getArgc() const;
|
int getArgc() const;
|
||||||
char** getArgv() const;
|
char** getArgv() const;
|
||||||
static FApplication* getApplicationObject();
|
static FApplication* getApplicationObject();
|
||||||
|
static FWidget* getKeyboardWidget();
|
||||||
static FLogPtr& getLog();
|
static FLogPtr& getLog();
|
||||||
|
|
||||||
// Mutator
|
// Mutator
|
||||||
|
@ -136,6 +139,8 @@ class FApplication : public FWidget
|
||||||
void initTerminal() override;
|
void initTerminal() override;
|
||||||
static void setDefaultTheme();
|
static void setDefaultTheme();
|
||||||
static void setDarkTheme();
|
static void setDarkTheme();
|
||||||
|
static void setLogFile (const FString&);
|
||||||
|
static void setKeyboardWidget (FWidget*);
|
||||||
static void closeConfirmationDialog (FWidget*, FCloseEvent*);
|
static void closeConfirmationDialog (FWidget*, FCloseEvent*);
|
||||||
|
|
||||||
// Callback method
|
// Callback method
|
||||||
|
@ -148,12 +153,13 @@ class FApplication : public FWidget
|
||||||
// Typedefs
|
// Typedefs
|
||||||
typedef std::pair<FObject*, FEvent*> EventPair;
|
typedef std::pair<FObject*, FEvent*> EventPair;
|
||||||
typedef std::deque<EventPair> FEventQueue;
|
typedef std::deque<EventPair> FEventQueue;
|
||||||
|
typedef std::unordered_map<int, std::function<void(char*)>> CmdMap;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void init();
|
void init();
|
||||||
static void setTerminalEncoding (const FString&);
|
static void setTerminalEncoding (const FString&);
|
||||||
static void setLogFile (const FString&);
|
static CmdMap& mapCmdOptions();
|
||||||
static void cmd_options (const int&, char*[]);
|
static void cmdOptions (const int&, char*[]);
|
||||||
static FStartOptions& getStartOptions();
|
static FStartOptions& getStartOptions();
|
||||||
static void showParameterUsage();
|
static void showParameterUsage();
|
||||||
void destroyLog();
|
void destroyLog();
|
||||||
|
@ -205,6 +211,7 @@ class FApplication : public FWidget
|
||||||
char** app_argv{};
|
char** app_argv{};
|
||||||
uInt64 key_timeout{100000}; // 100 ms
|
uInt64 key_timeout{100000}; // 100 ms
|
||||||
uInt64 dblclick_interval{500000}; // 500 ms
|
uInt64 dblclick_interval{500000}; // 500 ms
|
||||||
|
std::streambuf* default_clog_rdbuf{std::clog.rdbuf()};
|
||||||
FEventQueue event_queue{};
|
FEventQueue event_queue{};
|
||||||
static uInt64 next_event_wait;
|
static uInt64 next_event_wait;
|
||||||
static timeval time_last_event;
|
static timeval time_last_event;
|
||||||
|
@ -215,6 +222,20 @@ class FApplication : public FWidget
|
||||||
static FMouseControl* mouse;
|
static FMouseControl* mouse;
|
||||||
static FKeyboard* keyboard;
|
static FKeyboard* keyboard;
|
||||||
static FWidget* keyboard_widget;
|
static FWidget* keyboard_widget;
|
||||||
|
|
||||||
|
#if defined(__sun) && defined(__SVR4)
|
||||||
|
struct CmdOption
|
||||||
|
{
|
||||||
|
const char* name; // <- name is without 'const' in Solaris
|
||||||
|
int has_arg;
|
||||||
|
int* flag;
|
||||||
|
int val;
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
using CmdOption = struct option;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const std::vector<CmdOption> long_options;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -226,7 +247,7 @@ FApplication* getFApplication();
|
||||||
|
|
||||||
// FApplication inline functions
|
// FApplication inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString FApplication::getClassName() const
|
inline FString FApplication::getClassName() const
|
||||||
{ return "FApplication"; }
|
{ return "FApplication"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -76,13 +76,13 @@ class FBusyIndicator : public FToolTip
|
||||||
FBusyIndicator (const FBusyIndicator&) = delete;
|
FBusyIndicator (const FBusyIndicator&) = delete;
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~FBusyIndicator();
|
~FBusyIndicator() override;
|
||||||
|
|
||||||
// Disable copy assignment operator (=)
|
// Disable copy assignment operator (=)
|
||||||
FBusyIndicator& operator = (const FBusyIndicator&) = delete;
|
FBusyIndicator& operator = (const FBusyIndicator&) = delete;
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
const FString getClassName() const override;
|
FString getClassName() const override;
|
||||||
|
|
||||||
// Inquiries
|
// Inquiries
|
||||||
bool isRunning() const;
|
bool isRunning() const;
|
||||||
|
@ -113,7 +113,7 @@ class FBusyIndicator : public FToolTip
|
||||||
|
|
||||||
// FBusyIndicator inline functions
|
// FBusyIndicator inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString FBusyIndicator::getClassName() const
|
inline FString FBusyIndicator::getClassName() const
|
||||||
{ return "FBusyIndicator"; }
|
{ return "FBusyIndicator"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -77,7 +77,7 @@ class FButton : public FWidget
|
||||||
FButton& operator = (const FString&);
|
FButton& operator = (const FString&);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
const FString getClassName() const override;
|
FString getClassName() const override;
|
||||||
FString getText() const;
|
FString getText() const;
|
||||||
|
|
||||||
// Mutators
|
// Mutators
|
||||||
|
@ -134,7 +134,7 @@ class FButton : public FWidget
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Constants
|
// Constants
|
||||||
static constexpr std::size_t NOT_SET = static_cast<std::size_t>(-1);
|
static constexpr auto NOT_SET = static_cast<std::size_t>(-1);
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void init();
|
void init();
|
||||||
|
@ -174,7 +174,7 @@ class FButton : public FWidget
|
||||||
|
|
||||||
// FButton inline functions
|
// FButton inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString FButton::getClassName() const
|
inline FString FButton::getClassName() const
|
||||||
{ return "FButton"; }
|
{ return "FButton"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -78,7 +78,7 @@ class FButtonGroup : public FScrollView
|
||||||
FButtonGroup& operator = (const FButtonGroup&) = delete;
|
FButtonGroup& operator = (const FButtonGroup&) = delete;
|
||||||
|
|
||||||
// Accessor
|
// Accessor
|
||||||
const FString getClassName() const override;
|
FString getClassName() const override;
|
||||||
FToggleButton* getFirstButton();
|
FToggleButton* getFirstButton();
|
||||||
FToggleButton* getLastButton();
|
FToggleButton* getLastButton();
|
||||||
FToggleButton* getButton (int) const;
|
FToggleButton* getButton (int) const;
|
||||||
|
@ -119,7 +119,7 @@ class FButtonGroup : public FScrollView
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Constants
|
// Constants
|
||||||
static constexpr std::size_t NOT_SET = static_cast<std::size_t>(-1);
|
static constexpr auto NOT_SET = static_cast<std::size_t>(-1);
|
||||||
|
|
||||||
// Inquiries
|
// Inquiries
|
||||||
bool isRadioButton (const FToggleButton*) const;
|
bool isRadioButton (const FToggleButton*) const;
|
||||||
|
@ -127,7 +127,11 @@ class FButtonGroup : public FScrollView
|
||||||
// Methods
|
// Methods
|
||||||
void init();
|
void init();
|
||||||
void drawText (const FString&, std::size_t);
|
void drawText (const FString&, std::size_t);
|
||||||
|
bool directFocusCheckedRadioButton (FToggleButton*) const;
|
||||||
|
bool directFocusRadioButton() const;
|
||||||
void directFocus();
|
void directFocus();
|
||||||
|
void focusCheckedRadioButton (FToggleButton*, FFocusEvent*);
|
||||||
|
void focusInRadioButton (FFocusEvent*);
|
||||||
|
|
||||||
// Callback method
|
// Callback method
|
||||||
void cb_buttonToggled (const FToggleButton*) const;
|
void cb_buttonToggled (const FToggleButton*) const;
|
||||||
|
@ -139,7 +143,7 @@ class FButtonGroup : public FScrollView
|
||||||
|
|
||||||
// FButtonGroup inline functions
|
// FButtonGroup inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString FButtonGroup::getClassName() const
|
inline FString FButtonGroup::getClassName() const
|
||||||
{ return "FButtonGroup"; }
|
{ return "FButtonGroup"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#define SO "\016" // Shift out (alternative character set)
|
#define SO "\016" // Shift out (alternative character set)
|
||||||
#define SI "\017" // Shift in (regular character set)
|
#define SI "\017" // Shift in (regular character set)
|
||||||
#define OSC ESC "]" // Operating system command (7-bit)
|
#define OSC ESC "]" // Operating system command (7-bit)
|
||||||
#define SECDA ESC "[>c" // Secondary Device Attributes
|
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,7 +58,7 @@ struct FCallbackData
|
||||||
FCallbackData()
|
FCallbackData()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template<typename FuncPtr>
|
template <typename FuncPtr>
|
||||||
FCallbackData (const FString& s, FWidget* i, FuncPtr m, const FCall& c)
|
FCallbackData (const FString& s, FWidget* i, FuncPtr m, const FCall& c)
|
||||||
: cb_signal(s)
|
: cb_signal(s)
|
||||||
, cb_instance(i)
|
, cb_instance(i)
|
||||||
|
@ -88,7 +88,7 @@ class FCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Using-declaration
|
// Using-declaration
|
||||||
template<typename T>
|
template <typename T>
|
||||||
using ObjectPointer =
|
using ObjectPointer =
|
||||||
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
||||||
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
||||||
|
@ -97,7 +97,7 @@ class FCallback
|
||||||
&& std::is_object<T>::value
|
&& std::is_object<T>::value
|
||||||
&& ! std::is_class<T>::value
|
&& ! std::is_class<T>::value
|
||||||
, std::nullptr_t >;
|
, std::nullptr_t >;
|
||||||
template<typename T>
|
template <typename T>
|
||||||
using ClassObject =
|
using ClassObject =
|
||||||
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
||||||
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
||||||
|
@ -106,7 +106,7 @@ class FCallback
|
||||||
&& std::is_object<T>::value
|
&& std::is_object<T>::value
|
||||||
&& std::is_class<T>::value
|
&& std::is_class<T>::value
|
||||||
, std::nullptr_t >;
|
, std::nullptr_t >;
|
||||||
template<typename T>
|
template <typename T>
|
||||||
using MemberFunctionPointer =
|
using MemberFunctionPointer =
|
||||||
typename std::enable_if< std::is_member_function_pointer<T>::value
|
typename std::enable_if< std::is_member_function_pointer<T>::value
|
||||||
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
||||||
|
@ -115,7 +115,7 @@ class FCallback
|
||||||
&& std::is_object<T>::value
|
&& std::is_object<T>::value
|
||||||
&& ! std::is_class<T>::value
|
&& ! std::is_class<T>::value
|
||||||
, std::nullptr_t >;
|
, std::nullptr_t >;
|
||||||
template<typename T>
|
template <typename T>
|
||||||
using FunctionPointer =
|
using FunctionPointer =
|
||||||
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
||||||
&& std::is_function<typename std::remove_pointer<T>::type>::value
|
&& std::is_function<typename std::remove_pointer<T>::type>::value
|
||||||
|
@ -124,7 +124,7 @@ class FCallback
|
||||||
&& std::is_object<T>::value
|
&& std::is_object<T>::value
|
||||||
&& ! std::is_class<T>::value
|
&& ! std::is_class<T>::value
|
||||||
, std::nullptr_t >;
|
, std::nullptr_t >;
|
||||||
template<typename T>
|
template <typename T>
|
||||||
using FunctionReference =
|
using FunctionReference =
|
||||||
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
||||||
&& std::is_function<typename std::remove_pointer<T>::type>::value
|
&& std::is_function<typename std::remove_pointer<T>::type>::value
|
||||||
|
@ -147,11 +147,11 @@ class FCallback
|
||||||
FCallback& operator = (const FCallback&) = delete;
|
FCallback& operator = (const FCallback&) = delete;
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
const FString getClassName() const;
|
FString getClassName() const;
|
||||||
std::size_t getCallbackCount() const;
|
std::size_t getCallbackCount() const;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename ObjectPointer<Object>::type = nullptr
|
, typename ObjectPointer<Object>::type = nullptr
|
||||||
, typename MemberFunctionPointer<Function>::type = nullptr
|
, typename MemberFunctionPointer<Function>::type = nullptr
|
||||||
|
@ -160,7 +160,7 @@ class FCallback
|
||||||
, Object&& cb_instance
|
, Object&& cb_instance
|
||||||
, Function&& cb_member
|
, Function&& cb_member
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename ObjectPointer<Object>::type = nullptr
|
, typename ObjectPointer<Object>::type = nullptr
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
|
@ -169,42 +169,42 @@ class FCallback
|
||||||
, Object&& cb_instance
|
, Object&& cb_instance
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Function
|
template < typename Function
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
void addCallback ( const FString& cb_signal
|
void addCallback ( const FString& cb_signal
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
void addCallback ( const FString& cb_signal
|
void addCallback ( const FString& cb_signal
|
||||||
, Function& cb_function
|
, Function& cb_function
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FunctionReference<Function>::type = nullptr
|
, typename FunctionReference<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
void addCallback ( const FString& cb_signal
|
void addCallback ( const FString& cb_signal
|
||||||
, Function& cb_function
|
, Function& cb_function
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FunctionPointer<Function>::type = nullptr
|
, typename FunctionPointer<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
void addCallback ( const FString& cb_signal
|
void addCallback ( const FString& cb_signal
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename ObjectPointer<Object>::type = nullptr>
|
, typename ObjectPointer<Object>::type = nullptr>
|
||||||
void delCallback (Object&& cb_instance) noexcept;
|
void delCallback (Object&& cb_instance) noexcept;
|
||||||
void delCallback (const FString& cb_signal);
|
void delCallback (const FString& cb_signal);
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename ObjectPointer<Object>::type = nullptr>
|
, typename ObjectPointer<Object>::type = nullptr>
|
||||||
void delCallback ( const FString& cb_signal
|
void delCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance ) noexcept;
|
, Object&& cb_instance ) noexcept;
|
||||||
template<typename FunctionPtr
|
template <typename FunctionPtr
|
||||||
, typename FunctionPointer<FunctionPtr>::type = nullptr>
|
, typename FunctionPointer<FunctionPtr>::type = nullptr>
|
||||||
void delCallback (FunctionPtr&& cb_func_ptr) noexcept;
|
void delCallback (FunctionPtr&& cb_func_ptr) noexcept;
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FunctionReference<Function>::type = nullptr>
|
, typename FunctionReference<Function>::type = nullptr>
|
||||||
void delCallback (const Function& cb_function);
|
void delCallback (const Function& cb_function);
|
||||||
void delCallback();
|
void delCallback();
|
||||||
|
@ -220,7 +220,7 @@ class FCallback
|
||||||
|
|
||||||
// FCallback inline functions
|
// FCallback inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString FCallback::getClassName() const
|
inline FString FCallback::getClassName() const
|
||||||
{ return "FCallback"; }
|
{ return "FCallback"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -228,7 +228,7 @@ inline std::size_t FCallback::getCallbackCount() const
|
||||||
{ return callback_objects.size(); }
|
{ return callback_objects.size(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename FCallback::ObjectPointer<Object>::type
|
, typename FCallback::ObjectPointer<Object>::type
|
||||||
, typename FCallback::MemberFunctionPointer<Function>::type
|
, typename FCallback::MemberFunctionPointer<Function>::type
|
||||||
|
@ -249,7 +249,7 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename FCallback::ObjectPointer<Object>::type
|
, typename FCallback::ObjectPointer<Object>::type
|
||||||
, typename FCallback::ClassObject<Function>::type
|
, typename FCallback::ClassObject<Function>::type
|
||||||
|
@ -267,7 +267,7 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FCallback::ClassObject<Function>::type
|
, typename FCallback::ClassObject<Function>::type
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
inline void FCallback::addCallback ( const FString& cb_signal
|
inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
|
@ -283,7 +283,7 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FCallback::ClassObject<Function>::type
|
, typename FCallback::ClassObject<Function>::type
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
inline void FCallback::addCallback ( const FString& cb_signal
|
inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
|
@ -298,7 +298,7 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FCallback::FunctionReference<Function>::type
|
, typename FCallback::FunctionReference<Function>::type
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
inline void FCallback::addCallback ( const FString& cb_signal
|
inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
|
@ -314,7 +314,7 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FCallback::FunctionPointer<Function>::type
|
, typename FCallback::FunctionPointer<Function>::type
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
inline void FCallback::addCallback ( const FString& cb_signal
|
inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
|
@ -331,7 +331,7 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename FCallback::ObjectPointer<Object>::type>
|
, typename FCallback::ObjectPointer<Object>::type>
|
||||||
inline void FCallback::delCallback (Object&& cb_instance) noexcept
|
inline void FCallback::delCallback (Object&& cb_instance) noexcept
|
||||||
{
|
{
|
||||||
|
@ -352,7 +352,7 @@ inline void FCallback::delCallback (Object&& cb_instance) noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename FCallback::ObjectPointer<Object>::type>
|
, typename FCallback::ObjectPointer<Object>::type>
|
||||||
inline void FCallback::delCallback ( const FString& cb_signal
|
inline void FCallback::delCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance ) noexcept
|
, Object&& cb_instance ) noexcept
|
||||||
|
@ -376,7 +376,7 @@ inline void FCallback::delCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename FunctionPtr
|
template <typename FunctionPtr
|
||||||
, typename FCallback::FunctionPointer<FunctionPtr>::type>
|
, typename FCallback::FunctionPointer<FunctionPtr>::type>
|
||||||
inline void FCallback::delCallback (FunctionPtr&& cb_func_ptr) noexcept
|
inline void FCallback::delCallback (FunctionPtr&& cb_func_ptr) noexcept
|
||||||
{
|
{
|
||||||
|
@ -399,7 +399,7 @@ inline void FCallback::delCallback (FunctionPtr&& cb_func_ptr) noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FCallback::FunctionReference<Function>::type>
|
, typename FCallback::FunctionReference<Function>::type>
|
||||||
inline void FCallback::delCallback (const Function& cb_function)
|
inline void FCallback::delCallback (const Function& cb_function)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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-2019 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 *
|
||||||
|
@ -27,6 +27,8 @@
|
||||||
#error "Only <final/final.h> can be included directly."
|
#error "Only <final/final.h> can be included directly."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "final/fc.h"
|
#include "final/fc.h"
|
||||||
#include "final/ftypes.h"
|
#include "final/ftypes.h"
|
||||||
|
|
||||||
|
@ -36,17 +38,10 @@ namespace finalcut
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
extern uInt character[][fc::NUM_OF_ENCODINGS];
|
extern std::array<std::array<uInt, fc::NUM_OF_ENCODINGS>, 115> character;
|
||||||
extern const std::size_t lastCharItem;
|
extern const std::array<std::array<int, 2>, 39> vt100_key_to_utf8;
|
||||||
|
extern const std::array<std::array<wchar_t, 2>, 256> cp437_ucs;
|
||||||
extern int vt100_key_to_utf8[][2];
|
extern const std::array<std::array<wchar_t, 2>, 227> halfwidth_fullwidth;
|
||||||
extern const std::size_t lastKeyItem;
|
|
||||||
|
|
||||||
extern wchar_t cp437_ucs[][2];
|
|
||||||
extern const std::size_t lastCP437Item;
|
|
||||||
|
|
||||||
extern const wchar_t halfWidth_fullWidth[][2];
|
|
||||||
extern const std::size_t lastHalfWidthItem;
|
|
||||||
|
|
||||||
} // namespace fc
|
} // namespace fc
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ class FCheckBox : public FToggleButton
|
||||||
FCheckBox& operator = (const FCheckBox&) = delete;
|
FCheckBox& operator = (const FCheckBox&) = delete;
|
||||||
|
|
||||||
// Accessor
|
// Accessor
|
||||||
const FString getClassName() const override;
|
FString getClassName() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Methods
|
// Methods
|
||||||
|
@ -91,7 +91,7 @@ class FCheckBox : public FToggleButton
|
||||||
|
|
||||||
// FCheckBox inline functions
|
// FCheckBox inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString FCheckBox::getClassName() const
|
inline FString FCheckBox::getClassName() const
|
||||||
{ return "FCheckBox"; }
|
{ return "FCheckBox"; }
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
* ▲
|
* ▲
|
||||||
* │
|
* │
|
||||||
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏* 1▕▔▔▔▔▔▔▔▏
|
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏* 1▕▔▔▔▔▔▔▔▏
|
||||||
* ▕ FCheckMenuItem ▏- - - - -▕ FMenu ▏
|
* ▕ FCheckMenuItem ▏- - - -▕ FMenu ▏
|
||||||
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▏
|
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▏
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class FCheckMenuItem : public FMenuItem
|
||||||
FCheckMenuItem& operator = (const FCheckMenuItem&) = delete;
|
FCheckMenuItem& operator = (const FCheckMenuItem&) = delete;
|
||||||
|
|
||||||
// Accessor
|
// Accessor
|
||||||
const FString getClassName() const override;
|
FString getClassName() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Methods
|
// Methods
|
||||||
|
@ -89,7 +89,7 @@ class FCheckMenuItem : public FMenuItem
|
||||||
|
|
||||||
// FCheckMenuItem inline functions
|
// FCheckMenuItem inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString FCheckMenuItem::getClassName() const
|
inline FString FCheckMenuItem::getClassName() const
|
||||||
{ return "FCheckMenuItem"; }
|
{ return "FCheckMenuItem"; }
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
|
@ -65,7 +65,7 @@ class FColorPair
|
||||||
FColorPair& operator = (const FColorPair& pair) = default;
|
FColorPair& operator = (const FColorPair& pair) = default;
|
||||||
|
|
||||||
// Accessor
|
// Accessor
|
||||||
const FString getClassName() const
|
FString getClassName() const
|
||||||
{ return "FColorPair"; }
|
{ return "FColorPair"; }
|
||||||
|
|
||||||
FColor getForegroundColor() const
|
FColor getForegroundColor() const
|
||||||
|
|
|
@ -59,7 +59,7 @@ class FColorPalette
|
||||||
virtual ~FColorPalette();
|
virtual ~FColorPalette();
|
||||||
|
|
||||||
// Accessor
|
// Accessor
|
||||||
virtual const FString getClassName() const;
|
virtual FString getClassName() const;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual void setColorPalette() = 0;
|
virtual void setColorPalette() = 0;
|
||||||
|
@ -76,7 +76,7 @@ class FColorPalette
|
||||||
|
|
||||||
// FColorPalette inline functions
|
// FColorPalette inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString FColorPalette::getClassName() const
|
inline FString FColorPalette::getClassName() const
|
||||||
{ return "FColorPalette"; }
|
{ return "FColorPalette"; }
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,10 +104,10 @@ class default8ColorPalette final : public FColorPalette
|
||||||
explicit default8ColorPalette (const FSetPalette&);
|
explicit default8ColorPalette (const FSetPalette&);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~default8ColorPalette();
|
~default8ColorPalette() override;
|
||||||
|
|
||||||
// Accessor
|
// Accessor
|
||||||
const FString getClassName() const override;
|
FString getClassName() const override;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void setColorPalette() override;
|
void setColorPalette() override;
|
||||||
|
@ -116,7 +116,7 @@ class default8ColorPalette final : public FColorPalette
|
||||||
|
|
||||||
// default8ColorPalette inline functions
|
// default8ColorPalette inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString default8ColorPalette::getClassName() const
|
inline FString default8ColorPalette::getClassName() const
|
||||||
{ return "default8ColorPalette"; }
|
{ return "default8ColorPalette"; }
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,10 +144,10 @@ class default16ColorPalette final : public FColorPalette
|
||||||
explicit default16ColorPalette (const FSetPalette&);
|
explicit default16ColorPalette (const FSetPalette&);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~default16ColorPalette();
|
~default16ColorPalette() override;
|
||||||
|
|
||||||
// Accessor
|
// Accessor
|
||||||
const FString getClassName() const override;
|
FString getClassName() const override;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void setColorPalette() override;
|
void setColorPalette() override;
|
||||||
|
@ -156,7 +156,7 @@ class default16ColorPalette final : public FColorPalette
|
||||||
|
|
||||||
// default16ColorPalette inline functions
|
// default16ColorPalette inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString default16ColorPalette::getClassName() const
|
inline FString default16ColorPalette::getClassName() const
|
||||||
{ return "default16ColorPalette"; }
|
{ return "default16ColorPalette"; }
|
||||||
|
|
||||||
/* Inheritance diagram
|
/* Inheritance diagram
|
||||||
|
@ -183,10 +183,10 @@ class default16DarkColorPalette final : public FColorPalette
|
||||||
explicit default16DarkColorPalette (const FSetPalette&);
|
explicit default16DarkColorPalette (const FSetPalette&);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~default16DarkColorPalette();
|
~default16DarkColorPalette() override;
|
||||||
|
|
||||||
// Accessor
|
// Accessor
|
||||||
const FString getClassName() const override;
|
FString getClassName() const override;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void setColorPalette() override;
|
void setColorPalette() override;
|
||||||
|
@ -195,7 +195,7 @@ class default16DarkColorPalette final : public FColorPalette
|
||||||
|
|
||||||
// default16ColorPalette inline functions
|
// default16ColorPalette inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString default16DarkColorPalette::getClassName() const
|
inline FString default16DarkColorPalette::getClassName() const
|
||||||
{ return "default16DarkColorPalette"; }
|
{ return "default16DarkColorPalette"; }
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue