commit
bccdbbd3ad
@ -1,11 +1,15 @@
|
||||
exclude:
|
||||
- /fonts/.*
|
||||
- /scripts/.*
|
||||
- /doc/.*
|
||||
- /build.sh
|
||||
- /ltmain.sh
|
||||
component_depth: 1
|
||||
- /debian/.*
|
||||
- /doc/.*
|
||||
- /examples/.*
|
||||
- /fonts/.*
|
||||
- /icon/.*
|
||||
- /logo/.*
|
||||
- /m4/.*
|
||||
- /scripts/.*
|
||||
- /build.sh
|
||||
- /ltmain.sh
|
||||
component_depth: 3
|
||||
languages:
|
||||
- cpp
|
||||
- script
|
||||
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -49,6 +49,8 @@ examples/windows
|
||||
examples/term-attributes
|
||||
examples/transparent
|
||||
examples/input-dialog
|
||||
examples/fullwidth-character
|
||||
examples/7segment
|
||||
examples/choice
|
||||
examples/listbox
|
||||
examples/listview
|
||||
|
13
.travis.yml
13
.travis.yml
@ -12,6 +12,7 @@ addons:
|
||||
- autoconf
|
||||
- autoconf-archive
|
||||
- libtool
|
||||
- pkg-config
|
||||
- libglib2.0-dev
|
||||
- libncurses5-dev
|
||||
- gpm
|
||||
@ -21,6 +22,7 @@ addons:
|
||||
homebrew:
|
||||
packages:
|
||||
- autoconf-archive
|
||||
update: true
|
||||
|
||||
env:
|
||||
global:
|
||||
@ -52,7 +54,7 @@ matrix:
|
||||
name: gansm/finalcut
|
||||
description: Build submitted via Travis CI
|
||||
notification_email: guru.mail@muenster.de
|
||||
build_command_prepend: "autoreconf -v --install --force && ./configure --prefix=/usr CPPFLAGS='-DDEBUG' CXXFLAGS='-g -O0 -DDEBUG' --with-unit-test && make clean"
|
||||
build_command_prepend: "autoreconf -v --install --force && ./configure --prefix=/usr CPPFLAGS='-DDEBUG' CXXFLAGS='-g -O0 -DDEBUG -DUNIT_TEST' --with-unit-test && make clean"
|
||||
build_command: "make V=1 -j10"
|
||||
branch_pattern: master
|
||||
before_install:
|
||||
@ -60,15 +62,18 @@ matrix:
|
||||
- uname -a
|
||||
- whoami
|
||||
- sudo apt-get install gpm libgpm-dev libcppunit-dev autoconf-archive
|
||||
# Work around broken certificate of scan.coverity.com
|
||||
- sudo curl -s -L https://entrust.com/root-certificates/entrust_l1k.cer -o /usr/local/share/ca-certificates/entrust_l1k.crt
|
||||
- sudo update-ca-certificates
|
||||
script:
|
||||
- autoreconf -v --install --force
|
||||
- ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG" --with-unit-test
|
||||
- ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test
|
||||
- make V=1 -j10
|
||||
- make check
|
||||
- cat test/*.log
|
||||
|
||||
#
|
||||
# Coveralls
|
||||
# Coveralls + Codecov
|
||||
#
|
||||
- os: linux
|
||||
env:
|
||||
@ -77,10 +82,12 @@ matrix:
|
||||
- lsb_release -a
|
||||
- uname -a
|
||||
- pip install --user cpp-coveralls
|
||||
- sudo pip install codecov
|
||||
script:
|
||||
- ./build.sh coverage
|
||||
after_success:
|
||||
- coveralls --gcov-options '\-lp' -e debian -e doc -e icon -e logo -e m4 -e scripts -e examples
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
#
|
||||
# macOS
|
||||
|
113
ChangeLog
113
ChangeLog
@ -1,5 +1,112 @@
|
||||
2019-09-28 Markus Gans <guru.mail@muenster.de>
|
||||
* Support for displaying full-width characters (2 columns wide)
|
||||
on the terminal. This is particularly important for the correct
|
||||
display of CJK characters
|
||||
|
||||
2019-09-16 Markus Gans <guru.mail@muenster.de>
|
||||
* Improve FStartOptions implementation
|
||||
|
||||
2019-09-08 Markus Gans <guru.mail@muenster.de>
|
||||
* Remove the lines of the #pragma pack() directive from the code
|
||||
because they caused a misaligned address
|
||||
|
||||
2019-09-06 Markus Gans <guru.mail@muenster.de>
|
||||
* Outsourcing the initialization data to a separate struct
|
||||
|
||||
2019-09-04 Markus Gans <guru.mail@muenster.de>
|
||||
* The Cygwin and Linux console do not use cp437 character encoding
|
||||
by default anymore
|
||||
|
||||
2019-09-01 Markus Gans <guru.mail@muenster.de>
|
||||
* Removing public + protected data members from classes
|
||||
|
||||
2019-08-25 Markus Gans <guru.mail@muenster.de>
|
||||
* More use of direct initializations
|
||||
|
||||
2019-08-18 Markus Gans <guru.mail@muenster.de>
|
||||
* Solved problem detecting terminal size on quick changes
|
||||
* Update VTerm information only in case of changes
|
||||
* Fixes print() << FPoint() behavior in FScrollView
|
||||
|
||||
2019-08-11 Markus Gans <guru.mail@muenster.de>
|
||||
* FRect has now got a scaleBy() method
|
||||
* Convert drawBorder() to a non-member function using FRect
|
||||
* Converts getHotkeyPos() for sharing into a non-member function
|
||||
|
||||
2019-08-10 Markus Gans <guru.mail@muenster.de>
|
||||
* Pitch and duration of system speaker can now be changed
|
||||
on OpenBSD
|
||||
|
||||
2019-08-07 Markus Gans <guru.mail@muenster.de>
|
||||
* Fixes the Cygwin build
|
||||
|
||||
2019-08-04 Markus Gans <guru.mail@muenster.de>
|
||||
* Reduce the number of interface parameters
|
||||
|
||||
2019-07-31 Markus Gans <guru.mail@muenster.de>
|
||||
* Unit test for the move assignment operator and move constructor
|
||||
in FPoint, FSize and FRect
|
||||
|
||||
2019-07-28 Markus Gans <guru.mail@muenster.de>
|
||||
* FreeBSD can now change the frequency and duration
|
||||
of the pc speaker signal
|
||||
* Added a unit test for the FTermFreeBSD class to test
|
||||
the FreeBSD console
|
||||
|
||||
2019-07-21 Markus Gans <guru.mail@muenster.de>
|
||||
* Reduce include entries in the header files
|
||||
|
||||
2019-07-14 Markus Gans <guru.mail@muenster.de>
|
||||
* Reduces the use of raw loops
|
||||
* Add a unit test for FTermOpenBSD to test the OpenBSD
|
||||
and NetBSD console
|
||||
|
||||
2019-06-30 Markus Gans <guru.mail@muenster.de>
|
||||
* Expanding the unit test for FTermLinux
|
||||
* Update the cp437 unicode map
|
||||
* Reducing the special cases for Solaris
|
||||
|
||||
2019-06-19 Markus Gans <guru.mail@muenster.de>
|
||||
* Add a unit test for FTermLinux with a Linux console emulation
|
||||
and a dedicated FSystem test instance
|
||||
|
||||
2019-06-12 Markus Gans <guru.mail@muenster.de>
|
||||
* Fixes problem with scroll bar view after first draw
|
||||
|
||||
2019-06-02 Markus Gans <guru.mail@muenster.de>
|
||||
* Avoid drawing the scroll bars if the widget is non-visible
|
||||
|
||||
2019-05-27 Markus Gans <guru.mail@muenster.de>
|
||||
* Use the Singleton design pattern to get a single object instance
|
||||
via FTerm
|
||||
|
||||
2019-05-26 Marek Habersack <grendel@twistedcode.net>
|
||||
* Fix a segfault when processing input to empty FListView
|
||||
|
||||
2019-05-17 Markus Gans <guru.mail@muenster.de>
|
||||
* Move system calls to the new class FSystem
|
||||
|
||||
2019-04-27 Markus Gans <guru.mail@muenster.de>
|
||||
* Add the reserve() method to FListBox to increase the capacity
|
||||
of the list
|
||||
* Use shrink_to_fit() to save memory space
|
||||
|
||||
2019-03-24 Markus Gans <guru.mail@muenster.de>
|
||||
* Add a "scroll view" chapter to the first steps document
|
||||
|
||||
2019-02-28 Markus Gans <guru.mail@muenster.de>
|
||||
* Add an lambda expression callback example to the first steps document
|
||||
|
||||
2019-02-24 Markus Gans <guru.mail@muenster.de>
|
||||
* FLineEdit now has the ability to define a character input filter
|
||||
via regular expression (regex)
|
||||
* Now FLineEdit can define a maximum character length for the input
|
||||
* The cursor position can now be set directly in FLineEdit
|
||||
* Added the 7-segment example to demonstrate the use of FTermBuffer
|
||||
and FLineEdit input filters
|
||||
|
||||
2019-02-07 Markus Gans <guru.mail@muenster.de>
|
||||
* Add a "dynamic layout" Chapter into the first steps document
|
||||
* Add a "dynamic layout" chapter into the first steps document
|
||||
|
||||
2019-01-30 Markus Gans <guru.mail@muenster.de>
|
||||
* Printing an FColorPair object can change the foreground and
|
||||
@ -91,7 +198,7 @@
|
||||
the switch statement with a vector of lambda expressions
|
||||
|
||||
2018-12-09 Markus Gans <guru.mail@muenster.de>
|
||||
* Better handling of the scrollbar maximum
|
||||
* Better handling of the scroll bar maximum
|
||||
* Deactivate copy constructor and assignment operator with "= delete"
|
||||
* Use nullptr instead of 0 to initialize a pointer values
|
||||
|
||||
@ -107,7 +214,7 @@
|
||||
* Fix compile in optimization level 2 for newer gcc
|
||||
|
||||
2018-11-27 Markus Gans <guru.mail@muenster.de>
|
||||
* Correct vertical scrollbar position after sorting in FListView
|
||||
* Correct vertical scroll bar position after sorting in FListView
|
||||
|
||||
2018-11-25 Markus Gans <guru.mail@muenster.de>
|
||||
* Version 0.5.0
|
||||
|
93
README.md
93
README.md
@ -1,7 +1,12 @@
|
||||

|
||||
============================================
|
||||
|
||||
### Building and code analysis
|
||||
# Library for creating terminal applications with text-based widgets
|
||||
The FINAL CUT is a C++ class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen.
|
||||
|
||||
The structure of the Qt framework was originally the inspiration for the C++ class design of FINAL CUT. It provides common controls like dialog boxes, push buttons, check boxes, radio buttons, input lines, list boxes, status bars and so on.
|
||||
|
||||
## Building and code analysis
|
||||
*Latest release:*<br />
|
||||
     [](https://github.com/gansm/finalcut/releases) <br />
|
||||
*License:*<br />
|
||||
@ -9,18 +14,13 @@
|
||||
*Travis CI:*<br />
|
||||
     [](https://travis-ci.org/gansm/finalcut) <br />
|
||||
*Coverity Scan:*<br />
|
||||
     [](https://scan.coverity.com/projects/6508) <br />
|
||||
     [](https://scan.coverity.com/projects/6508) <br />
|
||||
*LGTM:*<br />
|
||||
     [](https://lgtm.com/projects/g/gansm/finalcut/context:cpp) <br />
|
||||
*Class Reference:*<br />
|
||||
     [](https://codedocs.xyz/gansm/finalcut/hierarchy.html)
|
||||
|
||||
### Description
|
||||
The FINAL CUT is a C++ class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen.
|
||||
|
||||
The structure of the Qt framework was originally the inspiration for the C++ class design of FINAL CUT. It provides common controls like dialog boxes, push buttons, check boxes, radio buttons, input lines, list boxes, status bars and so on.
|
||||
|
||||
### Installation
|
||||
## Installation
|
||||
```bash
|
||||
> git clone git://github.com/gansm/finalcut.git
|
||||
> cd finalcut
|
||||
@ -30,7 +30,7 @@ The structure of the Qt framework was originally the inspiration for the C++ cla
|
||||
> su -c "make install"
|
||||
```
|
||||
|
||||
### Supported platforms
|
||||
## Supported platforms
|
||||
* Linux
|
||||
* FreeBSD
|
||||
* NetBSD
|
||||
@ -39,13 +39,12 @@ The structure of the Qt framework was originally the inspiration for the C++ cla
|
||||
* Cygwin
|
||||
* Solaris
|
||||
|
||||
### First steps
|
||||
## First steps
|
||||
Read here [how to use the library](doc/first-steps.md#first-steps-with-the-final-cut-widget-toolkit)
|
||||
|
||||
[How to use the library](doc/first-steps.md#first-steps-with-the-final-cut-widget-toolkit)
|
||||
## Some screenshots
|
||||
|
||||
### Screenshots
|
||||
|
||||
The FFileDialog widget:
|
||||
The FFileDialog widget with incremental file name search:
|
||||
|
||||

|
||||
|
||||
@ -152,47 +151,53 @@ Class digramm
|
||||
1┌──────────────┐
|
||||
┌-----------┤ FTermFreeBSD │
|
||||
: └──────────────┘
|
||||
: 1┌──────────────┐ ┌───────────┐
|
||||
┌-----------┤ FTermOpenBSD │ ┌────┤ FKeyEvent │
|
||||
: └──────────────┘ │ └───────────┘
|
||||
: 1┌──────────────┐
|
||||
┌-----------┤ FTermOpenBSD │
|
||||
: └──────────────┘
|
||||
: 1┌────────────────┐ ┌───────────┐
|
||||
┌-----------┤ FTermDetection │ ┌────┤ FKeyEvent │
|
||||
: └────────────────┘ │ └───────────┘
|
||||
: 1┌────────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermDetection │ ├────┤ FMouseEvent │
|
||||
┌-----------┤ FTermcapQuirks │ ├────┤ FMouseEvent │
|
||||
: └────────────────┘ │ └─────────────┘
|
||||
: 1┌────────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermcapQuirks │ ├────┤ FWheelEvent │
|
||||
: └────────────────┘ │ └─────────────┘
|
||||
: 1┌────────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermXTerminal │ ├────┤ FFocusEvent │
|
||||
┌-----------┤ FTermXTerminal │ ├────┤ FWheelEvent │
|
||||
: └────────────────┘ │ └─────────────┘
|
||||
: 1┌──────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermcap │ ├────┤ FAccelEvent │
|
||||
┌-----------┤ FTermcap │ ├────┤ FFocusEvent │
|
||||
: └──────────┘ │ └─────────────┘
|
||||
: 1┌──────────┐ │ ┌──────────────┐
|
||||
┌-----------┤ FTermios │ ├────┤ FResizeEvent │
|
||||
: └──────────┘ │ └──────────────┘
|
||||
: 1┌───────────────┐ │ ┌────────────┐
|
||||
┌-----------┤ FColorPalette │ ├────┤ FShowEvent │
|
||||
: └───────────────┘ │ └────────────┘
|
||||
: 1┌──────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermios │ ├────┤ FAccelEvent │
|
||||
: └──────────┘ │ └─────────────┘
|
||||
: 1┌───────────────┐ │ ┌──────────────┐
|
||||
┌-----------┤ FColorPalette │ ├────┤ FResizeEvent │
|
||||
: └───────────────┘ │ └──────────────┘
|
||||
: 1┌───────────┐ │ ┌────────────┐
|
||||
┌-----------┤ FOptiMove │ ├────┤ FHideEvent │
|
||||
┌-----------┤ FOptiMove │ ├────┤ FShowEvent │
|
||||
: └───────────┘ │ └────────────┘
|
||||
: 1┌───────────┐ │ ┌────────────┐
|
||||
┌-----------┤ FOptiAttr │ ├────┤ FHideEvent │
|
||||
: └───────────┘ │ └────────────┘
|
||||
: 1┌───────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FOptiAttr │ ├────┤ FCloseEvent │
|
||||
┌-----------┤ FKeyboard │ ├────┤ FCloseEvent │
|
||||
: └───────────┘ │ └─────────────┘
|
||||
: 1┌───────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FKeyboard │ ├────┤ FTimerEvent │
|
||||
: └───────────┘ │ └─────────────┘
|
||||
: 1┌───────────────┐ │
|
||||
┌-----------┤ FMouseControl │ │ ┌──────────────┐
|
||||
: └───────────────┘ │ ┌────┤ FApplication │
|
||||
: *┌─────────┐ │ │ └──────────────┘
|
||||
: ┌--------┤ FString │ │ │ ┌─────────┐
|
||||
: : └─────────┘ │ ├────┤ FButton │
|
||||
: : *┌────────┐ │ │ └─────────┘
|
||||
: ┌--------┤ FPoint │ │ │ ┌────────┐
|
||||
: : └────────┘ │ ├────┤ FLabel │
|
||||
: 1┌───────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
|
||||
: └───────────────┘ │ └─────────────┘
|
||||
: 1┌─────────┐ │
|
||||
┌-----------┤ FSystem │ │
|
||||
: └─────────┘ │
|
||||
: *┌─────────┐ │
|
||||
: ┌--------┤ FString │ │ ┌──────────────┐
|
||||
: : └─────────┘ │ ┌────┤ FApplication │
|
||||
: : *┌────────┐ │ │ └──────────────┘
|
||||
: ┌--------┤ FPoint │ │ │ ┌─────────┐
|
||||
: : └────────┘ │ ├────┤ FButton │
|
||||
: : *┌───────┐ │ │ └─────────┘
|
||||
: ┌--------┤ FRect │ │ │ ┌────────┐
|
||||
: : └───────┘ │ ├────┤ FLabel │
|
||||
: : *┌───────┐ │ │ └────────┘
|
||||
: ┌--------┤ FRect │ │ │ ┌───────────┐
|
||||
: ┌--------┤ FSize │ │ │ ┌───────────┐
|
||||
: : └───────┘ │ ├────┤ FLineEdit │
|
||||
:1 :1 │ │ └───────────┘
|
||||
┌─┴──┴──┐ │ │ ┌──────────────┐ ┌──────────────┐
|
||||
|
23
build.sh
23
build.sh
@ -35,7 +35,7 @@ then
|
||||
autoreconf --install --force
|
||||
else
|
||||
echo "Build failed, please install autoconf first"
|
||||
exit -1
|
||||
exit 255
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@ -46,7 +46,7 @@ case "$1" in
|
||||
if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O2" # "-O3 -fno-rtti"
|
||||
then
|
||||
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
||||
exit -1
|
||||
exit 255
|
||||
fi
|
||||
;;
|
||||
|
||||
@ -54,15 +54,15 @@ case "$1" in
|
||||
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic"
|
||||
then
|
||||
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
||||
exit -1
|
||||
exit 255
|
||||
fi
|
||||
;;
|
||||
|
||||
"--fulldebug"|"fulldebug")
|
||||
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy -ftree-loop-distribute-patterns -Wmemset-transposed-args"
|
||||
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy -ftree-loop-distribute-patterns -Wmemset-transposed-args -Wno-format-nonliteral"
|
||||
then
|
||||
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
||||
exit -1
|
||||
exit 255
|
||||
fi
|
||||
;;
|
||||
|
||||
@ -70,7 +70,7 @@ case "$1" in
|
||||
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -pg -O0 -DDEBUG -W -Wall -pedantic"
|
||||
then
|
||||
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
||||
exit -1
|
||||
exit 255
|
||||
fi
|
||||
;;
|
||||
|
||||
@ -78,23 +78,23 @@ case "$1" in
|
||||
if ! ./configure --prefix="$PREFIX" --with-profiler
|
||||
then
|
||||
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
||||
exit -1
|
||||
exit 255
|
||||
fi
|
||||
;;
|
||||
|
||||
"--unit-test"|"unit-test")
|
||||
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG" --with-unit-test
|
||||
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test
|
||||
then
|
||||
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
||||
exit -1
|
||||
exit 255
|
||||
fi
|
||||
;;
|
||||
|
||||
"--coverage"|"coverage")
|
||||
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG" --with-unit-test --with-gcov
|
||||
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test --with-gcov
|
||||
then
|
||||
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
||||
exit -1
|
||||
exit 255
|
||||
fi
|
||||
;;
|
||||
|
||||
@ -139,6 +139,7 @@ if [ "$1" = "--unit-test" ] \
|
||||
|| [ "$1" = "--coverage" ] \
|
||||
|| [ "$1" = "coverage" ]
|
||||
then
|
||||
rm test/*.log 2>/dev/null
|
||||
cd test && make check-TESTS
|
||||
cat ./*.log 2>/dev/null
|
||||
cd .. || exit
|
||||
|
14
debian/libfinal-dev.docs
vendored
14
debian/libfinal-dev.docs
vendored
@ -1,8 +1,20 @@
|
||||
AUTHORS
|
||||
COPYING
|
||||
COPYING.LESSER
|
||||
ChangeLog
|
||||
README.md
|
||||
doc/calendar-draft.png
|
||||
doc/calculator.png
|
||||
doc/class-diagram.txt
|
||||
doc/class_template.cpp
|
||||
doc/class_template.h
|
||||
doc/console_codes-manual.sh
|
||||
doc/console_ioctl-manual.sh
|
||||
doc/faq.md
|
||||
doc/fileopen-dialog.png
|
||||
doc/first-steps.md
|
||||
doc/framebuffer.txt
|
||||
doc/Mandelbrot.png
|
||||
doc/ncurses.supp
|
||||
doc/newfont1.png
|
||||
doc/newfont2.png
|
||||
@ -13,6 +25,8 @@ doc/terminfo-capabilities.sh
|
||||
doc/terminfo-manual.sh
|
||||
doc/textview.png
|
||||
doc/TODO
|
||||
doc/vga.txt
|
||||
doc/vt100_line_drawing_graphics.png
|
||||
doc/virtual-terminal.txt
|
||||
doc/xterm.txt
|
||||
doc/xgraphics
|
||||
|
@ -6,10 +6,17 @@ docdir = ${datadir}/doc/${PACKAGE}
|
||||
|
||||
EXTRA_DIST = \
|
||||
calendar-draft.png \
|
||||
calculator.png \
|
||||
class-diagram.txt \
|
||||
class_template.cpp \
|
||||
class_template.h \
|
||||
console_codes-manual.sh \
|
||||
console_ioctl-manual.sh \
|
||||
faq.md \
|
||||
fileopen-dialog.png \
|
||||
first-steps.md \
|
||||
framebuffer.txt \
|
||||
Mandelbrot.png \
|
||||
ncurses.supp \
|
||||
newfont1.png \
|
||||
newfont2.png \
|
||||
@ -20,16 +27,25 @@ EXTRA_DIST = \
|
||||
terminfo-manual.sh \
|
||||
textview.png \
|
||||
TODO \
|
||||
vga.txt \
|
||||
vt100_line_drawing_graphics.png \
|
||||
virtual-terminal.txt \
|
||||
xterm.txt \
|
||||
xgraphics
|
||||
|
||||
doc_DATA = \
|
||||
calendar-draft.png \
|
||||
calculator.png \
|
||||
class-diagram.txt \
|
||||
class_template.cpp \
|
||||
class_template.h \
|
||||
console_codes-manual.sh \
|
||||
console_ioctl-manual.sh \
|
||||
faq.md \
|
||||
fileopen-dialog.png \
|
||||
first-steps.md \
|
||||
framebuffer.txt \
|
||||
Mandelbrot.png \
|
||||
ncurses.supp \
|
||||
newfont1.png \
|
||||
newfont2.png \
|
||||
@ -40,6 +56,8 @@ doc_DATA = \
|
||||
terminfo-manual.sh \
|
||||
textview.png \
|
||||
TODO \
|
||||
vga.txt \
|
||||
vt100_line_drawing_graphics.png \
|
||||
virtual-terminal.txt \
|
||||
xterm.txt \
|
||||
xgraphics
|
||||
|
24
doc/build_openbsd.txt
Normal file
24
doc/build_openbsd.txt
Normal file
@ -0,0 +1,24 @@
|
||||
Build FINAL CUT with the clang c++ compiler
|
||||
-------------------------------------------
|
||||
openbsd# CXX=clang++ ./build.sh
|
||||
|
||||
Build FINAL CUT with eg++
|
||||
-------------------------
|
||||
openbsd# CXX=eg++ ./build.sh
|
||||
|
||||
Install egcc on OpenBSD
|
||||
-----------------------
|
||||
openbsd# pkg_add g++
|
||||
quirks-3.124 signed on 2019-04-15T12:10:16Z
|
||||
Ambiguous: choose package for g++
|
||||
a 0: <None>
|
||||
1: g++-4.9.4p18
|
||||
2: g++-8.3.0
|
||||
Your choice: 2
|
||||
g++-8.3.0:gcc-libs-8.3.0: ok
|
||||
g++-8.3.0:gmp-6.1.2p3: ok
|
||||
g++-8.3.0:mpfr-3.1.5.2p0: ok
|
||||
g++-8.3.0:libmpc-0.9p2: ok
|
||||
g++-8.3.0:gcc-8.3.0: ok
|
||||
g++-8.3.0: ok
|
||||
|
12
doc/build_solaris.txt
Normal file
12
doc/build_solaris.txt
Normal file
@ -0,0 +1,12 @@
|
||||
Install gcc5g++ on Solaris
|
||||
https://www.opencsw.org/packages/gcc5g++/
|
||||
|
||||
pkgadd -d http://get.opencsw.org/now
|
||||
/opt/csw/bin/pkgutil -U
|
||||
/opt/csw/bin/pkgutil -y -i gcc5g++
|
||||
/usr/sbin/pkgchk -L CSWgcc5g++ # list files
|
||||
|
||||
|
||||
|
||||
PATH=/opt/csw/bin:$PATH
|
||||
|
@ -4,47 +4,53 @@
|
||||
1┌──────────────┐
|
||||
┌-----------┤ FTermFreeBSD │
|
||||
: └──────────────┘
|
||||
: 1┌──────────────┐ ┌───────────┐
|
||||
┌-----------┤ FTermOpenBSD │ ┌────┤ FKeyEvent │
|
||||
: └──────────────┘ │ └───────────┘
|
||||
: 1┌──────────────┐
|
||||
┌-----------┤ FTermOpenBSD │
|
||||
: └──────────────┘
|
||||
: 1┌────────────────┐ ┌───────────┐
|
||||
┌-----------┤ FTermDetection │ ┌────┤ FKeyEvent │
|
||||
: └────────────────┘ │ └───────────┘
|
||||
: 1┌────────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermDetection │ ├────┤ FMouseEvent │
|
||||
┌-----------┤ FTermcapQuirks │ ├────┤ FMouseEvent │
|
||||
: └────────────────┘ │ └─────────────┘
|
||||
: 1┌────────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermcapQuirks │ ├────┤ FWheelEvent │
|
||||
: └────────────────┘ │ └─────────────┘
|
||||
: 1┌────────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermXTerminal │ ├────┤ FFocusEvent │
|
||||
┌-----------┤ FTermXTerminal │ ├────┤ FWheelEvent │
|
||||
: └────────────────┘ │ └─────────────┘
|
||||
: 1┌──────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermcap │ ├────┤ FAccelEvent │
|
||||
┌-----------┤ FTermcap │ ├────┤ FFocusEvent │
|
||||
: └──────────┘ │ └─────────────┘
|
||||
: 1┌──────────┐ │ ┌──────────────┐
|
||||
┌-----------┤ FTermios │ ├────┤ FResizeEvent │
|
||||
: └──────────┘ │ └──────────────┘
|
||||
: 1┌───────────────┐ │ ┌────────────┐
|
||||
┌-----------┤ FColorPalette │ ├────┤ FShowEvent │
|
||||
: └───────────────┘ │ └────────────┘
|
||||
: 1┌──────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermios │ ├────┤ FAccelEvent │
|
||||
: └──────────┘ │ └─────────────┘
|
||||
: 1┌───────────────┐ │ ┌──────────────┐
|
||||
┌-----------┤ FColorPalette │ ├────┤ FResizeEvent │
|
||||
: └───────────────┘ │ └──────────────┘
|
||||
: 1┌───────────┐ │ ┌────────────┐
|
||||
┌-----------┤ FOptiMove │ ├────┤ FHideEvent │
|
||||
┌-----------┤ FOptiMove │ ├────┤ FShowEvent │
|
||||
: └───────────┘ │ └────────────┘
|
||||
: 1┌───────────┐ │ ┌────────────┐
|
||||
┌-----------┤ FOptiAttr │ ├────┤ FHideEvent │
|
||||
: └───────────┘ │ └────────────┘
|
||||
: 1┌───────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FOptiAttr │ ├────┤ FCloseEvent │
|
||||
┌-----------┤ FKeyboard │ ├────┤ FCloseEvent │
|
||||
: └───────────┘ │ └─────────────┘
|
||||
: 1┌───────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FKeyboard │ ├────┤ FTimerEvent │
|
||||
: └───────────┘ │ └─────────────┘
|
||||
: 1┌───────────────┐ │
|
||||
┌-----------┤ FMouseControl │ │ ┌──────────────┐
|
||||
: └───────────────┘ │ ┌────┤ FApplication │
|
||||
: *┌─────────┐ │ │ └──────────────┘
|
||||
: ┌--------┤ FString │ │ │ ┌─────────┐
|
||||
: : └─────────┘ │ ├────┤ FButton │
|
||||
: : *┌────────┐ │ │ └─────────┘
|
||||
: ┌--------┤ FPoint │ │ │ ┌────────┐
|
||||
: : └────────┘ │ ├────┤ FLabel │
|
||||
: 1┌───────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
|
||||
: └───────────────┘ │ └─────────────┘
|
||||
: 1┌─────────┐ │
|
||||
┌-----------┤ FSystem │ │
|
||||
: └─────────┘ │
|
||||
: *┌─────────┐ │
|
||||
: ┌--------┤ FString │ │ ┌──────────────┐
|
||||
: : └─────────┘ │ ┌────┤ FApplication │
|
||||
: : *┌────────┐ │ │ └──────────────┘
|
||||
: ┌--------┤ FPoint │ │ │ ┌─────────┐
|
||||
: : └────────┘ │ ├────┤ FButton │
|
||||
: : *┌───────┐ │ │ └─────────┘
|
||||
: ┌--------┤ FRect │ │ │ ┌────────┐
|
||||
: : └───────┘ │ ├────┤ FLabel │
|
||||
: : *┌───────┐ │ │ └────────┘
|
||||
: ┌--------┤ FRect │ │ │ ┌───────────┐
|
||||
: ┌--------┤ FSize │ │ │ ┌───────────┐
|
||||
: : └───────┘ │ ├────┤ FLineEdit │
|
||||
:1 :1 │ │ └───────────┘
|
||||
┌─┴──┴──┐ │ │ ┌──────────────┐ ┌──────────────┐
|
||||
@ -100,4 +106,3 @@
|
||||
└──────────┘ │ ┌────────────────┐* :
|
||||
└──┤ FRadioMenuItem ├---┘
|
||||
└────────────────┘
|
||||
|
||||
|
@ -44,9 +44,6 @@ namespace finalcut
|
||||
// class FClassName
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class FClassName
|
||||
{
|
||||
public:
|
||||
@ -82,7 +79,7 @@ class FClassName
|
||||
|
||||
// Callback methods
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
|
||||
protected:
|
||||
// Typedefs and Enumerations
|
||||
@ -99,7 +96,7 @@ class FClassName
|
||||
|
||||
// Callback methods
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
|
||||
private:
|
||||
// Typedefs and Enumerations
|
||||
@ -116,12 +113,12 @@ class FClassName
|
||||
|
||||
// Callback methods
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
|
||||
// Friend class
|
||||
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
// FClassName inline functions
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -13,9 +13,11 @@ Table of Contents
|
||||
- [Signals and Callbacks](#signals-and-callbacks)
|
||||
- [Default signals](#the-final-cut-widgets-emit-the-following-default-signals)
|
||||
- [Callback function](#example-of-a-callback-function)
|
||||
- [Callback lambda expression](#example-of-an-lambda-expression-callback)
|
||||
- [Callback method](#example-of-a-callback-function)
|
||||
- [Custom signals](#send-custom-signals)
|
||||
- [Dynamic layout](#dynamic-layout)
|
||||
- [Scroll view](#scroll-view)
|
||||
<!-- /TOC -->
|
||||
|
||||
|
||||
@ -25,7 +27,7 @@ How to use the library
|
||||
At the beginning of this introduction to the Final Cut
|
||||
we will start with a small example.
|
||||
|
||||
The following example creates an empty 30×10 character dialog.
|
||||
The following example creates an empty 30??10 character dialog.
|
||||
|
||||
**File:** *dialog.cpp*
|
||||
```cpp
|
||||
@ -288,7 +290,7 @@ class dialogWidget : public FDialog
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void onTimer (FTimerEvent* ev) override
|
||||
void onTimer (FTimerEvent* ev) override
|
||||
{
|
||||
if ( id == ev->getTimerId() && n < 9999999999 )
|
||||
{
|
||||
@ -479,6 +481,64 @@ g++ -O2 -lfinal callback-function.cpp -o callback-function
|
||||
```
|
||||
|
||||
|
||||
### Example of an lambda expression callback: ###
|
||||
|
||||
**File:** *callback-lambda.cpp*
|
||||
|
||||
```cpp
|
||||
#include <final/final.h>
|
||||
|
||||
using namespace finalcut;
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
FApplication app(argc, argv);
|
||||
FDialog dialog(&app);
|
||||
dialog.setText ("Lambda expression as callback");
|
||||
dialog.setGeometry (FRect(25, 5, 45, 9));
|
||||
FButton button ("&bottom", &dialog);
|
||||
button.setGeometry (FPoint(15, 5), FSize(14, 1));
|
||||
|
||||
// Connect the button signal "clicked" with the lambda expression
|
||||
button.addCallback
|
||||
(
|
||||
"clicked",
|
||||
[] (FWidget* w, FDataPtr d)
|
||||
{
|
||||
FButton& button = *(static_cast<FButton*>(w));
|
||||
|
||||
if ( button.getY() != 2 )
|
||||
{
|
||||
button.setPos (FPoint(15, 2));
|
||||
button.setText("&top");
|
||||
}
|
||||
else
|
||||
{
|
||||
button.setPos (FPoint(15, 5));
|
||||
button.setText("&bottom");
|
||||
}
|
||||
|
||||
static_cast<FDialog*>(d)->redraw();
|
||||
},
|
||||
&dialog
|
||||
);
|
||||
|
||||
app.setMainWidget(&dialog);
|
||||
dialog.show();
|
||||
return app.exec();
|
||||
}
|
||||
```
|
||||
*(Note: You can close the dialog with the mouse,
|
||||
<kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Ctrl</kbd>+<kbd>^</kbd>)*
|
||||
|
||||
|
||||
After entering the source code in *callback-lambda.cpp* you can compile
|
||||
the above program with gcc:
|
||||
```cpp
|
||||
g++ -O2 -lfinal -std=c++11 callback-lambda.cpp -o callback-lambda
|
||||
```
|
||||
|
||||
|
||||
### Example of a callback method: ###
|
||||
|
||||
**File:** *callback-method.cpp*
|
||||
@ -639,12 +699,12 @@ class dialogWidget : public FDialog
|
||||
void setTemperature()
|
||||
{
|
||||
label.clear();
|
||||
label << t << "°C";
|
||||
label << t << "??C";
|
||||
label.redraw();
|
||||
}
|
||||
|
||||
int t = 20;
|
||||
FLabel label{FString() << t << "°C", this};
|
||||
FLabel label{FString() << t << "??C", this};
|
||||
FButton plus {"&+", this};
|
||||
FButton minus {"&-", this};
|
||||
};
|
||||
@ -702,8 +762,8 @@ class dialogWidget : public FDialog
|
||||
{
|
||||
setText ("Dialog");
|
||||
setResizeable();
|
||||
btn.setGeometry (FPoint(1, 1), FSize(12, 1), false);
|
||||
line.setGeometry (FPoint(2, 3), FSize(12, 1), false);
|
||||
button.setGeometry (FPoint(1, 1), FSize(12, 1), false);
|
||||
input.setGeometry (FPoint(2, 3), FSize(12, 1), false);
|
||||
// Set dialog geometry and calling adjustSize()
|
||||
setGeometry (FPoint(25, 5), FSize(40, 12));
|
||||
setMinimumSize (FSize(25, 9));
|
||||
@ -727,15 +787,15 @@ class dialogWidget : public FDialog
|
||||
|
||||
void adjustWidgets()
|
||||
{
|
||||
auto bx = int(getWidth() - btn.getWidth() - 3);
|
||||
auto bx = int(getWidth() - button.getWidth() - 3);
|
||||
auto by = int(getHeight() - 4);
|
||||
btn.setPos (FPoint(bx, by), false);
|
||||
line.setWidth (getWidth() - 4);
|
||||
button.setPos (FPoint(bx, by), false);
|
||||
input.setWidth (getWidth() - 4);
|
||||
auto ly = int(getHeight() / 2) - 1;
|
||||
line.setY (ly, false);
|
||||
input.setY (ly, false);
|
||||
}
|
||||
|
||||
virtual void adjustSize() override
|
||||
void adjustSize() override
|
||||
{
|
||||
// Calling super class method adjustSize()
|
||||
FDialog::adjustSize();
|
||||
@ -743,14 +803,14 @@ class dialogWidget : public FDialog
|
||||
centerDialog();
|
||||
}
|
||||
|
||||
virtual void setSize (const FSize& size, bool) override
|
||||
void setSize (const FSize& size, bool) override
|
||||
{
|
||||
// Calling super class methods setSize() + adjustSize()
|
||||
FDialog::setSize (size, false);
|
||||
FDialog::adjustSize();
|
||||
}
|
||||
|
||||
virtual void draw() override
|
||||
void draw() override
|
||||
{
|
||||
adjustWidgets(); // Adjust widgets before drawing
|
||||
|
||||
@ -764,8 +824,8 @@ class dialogWidget : public FDialog
|
||||
<< "top";
|
||||
}
|
||||
|
||||
FLineEdit line{"Middle", this};
|
||||
FButton btn{"&Bottom", this};
|
||||
FLineEdit input{"Middle", this};
|
||||
FButton button{"&Bottom", this};
|
||||
};
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
@ -787,3 +847,123 @@ the above program with gcc:
|
||||
g++ -O2 -lfinal -std=c++11 size-adjustment.cpp -o size-adjustment
|
||||
```
|
||||
|
||||
|
||||
Scroll view
|
||||
-----------
|
||||
|
||||
The scroll view of the `FScrollView` class allows users to view content
|
||||
that is larger than the visible area. The `FScrollView` widget displays
|
||||
the horizontal and vertical scroll bar by default, only if the content size
|
||||
requires it. You can controll this behavior by the two methods
|
||||
`setHorizontalScrollBarMode()` and `setVerticalScrollBarMode()`.
|
||||
|
||||
```cpp
|
||||
setHorizontalScrollBarMode (fc::scrollBarMode);
|
||||
setVerticalScrollBarMode (fc::scrollBarMode);
|
||||
```
|
||||
|
||||
You pass the scroll bar visibility mode as a value of the enum type
|
||||
`fc::scrollBarMode`.
|
||||
|
||||
```cpp
|
||||
enum scrollBarMode
|
||||
{
|
||||
Auto = 0, // Shows a scroll bar when area is larger than viewport
|
||||
Hidden = 1, // Never shows a scroll bar
|
||||
Scroll = 2 // Always shows a scroll bar
|
||||
};
|
||||
```
|
||||
|
||||
You can add widgets to an `FScrollView` object as child objects and place
|
||||
them (with a widget positioning method) on the scrollable area. If a client
|
||||
widget gets the focus, it automatically scrolls the viewport to the focused
|
||||
widget. You can use the methods `scrollTo()`, `scrollToX()`, `scrollToY()`
|
||||
and `scrollBy()` to set the scroll position of the viewport directly.
|
||||
|
||||
The `FButtonGroup` widget uses `FScrollView` to display more buttons
|
||||
in the frame than the height allows.
|
||||
|
||||
**File:** *scrollview.cpp*
|
||||
```cpp
|
||||
#include <utility>
|
||||
#include <final/final.h>
|
||||
|
||||
using namespace finalcut;
|
||||
|
||||
class dialogWidget : public FDialog
|
||||
{
|
||||
public:
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog(parent)
|
||||
{
|
||||
setText ("Dialog");
|
||||
setGeometry (FPoint(28, 2), FSize(24, 21));
|
||||
scrollview.setGeometry(FPoint(1, 1), FSize(22, 11));
|
||||
scrollview.setScrollSize(FSize(60, 27));
|
||||
setColor (wc.label_inactive_fg, wc.dialog_bg);
|
||||
scrollview.clearArea();
|
||||
FColorPair red (fc::LightRed, wc.dialog_bg);
|
||||
FColorPair black (fc::Black, wc.dialog_bg);
|
||||
FColorPair cyan (fc::Cyan, wc.dialog_bg);
|
||||
|
||||
static std::vector<direction> d
|
||||
{
|
||||
{"NW", FPoint(3, 13), FPoint(1, 1), black},
|
||||
{"N", FPoint(10, 13), FPoint(21, 1), red},
|
||||
{"NE", FPoint(17, 13), FPoint(41, 1), black},
|
||||
{"W", FPoint(3, 15), FPoint(1, 10), black},
|
||||
{"*", FPoint(10, 15), FPoint(21, 10), black},
|
||||
{"E", FPoint(17, 15), FPoint(41, 10), black},
|
||||
{"SW", FPoint(3, 17), FPoint(1, 19), black},
|
||||
{"S", FPoint(10, 17), FPoint(21, 19), cyan},
|
||||
{"SE", FPoint(17, 17), FPoint(41, 19), black}
|
||||
};
|
||||
|
||||
for (auto&& b : d)
|
||||
{
|
||||
scrollview.print() << std::get<2>(b) + FPoint(10, 5)
|
||||
<< std::get<3>(b) << std::get<0>(b);
|
||||
auto edit = new FLineEdit("direction " + std::get<0>(b), &scrollview);
|
||||
edit->setGeometry(std::get<2>(b) + FPoint(1, 1), FSize(17, 1));
|
||||
auto btn = new FButton(std::get<0>(b), this);
|
||||
btn->setGeometry(std::get<1>(b), FSize(4, 1));
|
||||
btn->unsetShadow();
|
||||
btn->addCallback
|
||||
(
|
||||
"clicked",
|
||||
F_METHOD_CALLBACK (this, &dialogWidget::cb_button),
|
||||
static_cast<FDataPtr>(&std::get<2>(b))
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::tuple<FString, FPoint, FPoint, FColorPair> direction;
|
||||
|
||||
void cb_button (FWidget*, FDataPtr data)
|
||||
{
|
||||
FPoint* p = static_cast<FPoint*>(data);
|
||||
scrollview.scrollTo(*p);
|
||||
}
|
||||
|
||||
FScrollView scrollview{this};
|
||||
};
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
FApplication app(argc, argv);
|
||||
dialogWidget dialog(&app);
|
||||
app.setMainWidget(&dialog);
|
||||
dialog.show();
|
||||
return app.exec();
|
||||
}
|
||||
```
|
||||
*(Note: You can close the window with the mouse,
|
||||
<kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Ctrl</kbd>+<kbd>^</kbd>)*
|
||||
|
||||
|
||||
After entering the source code in *scrollview.cpp* you can compile
|
||||
the above program with gcc:
|
||||
```cpp
|
||||
g++ -O2 -lfinal -std=c++11 scrollview.cpp -o scrollview
|
||||
```
|
||||
|
516
doc/vga.txt
Normal file
516
doc/vga.txt
Normal file
@ -0,0 +1,516 @@
|
||||
3C0h: Attribute Controller: Address register
|
||||
bit 0-4 Address of data register to write to port 3C0h or read from port 3C1h
|
||||
(Reads only on VGA).
|
||||
5 If set screen output is enabled and the palette can not be modified,
|
||||
if clear screen output is disabled and the palette can be modified.
|
||||
|
||||
|
||||
Port 3C0h is special in that it is both address and data-write register.
|
||||
Data reads happen from port 3C1h. An internal flip-flop remembers whether it
|
||||
is currently acting as address or data register.
|
||||
Accesses to the attribute controller must be separated by at least 250ns.
|
||||
Reading port 3dAh will reset the flip-flop to address mode.
|
||||
|
||||
|
||||
3C0h index 0-Fh (r/W): Attribute: Palette
|
||||
bit 0 (EGA) Primary Blue
|
||||
1 (EGA) Primary Green
|
||||
2 (EGA) Primary Red
|
||||
3 (EGA) Secondary Blue
|
||||
4 (EGA) Secondary Green
|
||||
5 (EGA) Secondary Red
|
||||
0-5 (VGA) Index into the 256 color DAC table.
|
||||
May be modified by 3C0h index 10h and 14h.
|
||||
|
||||
3C0h index 10h (r/W): Attribute: Mode Control Register
|
||||
bit 0 Graphics mode if set, Alphanumeric mode else.
|
||||
1 Monochrome mode if set, color mode else.
|
||||
2 9-bit wide characters if set.
|
||||
The 9th bit of characters C0h-DFh will be the same as
|
||||
the 8th bit. Otherwise it will be the background color.
|
||||
3 If set Attribute bit 7 is blinking, else high intensity.
|
||||
5 (VGA Only) If set the PEL panning register (3C0h index 13h) is
|
||||
temporarily set to 0 from when the line compare causes a wrap around
|
||||
until the next vertical retrace when the register is automatically
|
||||
reloaded with the old value, else the PEL panning register ignores
|
||||
line compares.
|
||||
6 (VGA Only) If set pixels are 8 bits wide. Used in 256 color modes.
|
||||
7 (VGA Only) If set bit 4-5 of the index into the DAC table are taken
|
||||
from port 3C0h index 14h bit 0-1, else the bits in the palette
|
||||
register are used.
|
||||
|
||||
3C0h index 11h (r/W): Attribute: Overscan Color Register.
|
||||
bit 0-5 Color of screen border. Color is defined as in the palette registers.
|
||||
Note: The EGA requires the Overscan color to be 0 in high resolution modes.
|
||||
|
||||
3C0h index 12h (r/W): Attribute: Color Plane Enable Register
|
||||
bit 0 Bit plane 0 is enabled if set.
|
||||
1 Bit plane 1 is enabled if set.
|
||||
2 Bit plane 2 is enabled if set.
|
||||
3 Bit plane 3 is enabled if set.
|
||||
4-5 Video Status MUX. Diagnostics use only.
|
||||
Two attribute bits appear on bits 4 and 5 of the Input
|
||||
Status Register 1 (3dAh).
|
||||
Value EGA VGA
|
||||
0 Red/Blue Bit 2/Bit 0
|
||||
1 Blue'/Green Bit 5/Bit 4
|
||||
2 Red'/Green' Bit 3/Bit 1
|
||||
3 Bit 7/Bit 6
|
||||
|
||||
3C0h index 13h (r/W): Attribute: Horizontal PEL Panning Register
|
||||
bit 0-3 Indicates number of pixels to shift the display left
|
||||
Value 9bit textmode 256color mode Other modes
|
||||
0 1 0 0
|
||||
1 2 n/a 1
|
||||
2 3 1 2
|
||||
3 4 n/a 3
|
||||
4 5 2 4
|
||||
5 6 n/a 5
|
||||
6 7 3 6
|
||||
7 8 n/a 7
|
||||
8 0 n/a n/a
|
||||
|
||||
3C0h index 14h (r/W): Attribute: Color Select Register (VGA Only)
|
||||
bit 0-1 If 3C0h index 10h bit 7 is set these 2 bits are used as bits 4-5 of
|
||||
the index into the DAC table.
|
||||
2-3 These 2 bits are used as bit 6-7 of the index into the DAC table
|
||||
except in 256 color mode.
|
||||
Note: this register does not affect 256 color modes.
|
||||
|
||||
3C2h (R): Input Status #0 Register
|
||||
bit 4 Status of the switch selected by the Miscellaneous Output
|
||||
Register 3C2h bit 2-3. Switch high if set.
|
||||
5 (EGA Only) Pin 19 of the Feature Connector (FEAT0) is high if set
|
||||
6 (EGA Only) Pin 17 of the Feature Connector (FEAT1) is high if set
|
||||
7 (EGA Only ??) If set IRQ 2 has happened due to Vertical Retrace.
|
||||
Should be cleared by IRQ 2 interrupt routine by clearing port 3d4h
|
||||
index 11h bit 4.
|
||||
|
||||
3C2h (W): Miscellaneous Output Register
|
||||
bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base
|
||||
Address=3Bxh.
|
||||
1 Enable CPU Access to video memory if set
|
||||
2-3 Clock Select
|
||||
0: 14MHz(EGA) 25MHz(VGA)
|
||||
1: 16MHz(EGA) 28MHz(VGA)
|
||||
2: External(EGA) Reserved(VGA)
|
||||
4 (EGA Only) Disable internal video drivers if set
|
||||
5 When in Odd/Even modes Select High 64k bank if set
|
||||
6 Horizontal Sync Polarity. Negative if set
|
||||
7 Vertical Sync Polarity. Negative if set
|
||||
Bit 6-7 indicates the number of lines on the display:
|
||||
0=200(EGA) Reserved(VGA)
|
||||
1= 400(VGA)
|
||||
2=350(EGA) 350(VGA)
|
||||
3= 480(VGA).
|
||||
Note: Set to all zero on a hardware reset.
|
||||
Note: On the VGA this register can be read from port 3CCh.
|
||||
|
||||
3C3h (W): Video Subsystem Enable Register
|
||||
bit 0 Enables the VGA display if set
|
||||
|
||||
3C4h index 0 (r/W): Sequencer: Reset
|
||||
bit 0 (EGA) Asynchronous Reset if clear
|
||||
0 (VGA) Synchronous Reset just as bit 1
|
||||
1 Synchronous Reset if clear
|
||||
|
||||
3C4h index 1 (r/W): Sequencer: Clocking Mode
|
||||
bit 0 If set character clocks are 8 dots wide, else 9.
|
||||
1 (EGA Only) If set the CRTC uses 2/5 of the clock cycles, else 4/5.
|
||||
2 If set loads video serializers every other character
|
||||
clock cycle, else every one.
|
||||
3 If set the Dot Clock is Master Clock/2, else same as
|
||||
Master Clock (See 3C2h bit 2-3). (Doubles pixels).
|
||||
4 (VGA Only) If set loads video serializers every fourth character
|
||||
clock cycle, else every one.
|
||||
5 (VGA Only) if set turns off screen and gives all memory cycles to the
|
||||
CPU interface.
|
||||
|
||||
3C4h index 2 (r/W): Sequencer: Map Mask Register
|
||||
bit 0 Enable writes to plane 0 if set
|
||||
1 Enable writes to plane 1 if set
|
||||
2 Enable writes to plane 2 if set
|
||||
3 Enable writes to plane 3 if set
|
||||
|
||||
3C4h index 3 (r/W): Sequencer: Character Map Select Register
|
||||
bit 0-1 (EGA) Selects EGA Character Map (0..3) if bit 3 of the character
|
||||
attribute is clear.
|
||||
2-3 (EGA) Selects EGA Character Map (0..3) if bit 3 of the character
|
||||
attribute is set.
|
||||
0,1,4 (VGA) Selects VGA Character Map (0..7) if bit 3 of the character
|
||||
attribute is clear.
|
||||
2,3,5 (VGA) Selects VGA Character Map (0..7) if bit 3 of the character
|
||||
attribute is set.
|
||||
Note: Character Maps are placed at:
|
||||
Map no. (EGA/VGA) Map no. (VGA)
|
||||
0 0k 4 8k
|
||||
1 16k 5 24k
|
||||
2 32k 6 40k
|
||||
3 48k 7 56k
|
||||
|
||||
3C4h index 4 (r/W): Sequencer: Memory Mode Register
|
||||
bit 0 Set if in an alphanumeric mode, clear in graphics modes.
|
||||
1 Set if more than 64kbytes on the adapter.
|
||||
2 Enables Odd/Even addressing mode if set. Odd/Even mode places all odd
|
||||
bytes in plane 1&3, and all even bytes in plane 0&2.
|
||||
3 (VGA Only) If set address bit 0-1 selects video memory planes
|
||||
(256 color mode), rather than the Map Mask and Read Map Select
|
||||
Registers.
|
||||
|
||||
3C4h index 7 (R/W): Sequencer Horizontal Character Counter Reset Register.
|
||||
(VGA Only)
|
||||
Note: Undocumented by IBM. May not be available in all clones.
|
||||
A write to this register will cause the Horizontal Character Counter
|
||||
to be held reset (=0) until a write happens to any of the Sequencer
|
||||
registers index 0..6.
|
||||
The Vertical Line counter is clocked by a signal derived from the
|
||||
Horizontal Display Enable (which does not occur if the Horizontal
|
||||
Character Counter is held reset).
|
||||
Thus a write to index 7 during Vertical Retrace can stop the display
|
||||
timing and allow software to start the next frame reasonably
|
||||
synchronous to an external event.
|
||||
|
||||
3C6h (R/W): PEL Mask (VGA Only)
|
||||
bit 0-7 This register is anded with the palette index sent for each dot.
|
||||
Should be set to FFh.
|
||||
|
||||
3C7h (R): DAC State Register (VGA Only)
|
||||
bit 0-1 0 indicates the DAC is in Read Mode and 3 indicates write mode.
|
||||
|
||||
3C7h (W): PEL Address Read Mode (VGA Only)
|
||||
bit 0-7 The PEL data register (0..255) to be read from 3C9h.
|
||||
Note: After reading the 3 bytes at 3C9h this register will increment,
|
||||
pointing to the next data register.
|
||||
|
||||
3C8h (R/W): PEL Address Write Mode (VGA Only)
|
||||
bit 0-7 The PEL data register (0..255) to be written to 3C9h.
|
||||
Note: After writing the 3 bytes at 3C9h this register will increment, pointing
|
||||
to the next data register.
|
||||
|
||||
3C9h (R/W): PEL Data Register (VGA Only)
|
||||
bit 0-5 Color value
|
||||
Note: Each read or write of this register will cycle through first the
|
||||
registers for Red, Blue and Green, then increment the appropriate
|
||||
address register, thus the entire palette can be loaded by writing 0 to
|
||||
the PEL Address Write Mode register 3C8h and then writing all 768 bytes
|
||||
of the palette to this register.
|
||||
|
||||
3CAh (R): Feature Control Register (VGA Only)
|
||||
Bit 3 Vertical Sync Select. If set Vertical Sync to the monitor is the
|
||||
logical OR of the vertical sync and the vertical display enable.
|
||||
Note: This register is written to port 3dAh and read from 3CAh.
|
||||
|
||||
3CAh (W): Graphics 2 Position (EGA Only)
|
||||
bit 0-1 Select which bit planes should be controlled by Graphics Controller
|
||||
#2. Always set to 1.
|
||||
|
||||
3CCh (R): Miscellaneous Output Register (VGA Only)
|
||||
bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base
|
||||
Address=3Bxh.
|
||||
1 Enable CPU Access to video memory if set
|
||||
2-3 Clock Select. 0= 25MHz, 1= 28MHz, 2= Reserved
|
||||
5 When in Odd/Even modes Select High 64k bank if set
|
||||
6 Horizontal Sync Polarity. Negative if set
|
||||
7 Vertical Sync Polarity. Negative if set
|
||||
Bit 6-7 indicates the number of lines on the display:
|
||||
0=Reserved, 1=400, 2=350, 3=480.
|
||||
Note: This register is written to port 3C2h and read from port 3CCh.
|
||||
|
||||
3CCh (W): Graphics 1 Position (EGA Only)
|
||||
bit 0-1 Select which bit planes should be controlled by Graphics Controller
|
||||
#1. Always set to 0.
|
||||
|
||||
3CEh index 0 (r/W): Graphics: Set/Reset Register
|
||||
bit 0 If in Write Mode 0 and bit 0 of 3CEh index 1 is set a write to
|
||||
display memory will set all the bits in plane 0 of the byte to this
|
||||
bit, if the corresponding bit is set in the Map Mask Register (3CEh
|
||||
index 8).
|
||||
1 Same for plane 1 and bit 1 of 3CEh index 1.
|
||||
2 Same for plane 2 and bit 2 of 3CEh index 1.
|
||||
3 Same for plane 3 and bit 3 of 3CEh index 1.
|
||||
|
||||
3CEh index 1 (r/W): Graphics: Enable Set/Reset Register
|
||||
bit 0 If set enables Set/reset of plane 0 in Write Mode 0.
|
||||
1 Same for plane 1.
|
||||
2 Same for plane 2.
|
||||
3 Same for plane 3.
|
||||
|
||||
3CEh index 2 (r/W): Graphics: Color Compare Register
|
||||
bit 0-3 In Read Mode 1 each pixel at the address of the byte read is compared
|
||||
to this color and the corresponding bit in the output set to 1 if
|
||||
they match, 0 if not. The Color Don't Care Register (3CEh index 7)
|
||||
can exclude bitplanes from the comparison.
|
||||
|
||||
3CEh index 3 (r/W): Graphics: Data Rotate
|
||||
bit 0-2 Number of positions to rotate data right before it is written to
|
||||
display memory. Only active in Write Mode 0.
|
||||
3-4 In Write Mode 2 this field controls the relation between the data
|
||||
written from the CPU, the data latched from the previous read and the
|
||||
data written to display memory:
|
||||
0: CPU Data is written unmodified
|
||||
1: CPU data is ANDed with the latched data
|
||||
2: CPU data is ORed with the latch data.
|
||||
3: CPU data is XORed with the latched data.
|
||||
|
||||
3CEh index 4 (r/W): Graphics: Read Map Select Register
|
||||
bit 0-1 Number of the plane Read Mode 0 will read from.
|
||||
|
||||
3CEh index 5 (r/W): Graphics: Mode Register
|
||||
bit 0-1 Write Mode: Controls how data from the CPU is transformed before
|
||||
being written to display memory:
|
||||
0: Mode 0 works as a Read-Modify-Write operation.
|
||||
First a read access loads the data latches of the EGA/VGA with
|
||||
the value in video memory at the addressed location. Then a
|
||||
write access will provide the destination address and the CPU
|
||||
data byte. The data written is modified by the function code in
|
||||
the Data Rotate register (3CEh index 3) as a function of the CPU
|
||||
data and the latches, then data is rotated as specified by the
|
||||
same register.
|
||||
1: Mode 1 is used for video to video transfers.
|
||||
A read access will load the data latches with the contents of
|
||||
the addressed byte of video memory. A write access will write
|
||||
the contents of the latches to the addressed byte. Thus a single
|
||||
MOVSB instruction can copy all pixels in the source address byte
|
||||
to the destination address.
|
||||
2: Mode 2 writes a color to all pixels in the addressed byte of
|
||||
video memory. Bit 0 of the CPU data is written to plane 0 et
|
||||
cetera. Individual bits can be enabled or disabled through the
|
||||
Bit Mask register (3CEh index 8).
|
||||
3: (VGA Only) Mode 3 can be used to fill an area with a color and
|
||||
pattern. The CPU data is rotated according to 3CEh index 3 bits
|
||||
0-2 and anded with the Bit Mask Register (3CEh index 8). For
|
||||
each bit in the result the corresponding pixel is set to the
|
||||
color in the Set/Reset Register (3CEh index 0 bits 0-3) if the
|
||||
bit is set and to the contents of the processor latch if the bit
|
||||
is clear.
|
||||
2 (EGA Only) Forces all outputs to a high impedance state if set.
|
||||
3 Read Mode
|
||||
0: Data is read from one of 4 bit planes depending on the Read Map
|
||||
Select Register (3CEh index 4).
|
||||
1: Data returned is a comparison between the 8 pixels occupying the
|
||||
read byte and the color in the Color Compare Register (3CEh
|
||||
index 2). A bit is set if the color of the corresponding pixel
|
||||
matches the register.
|
||||
4 Enables Odd/Even mode if set (See 3C4h index 4 bit 2).
|
||||
5 Enables CGA style 4 color pixels using even/odd bit pairs if set.
|
||||
6 (VGA Only) Enables 256 color mode if set.
|
||||
|
||||
3CEh index 6 (r/W): Graphics: Miscellaneous Register
|
||||
bit 0 Indicates Graphics Mode if set, Alphanumeric mode else.
|
||||
1 Enables Odd/Even mode if set.
|
||||
2-3 Memory Mapping:
|
||||
0: use A000h-BFFFh
|
||||
1: use A000h-AFFFh EGA/VGA Graphics modes
|
||||
2: use B000h-B7FFh Monochrome modes
|
||||
3: use B800h-BFFFh CGA modes
|
||||
|
||||
3CEh index 7 (r/W): Graphics: Color Don't Care Register
|
||||
bit 0 Ignore bit plane 0 in Read mode 1 if clear.
|
||||
1 Ignore bit plane 1 in Read mode 1 if clear.
|
||||
2 Ignore bit plane 2 in Read mode 1 if clear.
|
||||
3 Ignore bit plane 3 in Read mode 1 if clear.
|
||||
|
||||
3CEh index 8 (r/W): Graphics: Bit Mask Register
|
||||
bit 0-7 Each bit if set enables writing to the corresponding bit of a byte in
|
||||
display memory.
|
||||
|
||||
3d4h index 0 (r/W): CRTC: Horizontal Total Register
|
||||
bit 0-7 (EGA) Horizontal Total Character Clocks-2
|
||||
0-7 (VGA) Horizontal Total Character Clocks-5
|
||||
|
||||
3d4h index 1 (r/W): CRTC: Horizontal Display End Register
|
||||
bit 0-7 Number of Character Clocks Displayed -1
|
||||
|
||||
3d4h index 2 (r/W): CRTC: Start Horizontal Blanking Register
|
||||
bit 0-7 The count at which Horizontal Blanking starts
|
||||
|
||||
3d4h index 3 (r/W): CRTC: End Horizontal Blanking Register
|
||||
bit 0-4 Horizontal Blanking ends when the last 5 (6 for VGA) bits of the
|
||||
character counter equals this field.
|
||||
(VGA) The sixth bit is found in port 3d4h index 5 bit 7.
|
||||
5-6 Number of character clocks to delay start of display after Horizontal
|
||||
Total has been reached.
|
||||
7 (VGA Only) Access to Vertical Retrace registers if set. If clear
|
||||
reads to 3d4h index 10h and 11h access the Lightpen read back
|
||||
registers ??
|
||||
|
||||
3d4h index 4 (r/W): CRTC: Start Horizontal Retrace Register
|
||||
bit 0-7 Horizontal Retrace starts when the Character Counter reaches this
|
||||
value.
|
||||
|
||||
3d4h index 5 (r/W): CRTC: End Horizontal Retrace Register
|
||||
bit 0-4 Horizontal Retrace ends when the last 5 bits of the character counter
|
||||
equals this value.
|
||||
5-6 Number of character clocks to delay start of display after Horizontal
|
||||
Retrace.
|
||||
7 (EGA) Provides Smooth Scrolling in Odd/Even mode. When set display
|
||||
starts from an odd byte.
|
||||
7 (VGA) bit 5 of the End Horizontal Blanking count (See 3d4h index 3
|
||||
bit 0-4).
|
||||
|
||||
3d4h index 6 (r/W): CRTC: Vertical Total Register
|
||||
bit 0-7 Lower 8 bits of the Vertical Total. Bit 8 is found in 3d4h index 7
|
||||
bit 0. (VGA) Bit 9 is found in 3d4h index 7 bit 5.
|
||||
Note: For the VGA this value is the number of scan lines in the display -2.
|
||||
|
||||
3d4h index 7 (r/W): CRTC: Overflow Register
|
||||
bit 0 Bit 8 of Vertical Total (3d4h index 6)
|
||||
1 Bit 8 of Vertical Display End (3d4h index 12h)
|
||||
2 Bit 8 of Vertical Retrace Start (3d4h index 10h)
|
||||
3 Bit 8 of Start Vertical Blanking (3d4h index 15h)
|
||||
4 Bit 8 of Line Compare Register (3d4h index 18h)
|
||||
5 (VGA) Bit 9 of Vertical Total (3d4h index 6)
|
||||
6 (VGA) Bit 9 of Vertical Display End (3d4h index 12h)
|
||||
7 (VGA) Bit 9 of Vertical Retrace Start (3d4h index 10h)
|
||||
|
||||
3d4h index 8 (r/W): CRTC: Preset Row Scan Register
|
||||
bit 0-4 Number of lines we have scrolled down in the first character row.
|
||||
Provides Smooth Vertical Scrolling.
|
||||
5-6 (VGA Only) Number of bytes to skip at the start of scanline. Provides
|
||||
Smooth Horizontal Scrolling together with the Horizontal Panning
|
||||
Register (3C0h index 13h).
|
||||
|
||||
3d4h index 9 (r/W): CRTC: Maximum Scan Line Register
|
||||
bit 0-4 Number of scan lines in a character row -1. In graphics modes this is
|
||||
the number of times (-1) the line is displayed before passing on to
|
||||
the next line (0: normal, 1: double, 2: triple...).
|
||||
This is independent of bit 7, except in CGA modes which seems to
|
||||
require this field to be 1 and bit 7 to be set to work.
|
||||
5 (VGA) Bit 9 of Start Vertical Blanking
|
||||
6 (VGA) Bit 9 of Line Compare Register
|
||||
7 (VGA) Doubles each scan line if set.
|
||||
I.e. displays 200 lines on a 400 display.
|
||||
|
||||
3d4h index Ah (r/W): CRTC: Cursor Start Register
|
||||
bit 0-4 First scanline of cursor within character.
|
||||
5 (VGA) Turns Cursor off if set
|
||||
|
||||
3d4h index Bh (r/W): CRTC: Cursor End Register
|
||||
bit 0-4 Last scanline of cursor within character
|
||||
5-6 Delay of cursor data in character clocks.
|
||||
|
||||
3d4h index Ch (r/W): CRTC: Start Address High Register
|
||||
bit 0-7 Upper 8 bits of the start address of the display buffer
|
||||
|
||||
3d4h index Dh (r/W): CRTC: Start Address Low Register
|
||||
bit 0-7 Lower 8 bits of the start address of the display buffer
|
||||
|
||||
3d4h index Eh (r/W): CRTC: Cursor Location High Register
|
||||
bit 0-7 Upper 8 bits of the address of the cursor
|
||||
|
||||
3d4h index Fh (r/W): CRTC: Cursor Location Low Register
|
||||
bit 0-7 Lower 8 bits of the address of the cursor
|
||||
|
||||
3d4h index 10h (R): CRTC: Light Pen High Register (EGA Only)
|
||||
bit 0-7 (EGA Only) Upper 8 bits of the address of the lightpen position.
|
||||
|
||||
3d4h index 10h (r/W): CRTC: Vertical Retrace Start Register
|
||||
bit 0-7 Lower 8 bits of Vertical Retrace Start. Vertical Retrace starts when
|
||||
the line counter reaches this value. Bit 8 is found in 3d4h index 7
|
||||
bit 2. (VGA Only) Bit 9 is found in 3d4h index 7 bit 7.
|
||||
|
||||
3d4h index 11h (R): CRTC: Light Pen Low Register (EGA Only)
|
||||
bit 0-7 (EGA Only) Lower 8 bits of the address of the lightpen position.
|
||||
|
||||
3d4h index 11h (r/W): CRTC: Vertical Retrace End Register
|
||||
bit 0-3 Vertical Retrace ends when the last 4 bits of the line counter equals
|
||||
this value.
|
||||
4 if clear Clears pending Vertical Interrupts.
|
||||
5 Vertical Interrupts (IRQ 2) disabled if set. Can usually be left
|
||||
disabled, but some systems (including PS/2) require it to be enabled.
|
||||
6 (VGA Only) If set selects 5 refresh cycles per scanline rather
|
||||
than 3.
|
||||
7 (VGA Only) Disables writing to registers 0-7 if set 3d4h index 7
|
||||
bit 4 is not affected by this bit.
|
||||
|
||||
3d4h index 12h (r/W): CRTC: Vertical Display End Register
|
||||
bit 0-7 Lower 8 bits of Vertical Display End. The display ends when the line
|
||||
counter reaches this value. Bit 8 is found in 3d4h index 7 bit 1.
|
||||
(VGA Only) Bit 9 is found in 3d4h index 7 bit 6.
|
||||
|
||||
3d4h index 13h (r/W): CRTC: Offset register
|
||||
bit 0-7 Number of bytes in a scanline / K. Where K is 2 for byte mode, 4 for
|
||||
word mode and 8 for Double Word mode.
|
||||
|
||||
3d4h index 14h (r/W): CRTC: Underline Location Register
|
||||
bit 0-4 Position of underline within Character cell.
|
||||
5 (VGA Only) If set memory address is only changed every fourth
|
||||
character clock.
|
||||
6 (VGA Only) Double Word mode addressing if set
|
||||
|
||||
3d4h index 15h (r/W): CRTC: Start Vertical Blank Register
|
||||
bit 0-7 Lower 8 bits of Vertical Blank Start. Vertical blanking starts when
|
||||
the line counter reaches this value. Bit 8 is found in 3d4h index 7
|
||||
bit 3.
|
||||
|
||||
3d4h index 16h (r/W): CRTC: End Vertical Blank Register
|
||||
bit 0-4 (EGA) Vertical blanking stops when the lower 5 bits of the line
|
||||
counter equals this field.
|
||||
0-6 (VGA) Vertical blanking stops when the lower 7 bits of the line
|
||||
counter equals this field.
|
||||
|
||||
3d4h index 17h (r/W): CRTC: Mode Control Register
|
||||
bit 0 If clear use CGA compatible memory addressing system
|
||||
by substituting character row scan counter bit 0 for address bit 13,
|
||||
thus creating 2 banks for even and odd scan lines.
|
||||
1 If clear use Hercules compatible memory addressing system by
|
||||
substituting character row scan counter bit 1 for address bit 14,
|
||||
thus creating 4 banks.
|
||||
2 If set increase scan line counter only every second line.
|
||||
3 If set increase memory address counter only every other character
|
||||
clock.
|
||||
4 (EGA Only) If set disable the EGA output drivers. This bit is used
|
||||
for other purposes in some Super VGA chips.
|
||||
5 When in Word Mode bit 15 is rotated to bit 0 if this bit is set else
|
||||
bit 13 is rotated into bit 0.
|
||||
6 If clear system is in word mode. Addresses are rotated 1 position up
|
||||
bringing either bit 13 or 15 into bit 0.
|
||||
7 Clearing this bit will reset the display system until the bit is set
|
||||
again.
|
||||
|
||||
3d4h index 18h (r/W): CRTC: Line Compare Register
|
||||
bit 0-7 Lower 8 bits of the Line Compare. When the Line counter reaches this
|
||||
value, the display address wraps to 0. Provides Split Screen
|
||||
facilities. Bit 8 is found in 3d4h index 7 bit 4.
|
||||
(VGA Only) Bit 9 is found in 3d4h index 9 bit 6.
|
||||
|
||||
3d4h index 22h (R): Memory Latch Register (VGA - Undoc)
|
||||
bit 0-7 Reads the contents of the Graphics Controller Memory Data Latch for
|
||||
the plane selected by 3C0h index 4 bit 0-1 (Read Map Select).
|
||||
Note: This register is not documented by IBM and may not be available on all
|
||||
clones.
|
||||
|
||||
3d4h index 24h (R): Attribute Controller Toggle Register. (VGA - Undoc)
|
||||
bit 0-4 Attribute Controller Index.
|
||||
The current value of the Attribute Index Register.
|
||||
5 Palette Address Source. Same as 3C0h bit 5.
|
||||
7 If set next read or write to 3C0h will access the data register.
|
||||
Note: This register is not documented by IBM and may not be available on all
|
||||
clones.
|
||||
|
||||
3d4h index 30h-3Fh (W): Clear Vertical Display Enable. (VGA - Undoc)
|
||||
bit 0 Setting this bit will clear the Vertical Display Enable thus blanking
|
||||
the display for the rest of the frame and giving the CPU total access
|
||||
to display memory until the start of the next frame.
|
||||
Note: This register is not documented by IBM and may not be available on all
|
||||
clones.
|
||||
|
||||
3dAh (R): Input Status #1 Register
|
||||
bit 0 Either Vertical or Horizontal Retrace active if set
|
||||
1 (EGA Only) Light Pen has triggered if set
|
||||
2 (EGA Only) Light Pen switch is open if set
|
||||
3 Vertical Retrace in progress if set
|
||||
4-5 (EGA Only) Shows two of the 6 color outputs, depending on 3C0h index
|
||||
12h bit 4-5:
|
||||
Attr: Bit 4-5: Out bit 4 Out bit 5
|
||||
0 Blue Red
|
||||
1 I Blue Green
|
||||
2 I Red I Green
|
||||
|
||||
3dAh (W): Feature Control Register
|
||||
bit 0 (EGA Only) Output to pin 21 of the Feature Connector.
|
||||
1 (EGA Only) Output to pin 20 of the Feature Connector.
|
||||
3 (VGA Only) Vertical Sync Select. If set Vertical Sync to the monitor
|
||||
is the logical OR of the vertical sync and the vertical display
|
||||
enable.
|
||||
Note: On the VGA this register can be read from port 3CAh.
|
233
examples/7segment.cpp
Normal file
233
examples/7segment.cpp
Normal file
@ -0,0 +1,233 @@
|
||||
/***********************************************************************
|
||||
* 7segment.cpp - Seven-segment display *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2012-2019 Markus Gans *
|
||||
* *
|
||||
* The 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. *
|
||||
* *
|
||||
* The 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 <map>
|
||||
#include <vector>
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FColorPair;
|
||||
using finalcut::FRect;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class TextWindow
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class SegmentView : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
explicit SegmentView (finalcut::FWidget* = nullptr);
|
||||
|
||||
private:
|
||||
// Typedef
|
||||
typedef struct
|
||||
{
|
||||
unsigned char a : 1;
|
||||
unsigned char b : 1;
|
||||
unsigned char c : 1;
|
||||
unsigned char d : 1;
|
||||
unsigned char e : 1;
|
||||
unsigned char f : 1;
|
||||
unsigned char g : 1;
|
||||
unsigned char : 1; // padding bit
|
||||
} sevenSegment;
|
||||
|
||||
// Methods
|
||||
void hexEncoding();
|
||||
void get7Segment (const wchar_t);
|
||||
void draw() override;
|
||||
|
||||
// Data members
|
||||
std::map<wchar_t, sevenSegment> code{};
|
||||
finalcut::FString line[3];
|
||||
finalcut::FLineEdit Input{"0123", this};
|
||||
finalcut::FButton Exit{"E&xit", this};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
SegmentView::SegmentView (finalcut::FWidget* parent)
|
||||
: FDialog(parent)
|
||||
{
|
||||
// Set encoding
|
||||
hexEncoding();
|
||||
|
||||
// Dialog settings
|
||||
setText ("Seven-segment display");
|
||||
setGeometry (FPoint(25, 5), FSize(42, 15));
|
||||
|
||||
// Input field
|
||||
Input.setGeometry (FPoint(2, 2), FSize(12, 1));
|
||||
Input.setLabelText (L"&Hex value");
|
||||
Input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)");
|
||||
Input.setLabelOrientation(finalcut::FLineEdit::label_above);
|
||||
Input.setMaxLength(9);
|
||||
Input.setInputFilter("[:.hHlLpPuU[:xdigit:]]");
|
||||
|
||||
// Exit button
|
||||
Exit.setGeometry(FPoint(28, 11), FSize(10, 1));
|
||||
|
||||
// Add some function callbacks
|
||||
Input.addCallback
|
||||
(
|
||||
"changed",
|
||||
[] (finalcut::FWidget*, FDataPtr data)
|
||||
{
|
||||
auto dialog = static_cast<SegmentView*>(data);
|
||||
dialog->redraw();
|
||||
},
|
||||
this
|
||||
);
|
||||
|
||||
Exit.addCallback
|
||||
(
|
||||
"clicked",
|
||||
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp)
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void SegmentView::hexEncoding()
|
||||
{
|
||||
code['0'] = sevenSegment{1, 1, 1, 1, 1, 1, 0};
|
||||
code['1'] = sevenSegment{0, 1, 1, 0, 0, 0, 0};
|
||||
code['2'] = sevenSegment{1, 1, 0, 1, 1, 0, 1};
|
||||
code['3'] = sevenSegment{1, 1, 1, 1, 0, 0, 1};
|
||||
code['4'] = sevenSegment{0, 1, 1, 0, 0, 1, 1};
|
||||
code['5'] = sevenSegment{1, 0, 1, 1, 0, 1, 1};
|
||||
code['6'] = sevenSegment{1, 0, 1, 1, 1, 1, 1};
|
||||
code['7'] = sevenSegment{1, 1, 1, 0, 0, 0, 0};
|
||||
code['8'] = sevenSegment{1, 1, 1, 1, 1, 1, 1};
|
||||
code['9'] = sevenSegment{1, 1, 1, 1, 0, 1, 1};
|
||||
code['A'] = sevenSegment{1, 1, 1, 0, 1, 1, 1};
|
||||
code['B'] = sevenSegment{0, 0, 1, 1, 1, 1, 1};
|
||||
code['C'] = sevenSegment{1, 0, 0, 1, 1, 1, 0};
|
||||
code['D'] = sevenSegment{0, 1, 1, 1, 1, 0, 1};
|
||||
code['E'] = sevenSegment{1, 0, 0, 1, 1, 1, 1};
|
||||
code['F'] = sevenSegment{1, 0, 0, 0, 1, 1, 1};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void SegmentView::get7Segment (const wchar_t c)
|
||||
{
|
||||
for (int i{0}; i < 3; i++)
|
||||
line[i].clear();
|
||||
|
||||
switch ( c )
|
||||
{
|
||||
case ':':
|
||||
line[0] = ' ';
|
||||
line[1] = '.';
|
||||
line[2] = '.';
|
||||
break;
|
||||
|
||||
case '.':
|
||||
line[0] = ' ';
|
||||
line[1] = ' ';
|
||||
line[2] = '.';
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
line[0] = " ";
|
||||
line[1] = "|_|";
|
||||
line[2] = "| |";
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
line[0] = " ";
|
||||
line[1] = "| ";
|
||||
line[2] = "|_ ";
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
line[0] = " _ ";
|
||||
line[1] = "|_|";
|
||||
line[2] = "| ";
|
||||
break;
|
||||
|
||||
case 'U':
|
||||
line[0] = " ";
|
||||
line[1] = "| |";
|
||||
line[2] = "|_|";
|
||||
break;
|
||||
|
||||
default:
|
||||
// Hexadecimal digit from 0 up to f
|
||||
if ( code.find(c) != code.end() )
|
||||
{
|
||||
sevenSegment& s = code[c];
|
||||
constexpr char h[2]{' ', '_'};
|
||||
constexpr char v[2]{' ', '|'};
|
||||
|
||||
line[0] << ' ' << h[s.a] << ' ';
|
||||
line[1] << v[s.f] << h[s.g] << v[s.b];
|
||||
line[2] << v[s.e] << h[s.d] << v[s.c];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void SegmentView::draw()
|
||||
{
|
||||
std::vector<finalcut::FTermBuffer> tbuffer{3};
|
||||
finalcut::FTermBuffer left_space{};
|
||||
|
||||
FDialog::draw();
|
||||
setColor(fc::LightGray, fc::Black);
|
||||
finalcut::drawBorder(this, FRect(FPoint(3, 6), FPoint(40, 11)));
|
||||
|
||||
for (auto&& ch : Input.getText().toUpper())
|
||||
{
|
||||
FColorPair color(fc::LightRed, fc::Black);
|
||||
get7Segment(ch);
|
||||
|
||||
for (std::size_t i{0}; i < 3; i++)
|
||||
tbuffer[i] << color << line[i] << " ";
|
||||
}
|
||||
|
||||
std::size_t length = tbuffer[0].getLength();
|
||||
|
||||
if ( length < 36 )
|
||||
left_space << finalcut::FString(36 - length, ' ');
|
||||
|
||||
print() << FPoint (4, 7) << left_space << tbuffer[0]
|
||||
<< FPoint (4, 8) << left_space << tbuffer[1]
|
||||
<< FPoint (4, 9) << left_space << tbuffer[2]
|
||||
<< FPoint (4, 10) << finalcut::FString(36, ' ');
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// main part
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
finalcut::FApplication app(argc, argv);
|
||||
SegmentView dialog(&app);
|
||||
app.setMainWidget(&dialog);
|
||||
dialog.show();
|
||||
return app.exec();
|
||||
}
|
@ -11,6 +11,8 @@ noinst_PROGRAMS = \
|
||||
hello \
|
||||
dialog \
|
||||
input-dialog \
|
||||
fullwidth-character \
|
||||
7segment \
|
||||
choice \
|
||||
listbox \
|
||||
listview \
|
||||
@ -35,6 +37,8 @@ noinst_PROGRAMS = \
|
||||
hello_SOURCES = hello.cpp
|
||||
dialog_SOURCES = dialog.cpp
|
||||
input_dialog_SOURCES = input-dialog.cpp
|
||||
fullwidth_character_SOURCES = fullwidth-character.cpp
|
||||
7segment_SOURCES = 7segment.cpp
|
||||
choice_SOURCES = choice.cpp
|
||||
listbox_SOURCES = listbox.cpp
|
||||
listview_SOURCES = listview.cpp
|
||||
|
@ -29,7 +29,7 @@ endif
|
||||
all: $(OBJS)
|
||||
|
||||
debug:
|
||||
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -Wall -Wextra -Wpedantic -Weverything -Wpadded -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-implicit-fallthrough -Wno-reserved-id-macro"
|
||||
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -Wall -Wextra -Wpedantic -Weverything -Wno-padded -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-implicit-fallthrough -Wno-reserved-id-macro"
|
||||
|
||||
profile:
|
||||
$(MAKE) $(MAKEFILE) PROFILE="-pg"
|
||||
|
@ -30,20 +30,18 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
using finalcut::FColorPair;
|
||||
|
||||
constexpr lDouble PI = 3.141592653589793238L;
|
||||
constexpr lDouble PI{3.141592653589793238L};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class Button
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Button : public finalcut::FButton
|
||||
{
|
||||
public:
|
||||
@ -54,13 +52,12 @@ class Button : public finalcut::FButton
|
||||
void setChecked(bool);
|
||||
|
||||
// Event handler
|
||||
virtual void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
|
||||
private:
|
||||
// Data Member
|
||||
// Data member
|
||||
bool checked{false};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Button::Button (finalcut::FWidget* parent)
|
||||
@ -77,12 +74,13 @@ void Button::setChecked (bool enable)
|
||||
|
||||
if ( checked )
|
||||
{
|
||||
setBackgroundColor(finalcut::fc::Cyan);
|
||||
setFocusForegroundColor(finalcut::fc::White);
|
||||
setFocusBackgroundColor(finalcut::fc::Cyan);
|
||||
setBackgroundColor(fc::Cyan);
|
||||
setFocusForegroundColor(fc::White);
|
||||
setFocusBackgroundColor(fc::Cyan);
|
||||
}
|
||||
else
|
||||
{
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
setBackgroundColor(wc.button_active_bg);
|
||||
setFocusForegroundColor(wc.button_active_focus_fg);
|
||||
setFocusBackgroundColor(wc.button_active_focus_bg);
|
||||
@ -97,8 +95,7 @@ void Button::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
FKey key = ev->key();
|
||||
|
||||
// catch the enter key
|
||||
if ( key == finalcut::fc::Fkey_return
|
||||
|| key == finalcut::fc::Fkey_enter )
|
||||
if ( key == fc::Fkey_return || key == fc::Fkey_enter )
|
||||
return;
|
||||
|
||||
finalcut::FButton::onKeyPress(ev);
|
||||
@ -109,9 +106,6 @@ void Button::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
// class Calc
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Calc : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -122,8 +116,8 @@ class Calc : public finalcut::FDialog
|
||||
~Calc();
|
||||
|
||||
// Event handlers
|
||||
virtual void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Callback method
|
||||
void cb_buttonClicked (finalcut::FWidget*, FDataPtr);
|
||||
@ -173,7 +167,7 @@ class Calc : public finalcut::FDialog
|
||||
|
||||
// Methods
|
||||
void drawDispay();
|
||||
virtual void draw() override;
|
||||
void draw() override;
|
||||
void clear (lDouble&);
|
||||
void zero (lDouble&);
|
||||
void one (lDouble&);
|
||||
@ -215,11 +209,11 @@ class Calc : public finalcut::FDialog
|
||||
void setInfixOperator (char);
|
||||
void clearInfixOperator();
|
||||
void calcInfixOperator();
|
||||
virtual void adjustSize() override;
|
||||
void adjustSize() override;
|
||||
const wchar_t* getButtonText (std::size_t);
|
||||
void mapKeyFunctions();
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
bool error{false};
|
||||
bool arcus_mode{false};
|
||||
bool hyperbolic_mode{false};
|
||||
@ -243,7 +237,6 @@ class Calc : public finalcut::FDialog
|
||||
std::map<Calc::button, std::shared_ptr<Button> > calculator_buttons{};
|
||||
std::map<Calc::button, keyFunction> key_map{};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Calc::Calc (FWidget* parent)
|
||||
@ -255,7 +248,7 @@ Calc::Calc (FWidget* parent)
|
||||
setText ("Calculator");
|
||||
setGeometry (FPoint(19, 6), FSize(37, 18));
|
||||
|
||||
for (std::size_t key = 0; key < Calc::NUM_OF_BUTTONS; key++)
|
||||
for (std::size_t key{0}; key < Calc::NUM_OF_BUTTONS; key++)
|
||||
{
|
||||
auto btn = std::make_shared<Button>(this);
|
||||
button_no[key] = key;
|
||||
@ -264,19 +257,17 @@ Calc::Calc (FWidget* parent)
|
||||
btn->setGeometry(FPoint(30, 15), FSize(5, 3));
|
||||
else
|
||||
{
|
||||
int x, y;
|
||||
std::size_t n;
|
||||
( key <= Three ) ? n = 0 : n = 1;
|
||||
x = int(key + n) % 5 * 7 + 2;
|
||||
y = int(key + n) / 5 * 2 + 3;
|
||||
std::size_t n = ( key <= Three ) ? 0 : 1;
|
||||
int x = int(key + n) % 5 * 7 + 2;
|
||||
int y = int(key + n) / 5 * 2 + 3;
|
||||
btn->setGeometry(FPoint(x, y), FSize(5, 1));
|
||||
}
|
||||
|
||||
btn->setFlat();
|
||||
btn->setNoUnderline();
|
||||
btn->setText(getButtonText(key));
|
||||
btn->setDoubleFlatLine(finalcut::fc::top);
|
||||
btn->setDoubleFlatLine(finalcut::fc::bottom);
|
||||
btn->setDoubleFlatLine(fc::top);
|
||||
btn->setDoubleFlatLine(fc::bottom);
|
||||
|
||||
if ( isNewFont() )
|
||||
btn->unsetClickAnimation();
|
||||
@ -291,7 +282,7 @@ Calc::Calc (FWidget* parent)
|
||||
calculator_buttons[button(key)] = btn;
|
||||
}
|
||||
|
||||
calculator_buttons[On]->addAccelerator(finalcut::fc::Fkey_dc); // Del key
|
||||
calculator_buttons[On]->addAccelerator(fc::Fkey_dc); // Del key
|
||||
calculator_buttons[On]->setFocus();
|
||||
calculator_buttons[Pi]->addAccelerator('p');
|
||||
calculator_buttons[Power]->addAccelerator('^');
|
||||
@ -300,8 +291,8 @@ Calc::Calc (FWidget* parent)
|
||||
calculator_buttons[Multiply]->addAccelerator('*');
|
||||
calculator_buttons[Decimal_point]->addAccelerator(',');
|
||||
calculator_buttons[Change_sign]->addAccelerator('#');
|
||||
calculator_buttons[Equals]->addAccelerator(finalcut::fc::Fkey_return);
|
||||
calculator_buttons[Equals]->addAccelerator(finalcut::fc::Fkey_enter);
|
||||
calculator_buttons[Equals]->addAccelerator(fc::Fkey_return);
|
||||
calculator_buttons[Equals]->addAccelerator(fc::Fkey_enter);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -311,7 +302,7 @@ Calc::~Calc()
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::drawDispay()
|
||||
{
|
||||
finalcut::FString display = input;
|
||||
finalcut::FString display(input);
|
||||
|
||||
if ( display.isNull() || display.isEmpty() )
|
||||
display = L'0';
|
||||
@ -337,7 +328,8 @@ void Calc::drawDispay()
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
print() << FColorPair(finalcut::fc::Black, finalcut::fc::LightGray)
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
print() << FColorPair(fc::Black, fc::LightGray)
|
||||
<< FPoint(3, 3) << display << ' '
|
||||
<< FColorPair(wc.dialog_fg, wc.dialog_bg);
|
||||
|
||||
@ -346,11 +338,11 @@ void Calc::drawDispay()
|
||||
|
||||
if ( isNewFont() )
|
||||
{
|
||||
wchar_t bottom_line = finalcut::fc::NF_border_line_bottom;
|
||||
wchar_t top_bottom_line = finalcut::fc::NF_border_line_up_and_down;
|
||||
wchar_t top_line = finalcut::fc::NF_border_line_upper;
|
||||
wchar_t right_line = finalcut::fc::NF_rev_border_line_right;
|
||||
wchar_t left_line = finalcut::fc::NF_border_line_left;
|
||||
wchar_t bottom_line {fc::NF_border_line_bottom};
|
||||
wchar_t top_bottom_line {fc::NF_border_line_up_and_down};
|
||||
wchar_t top_line {fc::NF_border_line_upper};
|
||||
wchar_t right_line {fc::NF_rev_border_line_right};
|
||||
wchar_t left_line {fc::NF_border_line_left};
|
||||
print() << FPoint(3, 2) << finalcut::FString(33, bottom_line);
|
||||
print() << FPoint(2, 3) << right_line;
|
||||
print() << FPoint(36, 3) << left_line;
|
||||
@ -365,12 +357,12 @@ void Calc::drawDispay()
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t vertical_and_right = finalcut::fc::BoxDrawingsVerticalAndRight;
|
||||
wchar_t horizontal = finalcut::fc::BoxDrawingsHorizontal;
|
||||
wchar_t vertical_and_left = finalcut::fc::BoxDrawingsVerticalAndLeft;
|
||||
finalcut::FString separator = finalcut::FString(vertical_and_right)
|
||||
wchar_t vertical_and_right {fc::BoxDrawingsVerticalAndRight};
|
||||
wchar_t horizontal {fc::BoxDrawingsHorizontal};
|
||||
wchar_t vertical_and_left {fc::BoxDrawingsVerticalAndLeft};
|
||||
finalcut::FString separator ( finalcut::FString(vertical_and_right)
|
||||
+ finalcut::FString(35, horizontal)
|
||||
+ finalcut::FString(vertical_and_left);
|
||||
+ finalcut::FString(vertical_and_left) );
|
||||
print() << FPoint(1, 4) << separator;
|
||||
}
|
||||
}
|
||||
@ -609,7 +601,7 @@ void Calc::pi (lDouble& x)
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::open_bracket (lDouble&)
|
||||
{
|
||||
stack_data d = { a, infix_operator };
|
||||
stack_data d{ a, infix_operator };
|
||||
bracket_stack.push(d);
|
||||
clearInfixOperator();
|
||||
input = "";
|
||||
@ -838,8 +830,8 @@ void Calc::tangent (lDouble& x)
|
||||
void Calc::draw()
|
||||
{
|
||||
setBold();
|
||||
setColor (finalcut::fc::Blue, finalcut::fc::Cyan);
|
||||
clearArea (vdesktop, finalcut::fc::MediumShade);
|
||||
setColor (fc::LightBlue, fc::Cyan);
|
||||
clearArea (getVirtualDesktop(), fc::MediumShade);
|
||||
unsetBold();
|
||||
finalcut::FDialog::draw();
|
||||
drawDispay();
|
||||
@ -906,7 +898,7 @@ lDouble& Calc::getValue()
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::setDisplay (lDouble d)
|
||||
{
|
||||
char buffer[33];
|
||||
char buffer[33]{};
|
||||
snprintf (buffer, sizeof(buffer), "%32.11Lg", d);
|
||||
input = buffer;
|
||||
}
|
||||
@ -995,8 +987,8 @@ void Calc::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
|
||||
switch ( key )
|
||||
{
|
||||
case finalcut::fc::Fkey_erase:
|
||||
case finalcut::fc::Fkey_backspace:
|
||||
case fc::Fkey_erase:
|
||||
case fc::Fkey_backspace:
|
||||
if ( len > 0 )
|
||||
{
|
||||
lDouble& x = getValue();
|
||||
@ -1019,10 +1011,10 @@ void Calc::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case finalcut::fc::Fkey_escape:
|
||||
case finalcut::fc::Fkey_escape_mintty:
|
||||
case fc::Fkey_escape:
|
||||
case fc::Fkey_escape_mintty:
|
||||
{
|
||||
finalcut::FAccelEvent a_ev( finalcut::fc::Accelerator_Event
|
||||
finalcut::FAccelEvent a_ev( fc::Accelerator_Event
|
||||
, getFocusWidget() );
|
||||
calculator_buttons[On]->onAccel(&a_ev);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -35,9 +36,6 @@ using finalcut::FSize;
|
||||
// class CheckList
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class CheckList : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -58,17 +56,16 @@ class CheckList : public finalcut::FDialog
|
||||
void populate();
|
||||
|
||||
// Event handlers
|
||||
virtual void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Callback method
|
||||
void cb_showList (finalcut::FWidget*, FDataPtr);
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
finalcut::FListView listView{this};
|
||||
finalcut::FStatusBar status_bar{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
CheckList::CheckList (finalcut::FWidget* parent)
|
||||
@ -76,22 +73,22 @@ CheckList::CheckList (finalcut::FWidget* parent)
|
||||
{
|
||||
setText (L"Shopping list");
|
||||
setShadow();
|
||||
setGeometry ( FPoint(int(1 + (parent->getWidth() - 30) / 2), 5)
|
||||
, FSize(30, 13) );
|
||||
setGeometry ( FPoint(int(1 + (parent->getWidth() - 28) / 2), 5)
|
||||
, FSize(28, 13) );
|
||||
listView.ignorePadding();
|
||||
listView.setGeometry (FPoint(1, 2), FSize(getWidth(), getHeight() - 1));
|
||||
|
||||
// Add columns to the view
|
||||
listView.addColumn ("Item");
|
||||
listView.addColumn ("Priority", 12);
|
||||
listView.addColumn ("Priority", 9);
|
||||
|
||||
// Set the type of sorting
|
||||
listView.setColumnSortType (1, finalcut::fc::by_name);
|
||||
listView.setColumnSortType (2, finalcut::fc::by_name);
|
||||
listView.setColumnSortType (1, fc::by_name);
|
||||
listView.setColumnSortType (2, fc::by_name);
|
||||
|
||||
// Statusbar at the bottom
|
||||
finalcut::FString separator;
|
||||
separator << ' ' << finalcut::fc::BoxDrawingsVertical << ' ';
|
||||
separator << ' ' << fc::BoxDrawingsVertical << ' ';
|
||||
listView.setStatusbarMessage ( finalcut::FString()
|
||||
<< "<Q> exit" << separator
|
||||
<< "<Space> select an item" << separator
|
||||
@ -131,7 +128,7 @@ void CheckList::populate()
|
||||
|
||||
constexpr int lastItem = int(sizeof(list) / sizeof(list[0])) - 1;
|
||||
|
||||
for (int i = 0; i <= lastItem; i++)
|
||||
for (int i{0}; i <= lastItem; i++)
|
||||
{
|
||||
const finalcut::FStringList line (&list[i][0], &list[i][0] + 2);
|
||||
auto iter = listView.insert (line);
|
||||
@ -147,8 +144,8 @@ void CheckList::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
return;
|
||||
|
||||
if ( ev->key() == 'q'
|
||||
|| ev->key() == finalcut::fc::Fkey_escape
|
||||
|| ev->key() == finalcut::fc::Fkey_escape_mintty )
|
||||
|| ev->key() == fc::Fkey_escape
|
||||
|| ev->key() == fc::Fkey_escape_mintty )
|
||||
{
|
||||
close();
|
||||
ev->accept();
|
||||
@ -174,7 +171,7 @@ void CheckList::cb_showList (finalcut::FWidget*, FDataPtr)
|
||||
const auto item = static_cast<finalcut::FListViewItem*>(*iter);
|
||||
|
||||
if ( item->isChecked() )
|
||||
shopping_list << finalcut::fc::Bullet << ' '
|
||||
shopping_list << fc::Bullet << ' '
|
||||
<< item->getText(1) << '\n';
|
||||
|
||||
++iter;
|
||||
|
@ -20,6 +20,7 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <final/final.h>
|
||||
|
||||
@ -96,7 +97,7 @@ void preset (std::vector<FRadioButtonPtr>& os)
|
||||
//----------------------------------------------------------------------
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
finalcut::FString label_text = "no OS";
|
||||
finalcut::FString label_text("no OS");
|
||||
|
||||
// Create the application object
|
||||
finalcut::FApplication app(argc, argv);
|
||||
@ -105,8 +106,8 @@ int main (int argc, char* argv[])
|
||||
finalcut::FDialog dgl(&app);
|
||||
dgl.setModal();
|
||||
dgl.setText ("UNIX select");
|
||||
std::size_t w = 20;
|
||||
std::size_t h = 13;
|
||||
std::size_t w{20};
|
||||
std::size_t h{13};
|
||||
int x = int(app.getDesktopWidth() - w) / 2;
|
||||
int y = int(app.getDesktopHeight() - h) / 2;
|
||||
dgl.setGeometry (FPoint(x, y), FSize(w, h));
|
||||
@ -122,7 +123,7 @@ int main (int argc, char* argv[])
|
||||
// Set the radio button geometry
|
||||
// => checkButtonGroup.setScrollSize(...) is not required
|
||||
// because a FButtonGroup is self-adjusting
|
||||
for (uInt i = 0; i < os.size(); i++)
|
||||
for (uInt i{0}; i < os.size(); i++)
|
||||
os[i]->setGeometry(FPoint(1, int(1 + i)), FSize(12, 1));
|
||||
|
||||
preset(os);
|
||||
@ -147,7 +148,7 @@ int main (int argc, char* argv[])
|
||||
dgl.show();
|
||||
|
||||
// Get the checked radio button text
|
||||
for (int n = 1; n <= int(checkButtonGroup.getCount()); n++)
|
||||
for (int n{1}; n <= int(checkButtonGroup.getCount()); n++)
|
||||
{
|
||||
if ( checkButtonGroup.isChecked(n) )
|
||||
{
|
||||
|
137
examples/fullwidth-character.cpp
Normal file
137
examples/fullwidth-character.cpp
Normal file
@ -0,0 +1,137 @@
|
||||
/***********************************************************************
|
||||
* fullwidth-letter.cpp - Demonstrates use of full-width characters *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2019 Markus Gans *
|
||||
* *
|
||||
* The 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. *
|
||||
* *
|
||||
* The 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/final.h>
|
||||
|
||||
#define full(...) finalcut::getFullWidth(__VA_ARGS__)
|
||||
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// main part
|
||||
//----------------------------------------------------------------------
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
// Create the application object
|
||||
finalcut::FApplication app(argc, argv);
|
||||
|
||||
// Create a simple dialog box
|
||||
finalcut::FDialog dgl(&app);
|
||||
dgl.setText (full("Dialog"));
|
||||
dgl.setSize (FSize(37, 16));
|
||||
dgl.setPos (FPoint( int(app.getDesktopWidth() - dgl.getWidth()) / 2
|
||||
, int(app.getDesktopHeight() - dgl.getHeight()) / 2));
|
||||
dgl.setShadow();
|
||||
|
||||
// Create input fields
|
||||
finalcut::FLineEdit field1 (&dgl);
|
||||
field1.setLabelText (full("Input"));
|
||||
field1.setText (L"你好"); // Nǐ hǎo (chinese)
|
||||
field1.setStatusbarMessage (full("Type your text here"));
|
||||
field1.setGeometry (FPoint(15, 1), FSize(19, 1));
|
||||
|
||||
finalcut::FLineEdit field2 (&dgl);
|
||||
field2.setLabelText (L"Comment");
|
||||
field2.setText (full(L"Hello"));
|
||||
field2.setStatusbarMessage (full("Post a comment"));
|
||||
field2.setGeometry (FPoint(15, 3), FSize(19, 1));
|
||||
|
||||
// Create the button group
|
||||
finalcut::FButtonGroup group (full("Side"), &dgl);
|
||||
group.setGeometry(FPoint(2, 5), FSize(32, 3));
|
||||
|
||||
// Create radio buttons
|
||||
finalcut::FRadioButton left ("&" + full("Left"), &group);
|
||||
finalcut::FRadioButton right ("&" + full("Right"), &group);
|
||||
left.setStatusbarMessage (full("Prefer the left side"));
|
||||
right.setStatusbarMessage (full("Prefer the right side"));
|
||||
left.setGeometry (FPoint(1, 1), FSize(8, 1));
|
||||
right.setGeometry (FPoint(15, 1), FSize(10, 1));
|
||||
|
||||
// Create a scrollable text field
|
||||
finalcut::FTextView scroll_text (&dgl);
|
||||
scroll_text.setGeometry (FPoint(2, 8), FSize(32, 3));
|
||||
finalcut::FString text_line{"FINAL CUT supports "
|
||||
"full-width characters."};
|
||||
scroll_text.setStatusbarMessage ("You can scroll right and "
|
||||
"left with the arrow keys");
|
||||
scroll_text.append(full(text_line));
|
||||
|
||||
// Create a OK button
|
||||
finalcut::FButton btn("&OK", &dgl);
|
||||
btn.setStatusbarMessage (full("Press Enter to exit the dialog"));
|
||||
btn.setGeometry (FPoint(24, 12), FSize(10, 1));
|
||||
|
||||
// Create the status bar
|
||||
finalcut::FStatusBar sbar(&dgl);
|
||||
finalcut::FStatusKey key_F1 (finalcut::fc::Fkey_f1, "Info", &sbar);
|
||||
|
||||
// Create the menu bar
|
||||
finalcut::FMenuBar Menubar(&dgl);
|
||||
|
||||
// Create menu bar items
|
||||
finalcut::FMenu File{L"&File", &Menubar};
|
||||
finalcut::FMenuItem Edit{L"&Edit", &Menubar};
|
||||
finalcut::FMenuItem Exit{L"E&xit", &Menubar};
|
||||
|
||||
// Create file menu items
|
||||
finalcut::FMenuItem Open{"&Open", &File};
|
||||
finalcut::FMenuItem Print{"&Print", &File};
|
||||
finalcut::FMenuItem Line{&File};
|
||||
Line.setSeparator();
|
||||
finalcut::FMenuItem Quit{"&Quit", &File};
|
||||
Quit.addAccelerator (finalcut::fc::Fckey_q); // Ctrl + Q
|
||||
|
||||
// Callback lambda expressions
|
||||
auto cb_exit = \
|
||||
[] (finalcut::FWidget*, FDataPtr data)
|
||||
{
|
||||
auto a = static_cast<finalcut::FApplication*>(data);
|
||||
a->quit();
|
||||
};
|
||||
|
||||
auto cb_tooltip = \
|
||||
[] (finalcut::FWidget*, FDataPtr data)
|
||||
{
|
||||
auto a = static_cast<finalcut::FApplication*>(data);
|
||||
finalcut::FToolTip tooltip(a);
|
||||
tooltip.setText (full("A tooltip with\ncharacters\n"
|
||||
"in full-width\nfor 3 seconds"));
|
||||
tooltip.show();
|
||||
sleep(3);
|
||||
};
|
||||
|
||||
// Connect the signals with the callback lambda expressions
|
||||
btn.addCallback ("clicked", cb_exit, &app);
|
||||
Exit.addCallback ("clicked", cb_exit, &app);
|
||||
Quit.addCallback ("clicked", cb_exit, &app);
|
||||
key_F1.addCallback ("activate",cb_tooltip, &app);
|
||||
|
||||
// Set dialog object as main widget
|
||||
app.setMainWidget(&dgl);
|
||||
|
||||
// Show and start the application
|
||||
dgl.show();
|
||||
return app.exec();
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/***********************************************************************
|
||||
* input-dialog.cpp - an input field example *
|
||||
* input-dialog.cpp - An input field example *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
|
@ -34,27 +34,27 @@ class Keyboard : public finalcut::FWidget
|
||||
|
||||
protected:
|
||||
// Event handlers
|
||||
virtual void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
virtual void onAccel (finalcut::FAccelEvent*) override;
|
||||
void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
void onAccel (finalcut::FAccelEvent*) override;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
virtual void draw() override;
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Keyboard::Keyboard (finalcut::FWidget* parent)
|
||||
: finalcut::FWidget(parent)
|
||||
{
|
||||
wc.term_fg = finalcut::fc::Default;
|
||||
wc.term_bg = finalcut::fc::Default;
|
||||
setFWidgetColors().term_fg = finalcut::fc::Default;
|
||||
setFWidgetColors().term_bg = finalcut::fc::Default;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
{
|
||||
FKey key_id = ev->key();
|
||||
bool is_last_line = false;
|
||||
bool is_last_line{false};
|
||||
|
||||
if ( getPrintPos().getY() == int(getDesktopHeight()) )
|
||||
is_last_line = true;
|
||||
@ -63,10 +63,10 @@ void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
<< " (id " << key_id << ")\n";
|
||||
|
||||
if ( is_last_line )
|
||||
scrollAreaForward (vdesktop);
|
||||
scrollAreaForward (getVirtualDesktop());
|
||||
|
||||
setAreaCursor ( finalcut::FPoint(1, getPrintPos().getY())
|
||||
, true, vdesktop );
|
||||
, true, getVirtualDesktop() );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -83,7 +83,7 @@ void Keyboard::draw()
|
||||
<< "---------------\n"
|
||||
<< "Press Q to quit\n"
|
||||
<< "---------------\n";
|
||||
setAreaCursor (finalcut::FPoint(1, 4), true, vdesktop);
|
||||
setAreaCursor (finalcut::FPoint(1, 4), true, getVirtualDesktop());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
|
||||
#include <final/final.h>
|
||||
@ -75,9 +76,6 @@ FString& mapToString ( std::map<FString
|
||||
// class Listbox
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Listbox : public FDialog
|
||||
{
|
||||
public:
|
||||
@ -95,16 +93,15 @@ class Listbox : public FDialog
|
||||
|
||||
private:
|
||||
// Event handlers
|
||||
virtual void onClose (FCloseEvent*) override;
|
||||
void onClose (FCloseEvent*) override;
|
||||
|
||||
// Data Member
|
||||
// Data member
|
||||
std::list<double> double_list{};
|
||||
FListBox list1{this};
|
||||
FListBox list2{this};
|
||||
FListBox list3{this};
|
||||
FButton Quit{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Listbox::Listbox (FWidget* parent)
|
||||
@ -118,12 +115,12 @@ Listbox::Listbox (FWidget* parent)
|
||||
list1.setGeometry(FPoint(2, 1), FSize(18, 10));
|
||||
list1.setText ("FListBoxItem");
|
||||
|
||||
for (int i = 1; i < 30; i++)
|
||||
for (int i{1}; i < 30; i++)
|
||||
list1.insert (L"----- " + (FString() << i) + L" -----");
|
||||
|
||||
// listbox 2
|
||||
//----------
|
||||
for (double i = 1; i<=15; i++)
|
||||
for (double i{1.0}; i <= 15.0; i++)
|
||||
double_list.push_back(2 * i + (i / 100));
|
||||
|
||||
list2.setGeometry(FPoint(21, 1), FSize(10, 10));
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -35,9 +36,6 @@ using finalcut::FSize;
|
||||
// class Listview
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Listview : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -58,16 +56,15 @@ class Listview : public finalcut::FDialog
|
||||
void populate();
|
||||
|
||||
// Event handlers
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Callback method
|
||||
void cb_showInMessagebox (finalcut::FWidget*, FDataPtr);
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
finalcut::FListView listView{this};
|
||||
finalcut::FButton Quit{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Listview::Listview (finalcut::FWidget* parent)
|
||||
@ -84,19 +81,19 @@ Listview::Listview (finalcut::FWidget* parent)
|
||||
listView.addColumn ("Pressure", 10);
|
||||
|
||||
// Set right alignment for the third, fourth, and fifth column
|
||||
listView.setColumnAlignment (3, finalcut::fc::alignRight);
|
||||
listView.setColumnAlignment (4, finalcut::fc::alignRight);
|
||||
listView.setColumnAlignment (5, finalcut::fc::alignRight);
|
||||
listView.setColumnAlignment (3, fc::alignRight);
|
||||
listView.setColumnAlignment (4, fc::alignRight);
|
||||
listView.setColumnAlignment (5, fc::alignRight);
|
||||
|
||||
// Set the type of sorting
|
||||
listView.setColumnSortType (1, finalcut::fc::by_name);
|
||||
listView.setColumnSortType (2, finalcut::fc::by_name);
|
||||
listView.setColumnSortType (3, finalcut::fc::by_number);
|
||||
listView.setColumnSortType (4, finalcut::fc::by_number);
|
||||
listView.setColumnSortType (5, finalcut::fc::by_number);
|
||||
listView.setColumnSortType (1, fc::by_name);
|
||||
listView.setColumnSortType (2, fc::by_name);
|
||||
listView.setColumnSortType (3, fc::by_number);
|
||||
listView.setColumnSortType (4, fc::by_number);
|
||||
listView.setColumnSortType (5, fc::by_number);
|
||||
|
||||
// Sort in ascending order by the 1st column
|
||||
listView.setColumnSort (1, finalcut::fc::ascending);
|
||||
listView.setColumnSort (1, fc::ascending);
|
||||
// Sorting follows later automatically on insert().
|
||||
// Otherwise you could start the sorting directly with sort()
|
||||
|
||||
@ -178,7 +175,7 @@ void Listview::populate()
|
||||
|
||||
constexpr int lastItem = int(sizeof(weather) / sizeof(weather[0])) - 1;
|
||||
|
||||
for (int i = 0; i <= lastItem; i++)
|
||||
for (int i{0}; i <= lastItem; i++)
|
||||
{
|
||||
finalcut::FStringList line (&weather[i][0], &weather[i][0] + 5);
|
||||
listView.insert (line);
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -30,9 +31,6 @@ using finalcut::FSize;
|
||||
// class Mandelbrot
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Mandelbrot : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -43,15 +41,15 @@ class Mandelbrot : public finalcut::FDialog
|
||||
~Mandelbrot();
|
||||
|
||||
// Event handlers
|
||||
virtual void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
virtual void draw() override;
|
||||
virtual void adjustSize() override;
|
||||
void draw() override;
|
||||
void adjustSize() override;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Mandelbrot::Mandelbrot (finalcut::FWidget* parent)
|
||||
@ -67,51 +65,46 @@ Mandelbrot::~Mandelbrot()
|
||||
//----------------------------------------------------------------------
|
||||
void Mandelbrot::draw()
|
||||
{
|
||||
int iter, max_iter;
|
||||
int Cols, Lines, xoffset, yoffset, current_line;
|
||||
double x, y, xtemp, x0, y0, dX, dY;
|
||||
double x_min, x_max, y_min, y_max;
|
||||
|
||||
finalcut::FDialog::draw();
|
||||
|
||||
x_min = -2.20;
|
||||
x_max = 1.00;
|
||||
y_min = -1.05;
|
||||
y_max = 1.05;
|
||||
max_iter = 99;
|
||||
double x_min{-2.20};
|
||||
double x_max{+1.00};
|
||||
double y_min{-1.05};
|
||||
double y_max{+1.05};
|
||||
int max_iter{99};
|
||||
|
||||
xoffset = 2;
|
||||
yoffset = 2;
|
||||
current_line = 0;
|
||||
Cols = int(getClientWidth());
|
||||
Lines = int(getClientHeight());
|
||||
int xoffset{2};
|
||||
int yoffset{2};
|
||||
int current_line{0};
|
||||
int Cols = int(getClientWidth());
|
||||
int Lines = int(getClientHeight());
|
||||
|
||||
dX = (x_max - x_min) / (Cols - 1);
|
||||
dY = (y_max - y_min) / Lines;
|
||||
double dX = (x_max - x_min) / (Cols - 1);
|
||||
double dY = (y_max - y_min) / Lines;
|
||||
|
||||
for (y0 = y_min; y0 < y_max && current_line < Lines; y0 += dY)
|
||||
for (double y0 = y_min; y0 < y_max && current_line < Lines; y0 += dY)
|
||||
{
|
||||
current_line++;
|
||||
print() << FPoint(xoffset, yoffset + current_line);
|
||||
|
||||
for (x0 = x_min; x0 < x_max; x0 += dX)
|
||||
for (double x0 = x_min; x0 < x_max; x0 += dX)
|
||||
{
|
||||
x = 0.0;
|
||||
y = 0.0;
|
||||
iter = 0;
|
||||
double x{0.0};
|
||||
double y{0.0};
|
||||
int iter{0};
|
||||
|
||||
while ( x * x + y * y < 4 && iter < max_iter )
|
||||
{
|
||||
xtemp = x * x - y * y + x0;
|
||||
double xtemp = x * x - y * y + x0;
|
||||
y = 2 * x * y + y0;
|
||||
x = xtemp;
|
||||
iter++;
|
||||
}
|
||||
|
||||
if ( iter < max_iter )
|
||||
setColor(finalcut::fc::Black, iter % 16);
|
||||
setColor(fc::Black, iter % 16);
|
||||
else
|
||||
setColor(finalcut::fc::Black, 0);
|
||||
setColor(fc::Black, 0);
|
||||
|
||||
print(' ');
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -30,9 +31,6 @@ using finalcut::FSize;
|
||||
// class Menu
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Menu : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -57,16 +55,16 @@ class Menu : public finalcut::FDialog
|
||||
void configureStyleMenuItems();
|
||||
void configureBorderMenuItems();
|
||||
void defaultCallback (finalcut::FMenuList*);
|
||||
virtual void adjustSize() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handler
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Callback method
|
||||
void cb_message (finalcut::FWidget*, FDataPtr);
|
||||
|
||||
// Data Members
|
||||
finalcut::FString line{13, finalcut::fc::BoxDrawingsHorizontal};
|
||||
// Data members
|
||||
finalcut::FString line{13, fc::BoxDrawingsHorizontal};
|
||||
finalcut::FMenuBar Menubar{this};
|
||||
finalcut::FMenu File{"&File", &Menubar};
|
||||
finalcut::FMenu Edit{"&Edit", &Menubar};
|
||||
@ -82,17 +80,17 @@ class Menu : public finalcut::FDialog
|
||||
finalcut::FMenuItem Print{"&Print", &File};
|
||||
finalcut::FMenuItem Line2{&File};
|
||||
finalcut::FMenuItem Quit{"&Quit", &File};
|
||||
finalcut::FMenuItem Undo{finalcut::fc::Fckey_z, "&Undo", &Edit};
|
||||
finalcut::FMenuItem Redo{finalcut::fc::Fckey_y, "&Redo", &Edit};
|
||||
finalcut::FMenuItem Undo{fc::Fckey_z, "&Undo", &Edit};
|
||||
finalcut::FMenuItem Redo{fc::Fckey_y, "&Redo", &Edit};
|
||||
finalcut::FMenuItem Line3{&Edit};
|
||||
finalcut::FMenuItem Cut{finalcut::fc::Fckey_x, "Cu&t", &Edit};
|
||||
finalcut::FMenuItem Copy{finalcut::fc::Fckey_c, "&Copy", &Edit};
|
||||
finalcut::FMenuItem Paste{finalcut::fc::Fckey_v, "&Paste", &Edit};
|
||||
finalcut::FMenuItem Cut{fc::Fckey_x, "Cu&t", &Edit};
|
||||
finalcut::FMenuItem Copy{fc::Fckey_c, "&Copy", &Edit};
|
||||
finalcut::FMenuItem Paste{fc::Fckey_v, "&Paste", &Edit};
|
||||
finalcut::FMenuItem Line4{&Edit};
|
||||
finalcut::FMenuItem Search{finalcut::fc::Fckey_f, "&Search", &Edit};
|
||||
finalcut::FMenuItem Next{finalcut::fc::Fkey_f3, "Search &next", &Edit};
|
||||
finalcut::FMenuItem Search{fc::Fckey_f, "&Search", &Edit};
|
||||
finalcut::FMenuItem Next{fc::Fkey_f3, "Search &next", &Edit};
|
||||
finalcut::FMenuItem Line5{&Edit};
|
||||
finalcut::FMenuItem SelectAll{finalcut::fc::Fckey_a, "Select &all", &Edit};
|
||||
finalcut::FMenuItem SelectAll{fc::Fckey_a, "Select &all", &Edit};
|
||||
finalcut::FMenu Color{"&Color", &Choice};
|
||||
finalcut::FMenu Style{"&Style", &Choice};
|
||||
finalcut::FMenu Border{"&Border", &Choice};
|
||||
@ -116,7 +114,6 @@ class Menu : public finalcut::FDialog
|
||||
finalcut::FLabel Headline2{this};
|
||||
finalcut::FLabel Info{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Menu::Menu (finalcut::FWidget* parent)
|
||||
@ -166,20 +163,20 @@ Menu::~Menu()
|
||||
void Menu::configureFileMenuItems()
|
||||
{
|
||||
// "File" menu items
|
||||
New.addAccelerator (finalcut::fc::Fckey_n); // Ctrl + N
|
||||
New.addAccelerator (fc::Fckey_n); // Ctrl + N
|
||||
New.setStatusbarMessage ("Create a new file");
|
||||
Open.addAccelerator (finalcut::fc::Fckey_o); // Ctrl + O
|
||||
Open.addAccelerator (fc::Fckey_o); // Ctrl + O
|
||||
Open.setStatusbarMessage ("Locate and open a text file");
|
||||
Save.addAccelerator (finalcut::fc::Fckey_s); // Ctrl + S
|
||||
Save.addAccelerator (fc::Fckey_s); // Ctrl + S
|
||||
Save.setStatusbarMessage ("Save the file");
|
||||
SaveAs.setStatusbarMessage ("Save the current file under a different name");
|
||||
Close.addAccelerator (finalcut::fc::Fckey_w); // Ctrl + W
|
||||
Close.addAccelerator (fc::Fckey_w); // Ctrl + W
|
||||
Close.setStatusbarMessage ("Close the current file");
|
||||
Line1.setSeparator();
|
||||
Print.addAccelerator (finalcut::fc::Fckey_p); // Ctrl + P
|
||||
Print.addAccelerator (fc::Fckey_p); // Ctrl + P
|
||||
Print.setStatusbarMessage ("Print the current file");
|
||||
Line2.setSeparator();
|
||||
Quit.addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X
|
||||
Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X
|
||||
Quit.setStatusbarMessage ("Exit the program");
|
||||
|
||||
// Add quit menu item callback
|
||||
@ -263,7 +260,7 @@ void Menu::configureBorderMenuItems()
|
||||
//----------------------------------------------------------------------
|
||||
void Menu::defaultCallback (finalcut::FMenuList* mb)
|
||||
{
|
||||
for (uInt i = 1; i <= mb->getCount(); i++)
|
||||
for (uInt i{1}; i <= mb->getCount(); i++)
|
||||
{
|
||||
auto item = mb->getItem(int(i));
|
||||
|
||||
|
@ -22,18 +22,17 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FColorPair;
|
||||
using finalcut::FRect;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
using finalcut::FColorPair;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class ColorChooser
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class ColorChooser : public finalcut::FWidget
|
||||
{
|
||||
public:
|
||||
@ -55,17 +54,17 @@ class ColorChooser : public finalcut::FWidget
|
||||
|
||||
private:
|
||||
// Method
|
||||
virtual void draw() override;
|
||||
void draw() override;
|
||||
void drawBorder() override;
|
||||
|
||||
// Event handler
|
||||
virtual void onMouseDown (finalcut::FMouseEvent*) override;
|
||||
void onMouseDown (finalcut::FMouseEvent*) override;
|
||||
|
||||
// Data Members
|
||||
FColor fg_color{finalcut::fc::White};
|
||||
FColor bg_color{finalcut::fc::Black};
|
||||
// Data members
|
||||
FColor fg_color{fc::White};
|
||||
FColor bg_color{fc::Black};
|
||||
finalcut::FLabel headline{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
ColorChooser::ColorChooser (finalcut::FWidget* parent)
|
||||
@ -88,7 +87,7 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent)
|
||||
// Text label
|
||||
headline.setGeometry (FPoint(1, 1), FSize(8, 1));
|
||||
headline.setEmphasis();
|
||||
headline.setAlignment (finalcut::fc::alignCenter);
|
||||
headline.setAlignment (fc::alignCenter);
|
||||
headline << "Color";
|
||||
}
|
||||
|
||||
@ -102,10 +101,10 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
if ( ev->getButton() == finalcut::fc::MiddleButton )
|
||||
if ( ev->getButton() == fc::MiddleButton )
|
||||
return;
|
||||
|
||||
for (int c = 0; c < 16; c++)
|
||||
for (int c{0}; c < 16; c++)
|
||||
{
|
||||
int xmin = 2 + (c / 8) * 3;
|
||||
int xmax = 4 + (c / 8) * 3;
|
||||
@ -113,9 +112,9 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
|
||||
if ( mouse_x >= xmin && mouse_x <= xmax && mouse_y == y )
|
||||
{
|
||||
if ( ev->getButton() == finalcut::fc::LeftButton )
|
||||
if ( ev->getButton() == fc::LeftButton )
|
||||
bg_color = FColor(c);
|
||||
else if ( ev->getButton() == finalcut::fc::RightButton )
|
||||
else if ( ev->getButton() == fc::RightButton )
|
||||
fg_color = FColor(c);
|
||||
|
||||
redraw();
|
||||
@ -128,28 +127,34 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
void ColorChooser::draw()
|
||||
{
|
||||
setColor();
|
||||
finalcut::FWidget::drawBorder (1, 2, 8, 11);
|
||||
drawBorder();
|
||||
|
||||
for (FColor c = 0; c < 16; c++)
|
||||
for (FColor c{0}; c < 16; c++)
|
||||
{
|
||||
print() << FPoint(2 + (c / 8) * 3, 3 + c % 8);
|
||||
|
||||
if ( c < 6 )
|
||||
setColor (finalcut::fc::LightGray, c);
|
||||
setColor (fc::LightGray, c);
|
||||
else if ( c > 8 )
|
||||
setColor (finalcut::fc::DarkGray, c);
|
||||
setColor (fc::DarkGray, c);
|
||||
else
|
||||
setColor (finalcut::fc::White, c);
|
||||
setColor (fc::White, c);
|
||||
|
||||
if ( c == bg_color )
|
||||
{
|
||||
print() << ' ' << finalcut::fc::Times << ' ';
|
||||
print() << L' ' << wchar_t(fc::Times) << L' ';
|
||||
}
|
||||
else
|
||||
print (" ");
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void ColorChooser::drawBorder()
|
||||
{
|
||||
finalcut::drawBorder (this, FRect(FPoint(1, 2), FSize(8, 10)));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FColor ColorChooser::getForeground()
|
||||
{
|
||||
@ -167,9 +172,6 @@ inline FColor ColorChooser::getBackground()
|
||||
// class Brushes
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Brushes : public finalcut::FWidget
|
||||
{
|
||||
public:
|
||||
@ -194,18 +196,18 @@ class Brushes : public finalcut::FWidget
|
||||
|
||||
private:
|
||||
// Method
|
||||
virtual void draw() override;
|
||||
void draw() override;
|
||||
void drawBorder() override;
|
||||
|
||||
// Event handler
|
||||
virtual void onMouseDown (finalcut::FMouseEvent*) override;
|
||||
void onMouseDown (finalcut::FMouseEvent*) override;
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
wchar_t brush{L' '};
|
||||
FColor fg_color{finalcut::fc::White};
|
||||
FColor bg_color{finalcut::fc::Black};
|
||||
FColor fg_color{fc::White};
|
||||
FColor bg_color{fc::Black};
|
||||
finalcut::FLabel headline{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Brushes::Brushes (finalcut::FWidget* parent)
|
||||
@ -228,7 +230,7 @@ Brushes::Brushes (finalcut::FWidget* parent)
|
||||
// Text label
|
||||
headline.setGeometry(FPoint(1, 1), FSize(8, 1));
|
||||
headline.setEmphasis();
|
||||
headline.setAlignment (finalcut::fc::alignCenter);
|
||||
headline.setAlignment (fc::alignCenter);
|
||||
headline << "Brush";
|
||||
}
|
||||
|
||||
@ -236,16 +238,15 @@ Brushes::Brushes (finalcut::FWidget* parent)
|
||||
Brushes::~Brushes()
|
||||
{ }
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Brushes::draw()
|
||||
{
|
||||
int pos;
|
||||
int pos{};
|
||||
setColor();
|
||||
finalcut::FWidget::drawBorder (1, 2, 8, 4);
|
||||
drawBorder();
|
||||
print() << FPoint(2, 3)
|
||||
<< FColorPair(fg_color, bg_color) << " "
|
||||
<< finalcut::FString(3, finalcut::fc::MediumShade);
|
||||
<< finalcut::FString(3, fc::MediumShade);
|
||||
|
||||
if ( brush == L' ' )
|
||||
pos = 0;
|
||||
@ -254,9 +255,15 @@ void Brushes::draw()
|
||||
|
||||
setColor();
|
||||
print() << FPoint(3 + pos, 2)
|
||||
<< finalcut::fc::BlackDownPointingTriangle
|
||||
<< fc::BlackDownPointingTriangle
|
||||
<< FPoint(3 + pos, 4)
|
||||
<< finalcut::fc::BlackUpPointingTriangle;
|
||||
<< fc::BlackUpPointingTriangle;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Brushes::drawBorder()
|
||||
{
|
||||
finalcut::drawBorder (this, FRect(FPoint(1, 2), FSize(8, 3)));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -265,7 +272,7 @@ void Brushes::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
if ( ev->getButton() != finalcut::fc::LeftButton )
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
return;
|
||||
|
||||
if ( mouse_x >= 2 && mouse_x <= 4 && mouse_y == 3 )
|
||||
@ -275,7 +282,7 @@ void Brushes::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
}
|
||||
else if ( mouse_x >= 5 && mouse_x <= 7 && mouse_y == 3 )
|
||||
{
|
||||
brush = finalcut::fc::MediumShade;
|
||||
brush = fc::MediumShade;
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
@ -303,9 +310,6 @@ inline void Brushes::setBackground (FColor color)
|
||||
// class MouseDraw
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class MouseDraw : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -328,29 +332,29 @@ class MouseDraw : public finalcut::FDialog
|
||||
void setGeometry (const FPoint&, const FSize&, bool = true) override;
|
||||
|
||||
// Event handlers
|
||||
virtual void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
virtual void draw() override;
|
||||
void draw() override;
|
||||
void drawBrush (int, int, bool = false);
|
||||
void drawCanvas();
|
||||
virtual void adjustSize() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handler
|
||||
virtual void onMouseDown (finalcut::FMouseEvent*) override;
|
||||
virtual void onMouseMove (finalcut::FMouseEvent*) override;
|
||||
void onMouseDown (finalcut::FMouseEvent*) override;
|
||||
void onMouseMove (finalcut::FMouseEvent*) override;
|
||||
|
||||
// Callback methods
|
||||
void cb_colorChanged (finalcut::FWidget*, FDataPtr);
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
term_area* canvas{nullptr};
|
||||
ColorChooser c_chooser{this};
|
||||
Brushes brush{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
MouseDraw::MouseDraw (finalcut::FWidget* parent)
|
||||
@ -424,27 +428,27 @@ void MouseDraw::draw()
|
||||
|
||||
if ( isNewFont() )
|
||||
{
|
||||
for (int y = 2; y < y_max; y++)
|
||||
for (int y{2}; y < y_max; y++)
|
||||
{
|
||||
print() << FPoint(10, y)
|
||||
<< finalcut::fc::NF_rev_border_line_right;
|
||||
<< fc::NF_rev_border_line_right;
|
||||
}
|
||||
|
||||
print() << FPoint(10, y_max)
|
||||
<< finalcut::fc::NF_rev_border_corner_lower_right;
|
||||
<< fc::NF_rev_border_corner_lower_right;
|
||||
}
|
||||
else
|
||||
{
|
||||
print() << FPoint(10, 2)
|
||||
<< finalcut::fc::BoxDrawingsDownAndHorizontal;
|
||||
<< fc::BoxDrawingsDownAndHorizontal;
|
||||
|
||||
for (int y = 3; y < y_max; y++)
|
||||
for (int y{3}; y < y_max; y++)
|
||||
{
|
||||
print() << FPoint(10, y) << finalcut::fc::BoxDrawingsVertical;
|
||||
print() << FPoint(10, y) << fc::BoxDrawingsVertical;
|
||||
}
|
||||
|
||||
print() << FPoint(10, y_max)
|
||||
<< finalcut::fc::BoxDrawingsUpAndHorizontal;
|
||||
<< fc::BoxDrawingsUpAndHorizontal;
|
||||
}
|
||||
|
||||
drawCanvas();
|
||||
@ -453,7 +457,7 @@ void MouseDraw::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void MouseDraw::drawBrush (int x, int y, bool swap_color)
|
||||
{
|
||||
int Cols = int(getWidth());
|
||||
int Cols = int(getWidth());
|
||||
int Lines = int(getHeight());
|
||||
|
||||
if ( x > 10 && x < Cols && y > 2 && y < Lines )
|
||||
@ -482,34 +486,37 @@ void MouseDraw::drawCanvas()
|
||||
if ( ! (hasPrintArea() && canvas) )
|
||||
return;
|
||||
|
||||
int ax = 9 + getTermX() - print_area->offset_left
|
||||
, ay = 1 + getTermY() - print_area->offset_top
|
||||
auto printarea = getCurrentPrintArea();
|
||||
int ax = 9 + getTermX() - printarea->offset_left
|
||||
, ay = 1 + getTermY() - printarea->offset_top
|
||||
, y_end = canvas->height
|
||||
, x_end = canvas->width
|
||||
, w_line_len = print_area->width + print_area->right_shadow;
|
||||
, w_line_len = printarea->width + printarea->right_shadow;
|
||||
|
||||
for (int y = 0; y < y_end; y++) // line loop
|
||||
for (int y{0}; y < y_end; y++) // line loop
|
||||
{
|
||||
charData* canvaschar; // canvas character
|
||||
charData* winchar; // window character
|
||||
finalcut::charData* canvaschar{}; // canvas character
|
||||
finalcut::charData* winchar{}; // window character
|
||||
canvaschar = &canvas->text[y * x_end];
|
||||
winchar = &print_area->text[(ay + y) * w_line_len + ax];
|
||||
std::memcpy (winchar, canvaschar, sizeof(charData) * unsigned(x_end));
|
||||
winchar = &printarea->text[(ay + y) * w_line_len + ax];
|
||||
std::memcpy ( winchar
|
||||
, canvaschar
|
||||
, sizeof(finalcut::charData) * unsigned(x_end) );
|
||||
|
||||
if ( int(print_area->changes[ay + y].xmin) > ax )
|
||||
print_area->changes[ay + y].xmin = uInt(ax);
|
||||
if ( int(printarea->changes[ay + y].xmin) > ax )
|
||||
printarea->changes[ay + y].xmin = uInt(ax);
|
||||
|
||||
if ( int(print_area->changes[ay + y].xmax) < ax + x_end - 1 )
|
||||
print_area->changes[ay + y].xmax = uInt(ax + x_end - 1);
|
||||
if ( int(printarea->changes[ay + y].xmax) < ax + x_end - 1 )
|
||||
printarea->changes[ay + y].xmax = uInt(ax + x_end - 1);
|
||||
}
|
||||
|
||||
print_area->has_changes = true;
|
||||
printarea->has_changes = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MouseDraw::adjustSize()
|
||||
{
|
||||
std::size_t w = 60, h = 18;
|
||||
std::size_t w{60}, h{18};
|
||||
int x = 1 + int((getParentWidget()->getWidth() - w) / 2);
|
||||
int y = 1 + int((getParentWidget()->getHeight() - h) / 2);
|
||||
setGeometry (FPoint(x, y), FSize(w, h), false);
|
||||
@ -521,13 +528,13 @@ void MouseDraw::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
{
|
||||
finalcut::FDialog::onMouseDown(ev);
|
||||
|
||||
if ( ev->getButton() != finalcut::fc::LeftButton
|
||||
&& ev->getButton() != finalcut::fc::RightButton )
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::RightButton )
|
||||
return;
|
||||
|
||||
drawBrush ( ev->getX()
|
||||
, ev->getY()
|
||||
, ev->getButton() == finalcut::fc::RightButton );
|
||||
, ev->getButton() == fc::RightButton );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -535,13 +542,13 @@ void MouseDraw::onMouseMove (finalcut::FMouseEvent* ev)
|
||||
{
|
||||
FDialog::onMouseMove(ev);
|
||||
|
||||
if ( ev->getButton() != finalcut::fc::LeftButton
|
||||
&& ev->getButton() != finalcut::fc::RightButton )
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::RightButton )
|
||||
return;
|
||||
|
||||
drawBrush ( ev->getX()
|
||||
, ev->getY()
|
||||
, ev->getButton() == finalcut::fc::RightButton);
|
||||
, ev->getButton() == fc::RightButton);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2016-2018 Markus Gans *
|
||||
* Copyright 2016-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -26,11 +26,8 @@
|
||||
#include <final/final.h>
|
||||
|
||||
|
||||
// Global FVTerm object
|
||||
static finalcut::FVTerm* terminal;
|
||||
|
||||
// Global FApplication object
|
||||
static finalcut::FApplication* app = nullptr;
|
||||
static finalcut::FApplication* app{nullptr};
|
||||
|
||||
// function prototype
|
||||
bool keyPressed();
|
||||
@ -44,12 +41,13 @@ void move (int, int, int, int);
|
||||
bool keyPressed()
|
||||
{
|
||||
// Waiting for keypress
|
||||
struct termios save, t;
|
||||
bool ret;
|
||||
|
||||
struct termios save{};
|
||||
bool ret{false};
|
||||
std::cout << "\nPress any key to continue...";
|
||||
fflush(stdout);
|
||||
tcgetattr (STDIN_FILENO, &save);
|
||||
t = save;
|
||||
struct termios t = save;
|
||||
t.c_lflag &= uInt(~(ICANON | ECHO));
|
||||
tcsetattr (STDIN_FILENO, TCSANOW, &t);
|
||||
|
||||
@ -89,10 +87,8 @@ void term_boundaries (int& x, int& y)
|
||||
void move (int xold, int yold, int xnew, int ynew)
|
||||
{
|
||||
// prints the cursor move escape sequence
|
||||
std::string sequence;
|
||||
char* buffer;
|
||||
char from[26], to[26], byte[20];
|
||||
uInt len;
|
||||
std::string sequence{};
|
||||
char from[26]{}, to[26]{}, byte[20]{};
|
||||
const std::string ctrl_character[] =
|
||||
{
|
||||
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
|
||||
@ -111,8 +107,8 @@ void move (int xold, int yold, int xnew, int ynew)
|
||||
<< std::left << std::setw(10) << to
|
||||
<< " ";
|
||||
// get the move string
|
||||
buffer = terminal->moveCursor (xold, yold, xnew, ynew);
|
||||
len = uInt(std::strlen(buffer));
|
||||
char* buffer = finalcut::FTerm::moveCursorString (xold, yold, xnew, ynew);
|
||||
uInt len = uInt(std::strlen(buffer));
|
||||
|
||||
for (uInt i = 0; i < len; i++)
|
||||
{
|
||||
@ -142,18 +138,15 @@ void move (int xold, int yold, int xnew, int ynew)
|
||||
//----------------------------------------------------------------------
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
int xmax, ymax;
|
||||
|
||||
// Create the application object
|
||||
finalcut::FApplication TermApp(argc, argv);
|
||||
|
||||
// Pointer to the global virtual terminal object
|
||||
terminal = static_cast<finalcut::FVTerm*>(&TermApp);
|
||||
app = &TermApp;
|
||||
|
||||
// Get screen dimension
|
||||
xmax = int(TermApp.getDesktopWidth() - 1);
|
||||
ymax = int(TermApp.getDesktopHeight() - 1);
|
||||
int xmax = int(TermApp.getDesktopWidth() - 1);
|
||||
int ymax = int(TermApp.getDesktopHeight() - 1);
|
||||
finalcut::FString line(std::size_t(xmax) + 1, '-');
|
||||
|
||||
// Place the cursor in the upper left corner
|
||||
@ -197,7 +190,8 @@ int main (int argc, char* argv[])
|
||||
|
||||
// Show terminal speed and milliseconds for all cursor movement sequence
|
||||
std::cout << "\r" << line;
|
||||
TermApp.printMoveDurations();
|
||||
const finalcut::FOptiMove& opti_move = *TermApp.getFTerm().getFOptiMove();
|
||||
finalcut::printDurations(opti_move);
|
||||
|
||||
// Waiting for keypress
|
||||
keyPressed();
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -30,9 +31,6 @@ using finalcut::FSize;
|
||||
// class Scrollview
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Scrollview : public finalcut::FScrollView
|
||||
{
|
||||
public:
|
||||
@ -53,7 +51,7 @@ class Scrollview : public finalcut::FScrollView
|
||||
|
||||
private:
|
||||
// Method
|
||||
virtual void draw() override;
|
||||
void draw() override;
|
||||
|
||||
// Callback methods
|
||||
void cb_go_east (finalcut::FWidget*, FDataPtr);
|
||||
@ -61,17 +59,16 @@ class Scrollview : public finalcut::FScrollView
|
||||
void cb_go_west (finalcut::FWidget*, FDataPtr);
|
||||
void cb_go_north (finalcut::FWidget*, FDataPtr);
|
||||
|
||||
// Data Members
|
||||
wchar_t pointer_right{finalcut::fc::BlackRightPointingPointer};
|
||||
wchar_t pointer_down{finalcut::fc::BlackDownPointingTriangle};
|
||||
wchar_t pointer_left{finalcut::fc::BlackLeftPointingPointer};
|
||||
wchar_t pointer_up{finalcut::fc::BlackUpPointingTriangle};
|
||||
// Data members
|
||||
wchar_t pointer_right{fc::BlackRightPointingPointer};
|
||||
wchar_t pointer_down{fc::BlackDownPointingTriangle};
|
||||
wchar_t pointer_left{fc::BlackLeftPointingPointer};
|
||||
wchar_t pointer_up{fc::BlackUpPointingTriangle};
|
||||
finalcut::FButton go_east{pointer_right, this};
|
||||
finalcut::FButton go_south{pointer_down, this};
|
||||
finalcut::FButton go_west{pointer_left, this};
|
||||
finalcut::FButton go_north{pointer_up, this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Scrollview::Scrollview (finalcut::FWidget* parent)
|
||||
@ -121,8 +118,8 @@ Scrollview::~Scrollview()
|
||||
void Scrollview::setScrollSize (const FSize& size)
|
||||
{
|
||||
FScrollView::setScrollSize (size);
|
||||
auto width = int(size.getWidth());
|
||||
auto height = int(size.getHeight());
|
||||
int width = int(size.getWidth());
|
||||
int height = int(size.getHeight());
|
||||
go_south.setPos (FPoint(width - 5, 1));
|
||||
go_west.setPos (FPoint(width - 5, height - 1));
|
||||
go_north.setPos (FPoint(1, height - 1));
|
||||
@ -134,15 +131,17 @@ void Scrollview::draw()
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
setColor (wc.label_inactive_fg, wc.dialog_bg);
|
||||
clearArea();
|
||||
|
||||
for (int y = 0; y < int(getScrollHeight()); y++)
|
||||
for (int y{0}; y < int(getScrollHeight()); y++)
|
||||
{
|
||||
print() << FPoint(1, 1 + y);
|
||||
|
||||
for (int x = 0; x < int(getScrollWidth()); x++)
|
||||
for (int x{0}; x < int(getScrollWidth()); x++)
|
||||
print (32 + ((x + y) % 0x5f));
|
||||
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
@ -192,9 +191,6 @@ void Scrollview::cb_go_north (finalcut::FWidget*, FDataPtr)
|
||||
// class Scrollviewdemo
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Scrollviewdemo : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -205,17 +201,16 @@ class Scrollviewdemo : public finalcut::FDialog
|
||||
~Scrollviewdemo();
|
||||
|
||||
// Event handler
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Callback method
|
||||
void cb_quit (finalcut::FWidget* = nullptr, FDataPtr = nullptr);
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
Scrollview sview{this};
|
||||
finalcut::FButton quit_btn{"&Quit", this};
|
||||
finalcut::FLabel label{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2012-2018 Markus Gans *
|
||||
* Copyright 2012-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -101,7 +101,7 @@ void inputStreamExample()
|
||||
void outputStreamExample()
|
||||
{
|
||||
// Test: output stream (operator <<)
|
||||
const finalcut::FString& out = L"A test string for 0 \x20ac";
|
||||
const finalcut::FString out{L"A test string for 0 \x20ac"};
|
||||
std::cout << " outstream << " << out << std::endl;
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ void streamingFromFStringExample()
|
||||
std::wcout << "stream out: " << stream_wstring << std::endl;
|
||||
|
||||
// ...to wide character
|
||||
wchar_t stream_wchar_t = L'\0';
|
||||
wchar_t stream_wchar_t{L'\0'};
|
||||
finalcut::FString("w") >> stream_wchar_t;
|
||||
std::wcout << "stream out: " << stream_wchar_t << std::endl;
|
||||
|
||||
@ -302,7 +302,7 @@ void streamToFloat()
|
||||
void CStringOutputExample()
|
||||
{
|
||||
// Test: c-string output
|
||||
const finalcut::FString& out = L"A test string for 0 \x20ac";
|
||||
const finalcut::FString out{L"A test string for 0 \x20ac"};
|
||||
printf (" c_str: \"%s\"\n", out.c_str());
|
||||
}
|
||||
|
||||
@ -326,7 +326,7 @@ void copyIntoFString()
|
||||
void utf8StringOutputExample()
|
||||
{
|
||||
// Test: utf-8 string
|
||||
const finalcut::FString& len = "длина́";
|
||||
const finalcut::FString len{"длина́"};
|
||||
std::cout << " length: \"" << len << "\" has "
|
||||
<< len.getLength() << " characters" << std::endl;
|
||||
}
|
||||
@ -335,11 +335,11 @@ void utf8StringOutputExample()
|
||||
void letterCaseExample()
|
||||
{
|
||||
// Test: convert uppercase letter to lowercase
|
||||
const finalcut::FString& lower = finalcut::FString(L"InPut").toLower();
|
||||
const finalcut::FString lower{finalcut::FString(L"InPut").toLower()};
|
||||
std::wcout << L" toLower: " << lower << std::endl;
|
||||
|
||||
// Test: convert lowercase letter to uppercase
|
||||
const finalcut::FString& upper = finalcut::FString("inPut").toUpper();
|
||||
const finalcut::FString upper{finalcut::FString("inPut").toUpper()};
|
||||
std::cout << " toUpper: " << upper << std::endl;
|
||||
}
|
||||
|
||||
@ -414,7 +414,7 @@ void stringConcatenationExample()
|
||||
void stringCompareExample()
|
||||
{
|
||||
// Test: compare operators ==, <=, <, >=, >, !=
|
||||
const finalcut::FString& cmp = "compare";
|
||||
const finalcut::FString cmp{"compare"};
|
||||
|
||||
if ( cmp == finalcut::FString("compare") )
|
||||
std::cout << " cmp: == Ok" << std::endl;
|
||||
@ -451,10 +451,10 @@ void stringCompareExample()
|
||||
void stringSplittingExample()
|
||||
{
|
||||
// Test: split a string with a delimiter and returns a vector (array)
|
||||
finalcut::FString split_str = "a,b,c,d";
|
||||
finalcut::FString split_str{"a,b,c,d"};
|
||||
std::cout << " split: \""
|
||||
<< split_str << "\" into substrings ->";
|
||||
finalcut::FStringList parts = split_str.split(",");
|
||||
finalcut::FStringList parts{ split_str.split(",") };
|
||||
finalcut::FStringList::iterator it, end;
|
||||
end = parts.end();
|
||||
|
||||
@ -468,7 +468,7 @@ void stringSplittingExample()
|
||||
void fromatStringExample()
|
||||
{
|
||||
// Test: format a string with sprintf
|
||||
finalcut::FString formatStr = "";
|
||||
finalcut::FString formatStr{""};
|
||||
std::cout << " formatted: "
|
||||
<< formatStr.sprintf("sqrt(%d) = %d", 16, 4)
|
||||
<< std::endl;
|
||||
@ -533,8 +533,8 @@ void convertToNumberExample()
|
||||
void convertNumberToStringExample()
|
||||
{
|
||||
// Test: convert integer and double value to a string
|
||||
finalcut::FString num1, num2, num3;
|
||||
num1.setNumber(137);
|
||||
finalcut::FString num1{}, num2{}, num3{};
|
||||
num1.setNumber(137u);
|
||||
num2.setNumber(-512);
|
||||
num3.setNumber(3.141592653589793238L, 12);
|
||||
std::cout << " setNumber: "
|
||||
@ -550,14 +550,14 @@ void formatedNumberExample()
|
||||
{
|
||||
// Test: convert and format a integer number with thousand separator
|
||||
std::setlocale (LC_NUMERIC, "");
|
||||
finalcut::FString fnum1, fnum2;
|
||||
finalcut::FString fnum1{}, fnum2{};
|
||||
#if defined(__LP64__) || defined(_LP64)
|
||||
// 64-bit architecture
|
||||
fnum1.setFormatedNumber(0xffffffffffffffff, '\'');
|
||||
fnum1.setFormatedNumber(0xffffffffffffffffu, '\'');
|
||||
fnum2.setFormatedNumber(-9223372036854775807);
|
||||
#else
|
||||
// 32-bit architecture
|
||||
fnum1.setFormatedNumber(0xffffffff, '\'');
|
||||
fnum1.setFormatedNumber(0xffffffffu, '\'');
|
||||
fnum2.setFormatedNumber(-2147483647);
|
||||
#endif
|
||||
std::cout << "setFormatedNumber: "
|
||||
@ -570,7 +570,7 @@ void formatedNumberExample()
|
||||
void trimExample()
|
||||
{
|
||||
// Test: remove whitespace from the end of a string
|
||||
const finalcut::FString& trim_str = " A string \t";
|
||||
const finalcut::FString& trim_str{" A string \t"};
|
||||
std::wcout << " rtrim: \""
|
||||
<< trim_str.rtrim() << "\"" << std::endl;
|
||||
|
||||
@ -587,8 +587,8 @@ void trimExample()
|
||||
void substringExample()
|
||||
{
|
||||
// Test: 11 characters from the left of the string
|
||||
const finalcut::FString& alphabet = "a b c d e f g h i j k l m "
|
||||
"n o p q r s t u v w x y z";
|
||||
const finalcut::FString alphabet{ "a b c d e f g h i j k l m "
|
||||
"n o p q r s t u v w x y z" };
|
||||
std::cout << " left: \""
|
||||
<< alphabet.left(11) << "\"" << std::endl;
|
||||
|
||||
@ -605,7 +605,7 @@ void substringExample()
|
||||
void insertExample()
|
||||
{
|
||||
// Test: insert a string at index position 7
|
||||
finalcut::FString insert_str = "I am a string";
|
||||
finalcut::FString insert_str{"I am a string"};
|
||||
|
||||
try
|
||||
{
|
||||
@ -622,7 +622,7 @@ void insertExample()
|
||||
void indexExample()
|
||||
{
|
||||
// Test: get character access at a specified index position
|
||||
finalcut::FString index(5); // string with five characters
|
||||
finalcut::FString index{5}; // string with five characters
|
||||
index = "index";
|
||||
|
||||
try
|
||||
@ -642,8 +642,8 @@ void indexExample()
|
||||
void iteratorExample()
|
||||
{
|
||||
// Test: character access with std::iterator
|
||||
const finalcut::FString& stringIterator = "iterator";
|
||||
finalcut::FString::iterator iter;
|
||||
const finalcut::FString stringIterator{"iterator"};
|
||||
finalcut::FString::const_iterator iter;
|
||||
iter = stringIterator.begin();
|
||||
std::cout << " " << stringIterator << ": ";
|
||||
|
||||
@ -662,7 +662,7 @@ void iteratorExample()
|
||||
void overwriteExample()
|
||||
{
|
||||
// Test: overwrite string at position 10 with "for t"
|
||||
finalcut::FString overwrite_std = "Overwrite the rest";
|
||||
finalcut::FString overwrite_std{"Overwrite the rest"};
|
||||
std::cout << "overwrite: "
|
||||
<< overwrite_std.overwrite("for t", 10) << std::endl;
|
||||
}
|
||||
@ -671,7 +671,7 @@ void overwriteExample()
|
||||
void removeExample()
|
||||
{
|
||||
// Test: remove 2 characters at position 7
|
||||
finalcut::FString remove_std = "A fast remove";
|
||||
finalcut::FString remove_std{"A fast remove"};
|
||||
std::cout << " remove: "
|
||||
<< remove_std.remove(7, 2) << std::endl;
|
||||
}
|
||||
@ -680,7 +680,7 @@ void removeExample()
|
||||
void substringIncludeExample()
|
||||
{
|
||||
// Test: includes a substring (positive test)
|
||||
finalcut::FString include_std = "string";
|
||||
finalcut::FString include_std{"string"};
|
||||
|
||||
if ( include_std.includes("ring") )
|
||||
std::cout << " includes: \""
|
||||
@ -706,7 +706,7 @@ void substringIncludeExample()
|
||||
void replaceExample()
|
||||
{
|
||||
// Test: find and replace a substring
|
||||
finalcut::FString source_str = "computer and software";
|
||||
finalcut::FString source_str{"computer and software"};
|
||||
const finalcut::FString& replace_str = \
|
||||
source_str.replace("computer", "hard-");
|
||||
std::cout << " replace: "
|
||||
@ -717,7 +717,7 @@ void replaceExample()
|
||||
void tabToSpaceExample()
|
||||
{
|
||||
// Test: convert tabs to spaces
|
||||
const finalcut::FString& tab_str = "1234\t5678";
|
||||
const finalcut::FString tab_str{"1234\t5678"};
|
||||
std::cout << " tab: "
|
||||
<< tab_str.expandTabs() << std::endl;
|
||||
}
|
||||
@ -726,7 +726,7 @@ void tabToSpaceExample()
|
||||
void backspaceControlCharacterExample()
|
||||
{
|
||||
// Test: backspaces remove characters in the string
|
||||
const finalcut::FString& bs_str = "t\b\bTesT\bt";
|
||||
const finalcut::FString bs_str{"t\b\bTesT\bt"};
|
||||
std::cout << "backspace: "
|
||||
<< bs_str.removeBackspaces() << std::endl;
|
||||
}
|
||||
@ -735,7 +735,7 @@ void backspaceControlCharacterExample()
|
||||
void deleteControlCharacterExample()
|
||||
{
|
||||
// Test: delete characters remove characters in the string
|
||||
const finalcut::FString& del_str = "apple \177\177\177pietree";
|
||||
const finalcut::FString del_str{"apple \177\177\177pietree"};
|
||||
std::cout << " delete: "
|
||||
<< del_str.removeDel() << std::endl;
|
||||
}
|
||||
|
@ -21,8 +21,10 @@
|
||||
***********************************************************************/
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
using finalcut::FColorPair;
|
||||
@ -32,9 +34,6 @@ using finalcut::FColorPair;
|
||||
// class AttribDlg
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class AttribDlg : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -51,31 +50,30 @@ class AttribDlg : public finalcut::FDialog
|
||||
AttribDlg& operator = (const AttribDlg&) = delete;
|
||||
|
||||
// Event handlers
|
||||
virtual void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
virtual void onWheel (finalcut::FWheelEvent*) override;
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
void onWheel (finalcut::FWheelEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Callback methods
|
||||
void cb_next (finalcut::FWidget* = nullptr, FDataPtr = nullptr);
|
||||
void cb_back (finalcut::FWidget* = nullptr, FDataPtr = nullptr);
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
FColor bgcolor;
|
||||
|
||||
private:
|
||||
// Method
|
||||
virtual void adjustSize() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
finalcut::FButton next_button{"&Next >", this};
|
||||
finalcut::FButton back_button{"< &Back", this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
AttribDlg::AttribDlg (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
, bgcolor(wc.label_bg)
|
||||
, bgcolor(getFWidgetColors().label_bg)
|
||||
{
|
||||
setText ( "A terminal attributes test ("
|
||||
+ finalcut::FString(getTermType())
|
||||
@ -83,10 +81,10 @@ AttribDlg::AttribDlg (finalcut::FWidget* parent)
|
||||
|
||||
next_button.setGeometry ( FPoint(int(getWidth()) - 13, int(getHeight()) - 4)
|
||||
, FSize(10, 1) );
|
||||
next_button.addAccelerator (finalcut::fc::Fkey_right);
|
||||
next_button.addAccelerator (fc::Fkey_right);
|
||||
back_button.setGeometry ( FPoint(int(getWidth()) - 25, int(getHeight()) - 4)
|
||||
, FSize(10, 1) );
|
||||
back_button.addAccelerator (finalcut::fc::Fkey_left);
|
||||
back_button.addAccelerator (fc::Fkey_left);
|
||||
|
||||
// Add function callbacks
|
||||
next_button.addCallback
|
||||
@ -126,9 +124,9 @@ void AttribDlg::onWheel (finalcut::FWheelEvent* ev)
|
||||
{
|
||||
int wheel = ev->getWheel();
|
||||
|
||||
if ( wheel == finalcut::fc::WheelUp )
|
||||
if ( wheel == fc::WheelUp )
|
||||
cb_next();
|
||||
else if ( wheel == finalcut::fc::WheelDown )
|
||||
else if ( wheel == fc::WheelDown )
|
||||
cb_back();
|
||||
}
|
||||
|
||||
@ -145,8 +143,8 @@ void AttribDlg::cb_next (finalcut::FWidget*, FDataPtr)
|
||||
return;
|
||||
|
||||
if ( bgcolor == FColor(getMaxColor() - 1) )
|
||||
bgcolor = finalcut::fc::Default;
|
||||
else if ( bgcolor == finalcut::fc::Default )
|
||||
bgcolor = fc::Default;
|
||||
else if ( bgcolor == fc::Default )
|
||||
bgcolor = 0;
|
||||
else
|
||||
bgcolor++;
|
||||
@ -161,8 +159,8 @@ void AttribDlg::cb_back (finalcut::FWidget*, FDataPtr)
|
||||
return;
|
||||
|
||||
if ( bgcolor == 0 )
|
||||
bgcolor = finalcut::fc::Default;
|
||||
else if ( bgcolor == finalcut::fc::Default )
|
||||
bgcolor = fc::Default;
|
||||
else if ( bgcolor == fc::Default )
|
||||
bgcolor = FColor(getMaxColor() - 1);
|
||||
else
|
||||
bgcolor--;
|
||||
@ -195,9 +193,6 @@ void AttribDlg::adjustSize()
|
||||
// class AttribDemo
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class AttribDemo : public finalcut::FWidget
|
||||
{
|
||||
public:
|
||||
@ -209,7 +204,7 @@ class AttribDemo : public finalcut::FWidget
|
||||
{ }
|
||||
|
||||
// Event handler
|
||||
virtual void onWheel (finalcut::FWheelEvent* ev) override
|
||||
void onWheel (finalcut::FWheelEvent* ev) override
|
||||
{
|
||||
auto p = static_cast<AttribDlg*>(getParentWidget());
|
||||
|
||||
@ -234,12 +229,11 @@ class AttribDemo : public finalcut::FWidget
|
||||
void printStandout();
|
||||
void printInvisible();
|
||||
void printProtected();
|
||||
virtual void draw() override;
|
||||
void draw() override;
|
||||
|
||||
// Data Member
|
||||
// Data member
|
||||
int colors;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
AttribDemo::AttribDemo (finalcut::FWidget* parent)
|
||||
@ -259,7 +253,7 @@ void AttribDemo::printColorLine()
|
||||
{
|
||||
auto parent = static_cast<AttribDlg*>(getParent());
|
||||
|
||||
for (FColor color = 0; color < colors; color++)
|
||||
for (FColor color{0}; color < colors; color++)
|
||||
{
|
||||
print() << FColorPair(color, parent->bgcolor) << " # ";
|
||||
}
|
||||
@ -268,6 +262,7 @@ void AttribDemo::printColorLine()
|
||||
//----------------------------------------------------------------------
|
||||
void AttribDemo::printAltCharset()
|
||||
{
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
auto parent = static_cast<AttribDlg*>(getParent());
|
||||
|
||||
if ( ! isMonochron() )
|
||||
@ -275,9 +270,9 @@ void AttribDemo::printAltCharset()
|
||||
|
||||
print() << FPoint(1, 1) << "alternate charset: ";
|
||||
|
||||
if ( parent->bgcolor == finalcut::fc::Default )
|
||||
if ( parent->bgcolor == fc::Default )
|
||||
{
|
||||
setColor (finalcut::fc::Default, finalcut::fc::Default);
|
||||
setColor (fc::Default, fc::Default);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -285,9 +280,9 @@ void AttribDemo::printAltCharset()
|
||||
|| (parent->bgcolor >= 16 && parent->bgcolor <= 231
|
||||
&& (parent->bgcolor - 16) % 36 <= 17)
|
||||
|| (parent->bgcolor >= 232 && parent->bgcolor <= 243) )
|
||||
setColor (finalcut::fc::White, parent->bgcolor);
|
||||
setColor (fc::White, parent->bgcolor);
|
||||
else
|
||||
setColor (finalcut::fc::Black, parent->bgcolor);
|
||||
setColor (fc::Black, parent->bgcolor);
|
||||
}
|
||||
|
||||
setAltCharset();
|
||||
@ -418,6 +413,7 @@ void AttribDemo::printProtected()
|
||||
void AttribDemo::draw()
|
||||
{
|
||||
// test alternate character set
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
printAltCharset();
|
||||
|
||||
std::vector<std::function<void()> > effect
|
||||
@ -437,7 +433,7 @@ void AttribDemo::draw()
|
||||
[&] { printProtected(); },
|
||||
};
|
||||
|
||||
for (std::size_t y = 0; y < getParentWidget()->getHeight() - 7; y++)
|
||||
for (std::size_t y{0}; y < getParentWidget()->getHeight() - 7; y++)
|
||||
{
|
||||
print() << FPoint(1, 2 + int(y));
|
||||
|
||||
@ -455,7 +451,7 @@ void AttribDemo::draw()
|
||||
FColor bg = static_cast<AttribDlg*>(getParent())->bgcolor;
|
||||
print (" Background color:");
|
||||
|
||||
if ( bg == finalcut::fc::Default )
|
||||
if ( bg == fc::Default )
|
||||
print (" default");
|
||||
else
|
||||
printf ( " %d", bg);
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2018 Markus Gans *
|
||||
* Copyright 2017-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -26,9 +26,7 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
|
||||
// Global FVTerm object
|
||||
static finalcut::FVTerm* terminal;
|
||||
namespace fc = finalcut::fc;
|
||||
|
||||
// Function prototype
|
||||
void tcapBoolean (const std::string&, bool);
|
||||
@ -37,117 +35,113 @@ void tcapString (const std::string&, const char[]);
|
||||
void debug (finalcut::FApplication&);
|
||||
void booleans();
|
||||
void numeric();
|
||||
void string(finalcut::FTermcap::tcap_map*&);
|
||||
void string();
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// struct data
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
struct data
|
||||
{
|
||||
static int getNumberOfItems();
|
||||
|
||||
struct termcap_string
|
||||
struct alignas(alignof(std::string)) termcap_string
|
||||
{
|
||||
const std::string name;
|
||||
const finalcut::fc::termcaps cap;
|
||||
const fc::termcaps cap;
|
||||
};
|
||||
|
||||
static termcap_string strings[];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// struct data - string data array
|
||||
//----------------------------------------------------------------------
|
||||
data::termcap_string data::strings[] =
|
||||
{
|
||||
{ "t_bell", finalcut::fc::t_bell },
|
||||
{ "t_erase_chars", finalcut::fc::t_erase_chars },
|
||||
{ "t_clear_screen", finalcut::fc::t_clear_screen },
|
||||
{ "t_clr_eos", finalcut::fc::t_clr_eos },
|
||||
{ "t_clr_eol", finalcut::fc::t_clr_eol },
|
||||
{ "t_clr_bol", finalcut::fc::t_clr_bol },
|
||||
{ "t_cursor_home", finalcut::fc::t_cursor_home },
|
||||
{ "t_cursor_to_ll", finalcut::fc::t_cursor_to_ll },
|
||||
{ "t_carriage_return", finalcut::fc::t_carriage_return },
|
||||
{ "t_tab", finalcut::fc::t_tab },
|
||||
{ "t_back_tab", finalcut::fc::t_back_tab },
|
||||
{ "t_insert_padding", finalcut::fc::t_insert_padding },
|
||||
{ "t_insert_character", finalcut::fc::t_insert_character },
|
||||
{ "t_parm_ich", finalcut::fc::t_parm_ich },
|
||||
{ "t_repeat_char", finalcut::fc::t_repeat_char },
|
||||
{ "t_initialize_color", finalcut::fc::t_initialize_color },
|
||||
{ "t_initialize_pair", finalcut::fc::t_initialize_pair },
|
||||
{ "t_set_a_foreground", finalcut::fc::t_set_a_foreground },
|
||||
{ "t_set_a_background", finalcut::fc::t_set_a_background },
|
||||
{ "t_set_foreground", finalcut::fc::t_set_foreground },
|
||||
{ "t_set_background", finalcut::fc::t_set_background },
|
||||
{ "t_set_color_pair", finalcut::fc::t_set_color_pair },
|
||||
{ "t_orig_pair", finalcut::fc::t_orig_pair },
|
||||
{ "t_orig_colors", finalcut::fc::t_orig_colors },
|
||||
{ "t_no_color_video", finalcut::fc::t_no_color_video },
|
||||
{ "t_cursor_address", finalcut::fc::t_cursor_address },
|
||||
{ "t_column_address", finalcut::fc::t_column_address },
|
||||
{ "t_row_address", finalcut::fc::t_row_address },
|
||||
{ "t_cursor_visible", finalcut::fc::t_cursor_visible },
|
||||
{ "t_cursor_invisible", finalcut::fc::t_cursor_invisible },
|
||||
{ "t_cursor_normal", finalcut::fc::t_cursor_normal },
|
||||
{ "t_cursor_up", finalcut::fc::t_cursor_up },
|
||||
{ "t_cursor_down", finalcut::fc::t_cursor_down },
|
||||
{ "t_cursor_left", finalcut::fc::t_cursor_left },
|
||||
{ "t_cursor_right", finalcut::fc::t_cursor_right },
|
||||
{ "t_parm_up_cursor", finalcut::fc::t_parm_up_cursor },
|
||||
{ "t_parm_down_cursor", finalcut::fc::t_parm_down_cursor },
|
||||
{ "t_parm_left_cursor", finalcut::fc::t_parm_left_cursor },
|
||||
{ "t_parm_right_cursor", finalcut::fc::t_parm_right_cursor },
|
||||
{ "t_save_cursor", finalcut::fc::t_save_cursor },
|
||||
{ "t_restore_cursor", finalcut::fc::t_restore_cursor },
|
||||
{ "t_scroll_forward", finalcut::fc::t_scroll_forward },
|
||||
{ "t_scroll_reverse", finalcut::fc::t_scroll_reverse },
|
||||
{ "t_enter_ca_mode", finalcut::fc::t_enter_ca_mode },
|
||||
{ "t_exit_ca_mode", finalcut::fc::t_exit_ca_mode },
|
||||
{ "t_enable_acs", finalcut::fc::t_enable_acs },
|
||||
{ "t_enter_bold_mode", finalcut::fc::t_enter_bold_mode },
|
||||
{ "t_exit_bold_mode", finalcut::fc::t_exit_bold_mode },
|
||||
{ "t_enter_dim_mode", finalcut::fc::t_enter_dim_mode },
|
||||
{ "t_exit_dim_mode", finalcut::fc::t_exit_dim_mode },
|
||||
{ "t_enter_italics_mode", finalcut::fc::t_enter_italics_mode },
|
||||
{ "t_exit_italics_mode", finalcut::fc::t_exit_italics_mode },
|
||||
{ "t_enter_underline_mode", finalcut::fc::t_enter_underline_mode },
|
||||
{ "t_exit_underline_mode", finalcut::fc::t_exit_underline_mode },
|
||||
{ "t_enter_blink_mode", finalcut::fc::t_enter_blink_mode },
|
||||
{ "t_exit_blink_mode", finalcut::fc::t_exit_blink_mode },
|
||||
{ "t_enter_reverse_mode", finalcut::fc::t_enter_reverse_mode },
|
||||
{ "t_exit_reverse_mode", finalcut::fc::t_exit_reverse_mode },
|
||||
{ "t_enter_standout_mode", finalcut::fc::t_enter_standout_mode },
|
||||
{ "t_exit_standout_mode", finalcut::fc::t_exit_standout_mode },
|
||||
{ "t_enter_secure_mode", finalcut::fc::t_enter_secure_mode },
|
||||
{ "t_exit_secure_mode", finalcut::fc::t_exit_secure_mode },
|
||||
{ "t_enter_protected_mode", finalcut::fc::t_enter_protected_mode },
|
||||
{ "t_exit_protected_mode", finalcut::fc::t_exit_protected_mode },
|
||||
{ "t_enter_crossed_out_mode", finalcut::fc::t_enter_crossed_out_mode },
|
||||
{ "t_exit_crossed_out_mode", finalcut::fc::t_exit_crossed_out_mode },
|
||||
{ "t_enter_dbl_underline_mode", finalcut::fc::t_enter_dbl_underline_mode },
|
||||
{ "t_exit_dbl_underline_mode", finalcut::fc::t_exit_dbl_underline_mode },
|
||||
{ "t_set_attributes", finalcut::fc::t_set_attributes },
|
||||
{ "t_exit_attribute_mode", finalcut::fc::t_exit_attribute_mode },
|
||||
{ "t_enter_alt_charset_mode", finalcut::fc::t_enter_alt_charset_mode },
|
||||
{ "t_exit_alt_charset_mode", finalcut::fc::t_exit_alt_charset_mode },
|
||||
{ "t_enter_pc_charset_mode", finalcut::fc::t_enter_pc_charset_mode },
|
||||
{ "t_exit_pc_charset_mode", finalcut::fc::t_exit_pc_charset_mode },
|
||||
{ "t_enter_insert_mode", finalcut::fc::t_enter_insert_mode },
|
||||
{ "t_exit_insert_mode", finalcut::fc::t_exit_insert_mode },
|
||||
{ "t_enter_am_mode", finalcut::fc::t_enter_am_mode },
|
||||
{ "t_exit_am_mode", finalcut::fc::t_exit_am_mode },
|
||||
{ "t_acs_chars", finalcut::fc::t_acs_chars },
|
||||
{ "t_keypad_xmit", finalcut::fc::t_keypad_xmit },
|
||||
{ "t_keypad_local", finalcut::fc::t_keypad_local },
|
||||
{ "t_key_mouse", finalcut::fc::t_key_mouse }
|
||||
{ "t_bell", fc::t_bell },
|
||||
{ "t_erase_chars", fc::t_erase_chars },
|
||||
{ "t_clear_screen", fc::t_clear_screen },
|
||||
{ "t_clr_eos", fc::t_clr_eos },
|
||||
{ "t_clr_eol", fc::t_clr_eol },
|
||||
{ "t_clr_bol", fc::t_clr_bol },
|
||||
{ "t_cursor_home", fc::t_cursor_home },
|
||||
{ "t_cursor_to_ll", fc::t_cursor_to_ll },
|
||||
{ "t_carriage_return", fc::t_carriage_return },
|
||||
{ "t_tab", fc::t_tab },
|
||||
{ "t_back_tab", fc::t_back_tab },
|
||||
{ "t_insert_padding", fc::t_insert_padding },
|
||||
{ "t_insert_character", fc::t_insert_character },
|
||||
{ "t_parm_ich", fc::t_parm_ich },
|
||||
{ "t_repeat_char", fc::t_repeat_char },
|
||||
{ "t_initialize_color", fc::t_initialize_color },
|
||||
{ "t_initialize_pair", fc::t_initialize_pair },
|
||||
{ "t_set_a_foreground", fc::t_set_a_foreground },
|
||||
{ "t_set_a_background", fc::t_set_a_background },
|
||||
{ "t_set_foreground", fc::t_set_foreground },
|
||||
{ "t_set_background", fc::t_set_background },
|
||||
{ "t_set_color_pair", fc::t_set_color_pair },
|
||||
{ "t_orig_pair", fc::t_orig_pair },
|
||||
{ "t_orig_colors", fc::t_orig_colors },
|
||||
{ "t_no_color_video", fc::t_no_color_video },
|
||||
{ "t_cursor_address", fc::t_cursor_address },
|
||||
{ "t_column_address", fc::t_column_address },
|
||||
{ "t_row_address", fc::t_row_address },
|
||||
{ "t_cursor_visible", fc::t_cursor_visible },
|
||||
{ "t_cursor_invisible", fc::t_cursor_invisible },
|
||||
{ "t_cursor_normal", fc::t_cursor_normal },
|
||||
{ "t_cursor_up", fc::t_cursor_up },
|
||||
{ "t_cursor_down", fc::t_cursor_down },
|
||||
{ "t_cursor_left", fc::t_cursor_left },
|
||||
{ "t_cursor_right", fc::t_cursor_right },
|
||||
{ "t_parm_up_cursor", fc::t_parm_up_cursor },
|
||||
{ "t_parm_down_cursor", fc::t_parm_down_cursor },
|
||||
{ "t_parm_left_cursor", fc::t_parm_left_cursor },
|
||||
{ "t_parm_right_cursor", fc::t_parm_right_cursor },
|
||||
{ "t_save_cursor", fc::t_save_cursor },
|
||||
{ "t_restore_cursor", fc::t_restore_cursor },
|
||||
{ "t_scroll_forward", fc::t_scroll_forward },
|
||||
{ "t_scroll_reverse", fc::t_scroll_reverse },
|
||||
{ "t_enter_ca_mode", fc::t_enter_ca_mode },
|
||||
{ "t_exit_ca_mode", fc::t_exit_ca_mode },
|
||||
{ "t_enable_acs", fc::t_enable_acs },
|
||||
{ "t_enter_bold_mode", fc::t_enter_bold_mode },
|
||||
{ "t_exit_bold_mode", fc::t_exit_bold_mode },
|
||||
{ "t_enter_dim_mode", fc::t_enter_dim_mode },
|
||||
{ "t_exit_dim_mode", fc::t_exit_dim_mode },
|
||||
{ "t_enter_italics_mode", fc::t_enter_italics_mode },
|
||||
{ "t_exit_italics_mode", fc::t_exit_italics_mode },
|
||||
{ "t_enter_underline_mode", fc::t_enter_underline_mode },
|
||||
{ "t_exit_underline_mode", fc::t_exit_underline_mode },
|
||||
{ "t_enter_blink_mode", fc::t_enter_blink_mode },
|
||||
{ "t_exit_blink_mode", fc::t_exit_blink_mode },
|
||||
{ "t_enter_reverse_mode", fc::t_enter_reverse_mode },
|
||||
{ "t_exit_reverse_mode", fc::t_exit_reverse_mode },
|
||||
{ "t_enter_standout_mode", fc::t_enter_standout_mode },
|
||||
{ "t_exit_standout_mode", fc::t_exit_standout_mode },
|
||||
{ "t_enter_secure_mode", fc::t_enter_secure_mode },
|
||||
{ "t_exit_secure_mode", fc::t_exit_secure_mode },
|
||||
{ "t_enter_protected_mode", fc::t_enter_protected_mode },
|
||||
{ "t_exit_protected_mode", fc::t_exit_protected_mode },
|
||||
{ "t_enter_crossed_out_mode", fc::t_enter_crossed_out_mode },
|
||||
{ "t_exit_crossed_out_mode", fc::t_exit_crossed_out_mode },
|
||||
{ "t_enter_dbl_underline_mode", fc::t_enter_dbl_underline_mode },
|
||||
{ "t_exit_dbl_underline_mode", fc::t_exit_dbl_underline_mode },
|
||||
{ "t_set_attributes", fc::t_set_attributes },
|
||||
{ "t_exit_attribute_mode", fc::t_exit_attribute_mode },
|
||||
{ "t_enter_alt_charset_mode", fc::t_enter_alt_charset_mode },
|
||||
{ "t_exit_alt_charset_mode", fc::t_exit_alt_charset_mode },
|
||||
{ "t_enter_pc_charset_mode", fc::t_enter_pc_charset_mode },
|
||||
{ "t_exit_pc_charset_mode", fc::t_exit_pc_charset_mode },
|
||||
{ "t_enter_insert_mode", fc::t_enter_insert_mode },
|
||||
{ "t_exit_insert_mode", fc::t_exit_insert_mode },
|
||||
{ "t_enter_am_mode", fc::t_enter_am_mode },
|
||||
{ "t_exit_am_mode", fc::t_exit_am_mode },
|
||||
{ "t_acs_chars", fc::t_acs_chars },
|
||||
{ "t_keypad_xmit", fc::t_keypad_xmit },
|
||||
{ "t_keypad_local", fc::t_keypad_local },
|
||||
{ "t_key_mouse", fc::t_key_mouse }
|
||||
};
|
||||
|
||||
// data inline functions
|
||||
@ -180,8 +174,7 @@ void tcapNumeric (const std::string& name, int cap_num)
|
||||
//----------------------------------------------------------------------
|
||||
void tcapString (const std::string& name, const char cap_str[])
|
||||
{
|
||||
uInt len;
|
||||
std::string sequence;
|
||||
std::string sequence{};
|
||||
std::cout << name << ": ";
|
||||
|
||||
if ( cap_str == 0 )
|
||||
@ -190,9 +183,9 @@ void tcapString (const std::string& name, const char cap_str[])
|
||||
return;
|
||||
}
|
||||
|
||||
len = uInt(std::strlen(cap_str));
|
||||
uInt len = uInt(std::strlen(cap_str));
|
||||
|
||||
for (uInt i = 0; i < len; i++)
|
||||
for (uInt i{0}; i < len; i++)
|
||||
{
|
||||
uChar c = uChar(cap_str[i]);
|
||||
|
||||
@ -225,7 +218,8 @@ void tcapString (const std::string& name, const char cap_str[])
|
||||
#if DEBUG
|
||||
void debug (finalcut::FApplication& TermApp)
|
||||
{
|
||||
finalcut::FTermDebugData& debug_data = TermApp.getFTermDebugData();
|
||||
auto& fterm = TermApp.getFTerm();
|
||||
auto& debug_data = fterm.getFTermDebugData();
|
||||
const finalcut::FString& ab_s = debug_data.getAnswerbackString();
|
||||
const finalcut::FString& sec_da = debug_data.getSecDAString();
|
||||
std::cout << "\n.------------------- debug -------------------\r\n";
|
||||
@ -290,15 +284,17 @@ void numeric()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void string(finalcut::FTermcap::tcap_map*& tcap)
|
||||
void string()
|
||||
{
|
||||
std::cout << "\r\n[String]\r\n";
|
||||
finalcut::FTermcap::tcap_map (&tcap_strings)[] \
|
||||
= finalcut::FTermcap::strings;
|
||||
|
||||
for (int n = 0; n <= data::getNumberOfItems(); n++ )
|
||||
for (int n{0}; n <= data::getNumberOfItems(); n++ )
|
||||
{
|
||||
const std::string name = data::strings[n].name;
|
||||
const finalcut::fc::termcaps cap = data::strings[n].cap;
|
||||
tcapString (name, tcap[cap].string);
|
||||
const fc::termcaps cap = data::strings[n].cap;
|
||||
tcapString (name, tcap_strings[cap].string);
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,15 +303,9 @@ void string(finalcut::FTermcap::tcap_map*& tcap)
|
||||
//----------------------------------------------------------------------
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
bool disable_alt_screen = true;
|
||||
bool disable_alt_screen{true};
|
||||
finalcut::FApplication TermApp (argc, argv, disable_alt_screen);
|
||||
|
||||
// Pointer to the global virtual terminal object
|
||||
terminal = static_cast<finalcut::FVTerm*>(&TermApp);
|
||||
|
||||
finalcut::FTermcap::tcap_map* tcap = nullptr;
|
||||
tcap = finalcut::FTermcap::getTermcapMap();
|
||||
|
||||
std::cout << "--------\r\nFTermcap\r\n--------\r\n\n";
|
||||
std::cout << "Terminal: " << TermApp.getTermType() << "\r\n";
|
||||
|
||||
@ -323,5 +313,5 @@ int main (int argc, char* argv[])
|
||||
|
||||
booleans();
|
||||
numeric();
|
||||
string(tcap);
|
||||
string();
|
||||
}
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class Timer
|
||||
@ -35,11 +37,11 @@ class Timer : public finalcut::FWidget
|
||||
|
||||
protected:
|
||||
// Method
|
||||
virtual void draw() override;
|
||||
void draw() override;
|
||||
|
||||
// Event handlers
|
||||
virtual void onTimer (finalcut::FTimerEvent*) override;
|
||||
virtual void onAccel (finalcut::FAccelEvent*) override;
|
||||
void onTimer (finalcut::FTimerEvent*) override;
|
||||
void onAccel (finalcut::FAccelEvent*) override;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -52,8 +54,8 @@ Timer::Timer (finalcut::FWidget* parent)
|
||||
delTimer (id);
|
||||
addTimer (250); // 250-millisecond timer
|
||||
|
||||
wc.term_fg = finalcut::fc::Default;
|
||||
wc.term_bg = finalcut::fc::Default;
|
||||
setFWidgetColors().term_fg = fc::Default;
|
||||
setFWidgetColors().term_bg = fc::Default;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -63,13 +65,13 @@ void Timer::draw()
|
||||
<< "---------------\n"
|
||||
<< "Press Q to quit\n"
|
||||
<< "---------------\n";
|
||||
setAreaCursor (finalcut::FPoint(1, 4), true, vdesktop);
|
||||
setAreaCursor (finalcut::FPoint(1, 4), true, getVirtualDesktop());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Timer::onTimer (finalcut::FTimerEvent* ev)
|
||||
{
|
||||
bool is_last_line = false;
|
||||
bool is_last_line{false};
|
||||
int timer_id = ev->getTimerId();
|
||||
|
||||
if ( getPrintPos().getY() == int(getDesktopHeight()) )
|
||||
@ -79,10 +81,10 @@ void Timer::onTimer (finalcut::FTimerEvent* ev)
|
||||
<< "Timer event, id " << timer_id << '\n';
|
||||
|
||||
if ( is_last_line )
|
||||
scrollAreaForward (vdesktop);
|
||||
scrollAreaForward (getVirtualDesktop());
|
||||
|
||||
setAreaCursor ( finalcut::FPoint(1, getPrintPos().getY())
|
||||
, true, vdesktop );
|
||||
, true, getVirtualDesktop() );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -100,8 +102,8 @@ int main (int argc, char* argv[])
|
||||
{
|
||||
// Create the application object
|
||||
finalcut::FApplication app(argc, argv);
|
||||
app.setForegroundColor(finalcut::fc::Default);
|
||||
app.setBackgroundColor(finalcut::fc::Default);
|
||||
app.setForegroundColor(fc::Default);
|
||||
app.setBackgroundColor(fc::Default);
|
||||
|
||||
// Create a timer object t
|
||||
Timer t(&app);
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -30,9 +31,6 @@ using finalcut::FSize;
|
||||
// class Transparent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Transparent : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -59,15 +57,14 @@ class Transparent : public finalcut::FDialog
|
||||
|
||||
private:
|
||||
// Method
|
||||
virtual void draw() override;
|
||||
void draw() override;
|
||||
|
||||
// Event handlers
|
||||
virtual void onKeyPress (finalcut::FKeyEvent* ev) override;
|
||||
void onKeyPress (finalcut::FKeyEvent* ev) override;
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
trans_type type;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Transparent::Transparent ( finalcut::FWidget* parent
|
||||
@ -92,15 +89,16 @@ void Transparent::draw()
|
||||
|
||||
if ( type == shadow )
|
||||
{
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
setColor(wc.shadow_bg, wc.shadow_fg);
|
||||
setTransShadow();
|
||||
}
|
||||
else if ( type == inherit_background )
|
||||
{
|
||||
if ( getMaxColor() > 8 )
|
||||
setColor(finalcut::fc::Blue, finalcut::fc::Black);
|
||||
setColor(fc::Blue, fc::Black);
|
||||
else
|
||||
setColor(finalcut::fc::Green, finalcut::fc::Black);
|
||||
setColor(fc::Green, fc::Black);
|
||||
|
||||
setInheritBackground();
|
||||
}
|
||||
@ -109,7 +107,7 @@ void Transparent::draw()
|
||||
|
||||
finalcut::FString line(getClientWidth(), '.');
|
||||
|
||||
for (int n = 1; n <= int(getClientHeight()); n++)
|
||||
for (int n{1}; n <= int(getClientHeight()); n++)
|
||||
{
|
||||
print() << FPoint(2, 2 + n) << line;
|
||||
}
|
||||
@ -145,9 +143,6 @@ void Transparent::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
// class MainWindow
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class MainWindow : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -165,13 +160,13 @@ class MainWindow : public finalcut::FDialog
|
||||
|
||||
private:
|
||||
// Method
|
||||
virtual void draw() override;
|
||||
void draw() override;
|
||||
|
||||
// Event handlers
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
virtual void onShow (finalcut::FShowEvent*) override;
|
||||
virtual void onTimer (finalcut::FTimerEvent*) override;
|
||||
virtual void onKeyPress (finalcut::FKeyEvent* ev) override
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
void onShow (finalcut::FShowEvent*) override;
|
||||
void onTimer (finalcut::FTimerEvent*) override;
|
||||
void onKeyPress (finalcut::FKeyEvent* ev) override
|
||||
{
|
||||
if ( ! ev )
|
||||
return;
|
||||
@ -185,7 +180,7 @@ class MainWindow : public finalcut::FDialog
|
||||
finalcut::FDialog::onKeyPress(ev);
|
||||
}
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
finalcut::FString line1{};
|
||||
finalcut::FString line2{};
|
||||
Transparent* transpwin{nullptr};
|
||||
@ -193,7 +188,7 @@ class MainWindow : public finalcut::FDialog
|
||||
Transparent* ibg{nullptr};
|
||||
finalcut::FStatusBar status_bar{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
MainWindow::MainWindow (finalcut::FWidget* parent)
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -111,9 +112,6 @@ bool sortDescending ( const finalcut::FObject* lhs
|
||||
// class Treeview
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Treeview : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -134,12 +132,12 @@ class Treeview : public finalcut::FDialog
|
||||
struct TreeItem; // forward declaration
|
||||
|
||||
// Methods
|
||||
virtual void adjustSize() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handler
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
bool initialized{false};
|
||||
finalcut::FListView listView{this};
|
||||
finalcut::FButton Quit{this};
|
||||
@ -150,15 +148,12 @@ class Treeview : public finalcut::FDialog
|
||||
static TreeItem south_america[];
|
||||
static TreeItem oceania[];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// struct Treeview::TreeItem
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
struct Treeview::TreeItem
|
||||
{
|
||||
const char* const* begin() const
|
||||
@ -167,13 +162,12 @@ struct Treeview::TreeItem
|
||||
const char* const* end() const
|
||||
{ return reinterpret_cast<const char* const*>(&child_element); }
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
const char* name;
|
||||
const char* population;
|
||||
const char* density;
|
||||
TreeItem* child_element;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class Treeview - array data
|
||||
@ -314,13 +308,13 @@ Treeview::Treeview (finalcut::FWidget* parent)
|
||||
listView.addColumn ("Density/km²");
|
||||
|
||||
// Set right alignment for the second and third column
|
||||
listView.setColumnAlignment (2, finalcut::fc::alignRight);
|
||||
listView.setColumnAlignment (3, finalcut::fc::alignRight);
|
||||
listView.setColumnAlignment (2, fc::alignRight);
|
||||
listView.setColumnAlignment (3, fc::alignRight);
|
||||
|
||||
// Set the type of sorting
|
||||
listView.setColumnSortType (1, finalcut::fc::by_name);
|
||||
listView.setColumnSortType (2, finalcut::fc::user_defined);
|
||||
listView.setColumnSortType (3, finalcut::fc::user_defined);
|
||||
listView.setColumnSortType (1, fc::by_name);
|
||||
listView.setColumnSortType (2, fc::user_defined);
|
||||
listView.setColumnSortType (3, fc::user_defined);
|
||||
listView.setUserAscendingCompare(sortAscending);
|
||||
listView.setUserDescendingCompare(sortDescending);
|
||||
|
||||
|
@ -21,11 +21,14 @@
|
||||
***********************************************************************/
|
||||
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -34,9 +37,6 @@ using finalcut::FSize;
|
||||
// class ProgressDialog
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class ProgressDialog : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -54,21 +54,20 @@ class ProgressDialog : public finalcut::FDialog
|
||||
|
||||
private:
|
||||
// Event handlers
|
||||
virtual void onShow (finalcut::FShowEvent*) override;
|
||||
virtual void onTimer (finalcut::FTimerEvent*) override;
|
||||
void onShow (finalcut::FShowEvent*) override;
|
||||
void onTimer (finalcut::FTimerEvent*) override;
|
||||
|
||||
// Callback methods
|
||||
void cb_reset_bar (finalcut::FWidget*, FDataPtr);
|
||||
void cb_more_bar (finalcut::FWidget*, FDataPtr);
|
||||
void cb_exit_bar (finalcut::FWidget*, FDataPtr);
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
finalcut::FProgressbar progressBar{this};
|
||||
finalcut::FButton reset{this};
|
||||
finalcut::FButton more{this};
|
||||
finalcut::FButton quit{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
|
||||
@ -180,9 +179,6 @@ void ProgressDialog::cb_exit_bar (finalcut::FWidget*, FDataPtr)
|
||||
// class TextWindow
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class TextWindow : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -203,12 +199,11 @@ class TextWindow : public finalcut::FDialog
|
||||
|
||||
private:
|
||||
// Method
|
||||
virtual void adjustSize() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
finalcut::FTextView scrollText{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
TextWindow::TextWindow (finalcut::FWidget* parent)
|
||||
@ -250,9 +245,6 @@ void TextWindow::adjustSize()
|
||||
// class MyDialog
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class MyDialog : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -269,7 +261,7 @@ class MyDialog : public finalcut::FDialog
|
||||
MyDialog& operator = (const MyDialog&) = delete;
|
||||
|
||||
private:
|
||||
// Method
|
||||
// Methods
|
||||
void initMenu();
|
||||
void initMenuCallbacks();
|
||||
void initFileMenuCallbacks();
|
||||
@ -283,10 +275,10 @@ class MyDialog : public finalcut::FDialog
|
||||
void initButtons();
|
||||
void initLabels();
|
||||
void initWidgetsCallbacks();
|
||||
virtual void adjustSize() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handlers
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Callback methods
|
||||
void cb_noFunctionMsg (finalcut::FWidget*, FDataPtr);
|
||||
@ -305,7 +297,7 @@ class MyDialog : public finalcut::FDialog
|
||||
void cb_view (finalcut::FWidget*, FDataPtr);
|
||||
void cb_setInput (finalcut::FWidget*, FDataPtr);
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
bool initialized{false};
|
||||
finalcut::FMenuBar Menubar{this};
|
||||
// Menu bar items
|
||||
@ -325,21 +317,21 @@ class MyDialog : public finalcut::FDialog
|
||||
finalcut::FMenuItem File2{"/etc/fstab", &Recent};
|
||||
finalcut::FMenuItem File3{"/etc/passwd", &Recent};
|
||||
// "Edit" menu items
|
||||
finalcut::FMenuItem Undo{finalcut::fc::Fckey_z, "Undo", &Edit};
|
||||
finalcut::FMenuItem Redo{finalcut::fc::Fckey_y, "Redo", &Edit};
|
||||
finalcut::FMenuItem Undo{fc::Fckey_z, "Undo", &Edit};
|
||||
finalcut::FMenuItem Redo{fc::Fckey_y, "Redo", &Edit};
|
||||
finalcut::FMenuItem Line2{&Edit};
|
||||
finalcut::FMenuItem Cut{finalcut::fc::Fckey_x, "Cu&t", &Edit};
|
||||
finalcut::FMenuItem Copy{finalcut::fc::Fckey_c, "&Copy", &Edit};
|
||||
finalcut::FMenuItem Paste{finalcut::fc::Fckey_v, "&Paste", &Edit};
|
||||
finalcut::FMenuItem Clear{finalcut::fc::Fkey_dc, "C&lear", &Edit};
|
||||
finalcut::FMenuItem Cut{fc::Fckey_x, "Cu&t", &Edit};
|
||||
finalcut::FMenuItem Copy{fc::Fckey_c, "&Copy", &Edit};
|
||||
finalcut::FMenuItem Paste{fc::Fckey_v, "&Paste", &Edit};
|
||||
finalcut::FMenuItem Clear{fc::Fkey_dc, "C&lear", &Edit};
|
||||
// "View" menu items
|
||||
finalcut::FMenuItem Env{"&Terminal...", &View};
|
||||
finalcut::FMenuItem Drive{"&Drive symbols...", &View};
|
||||
// Statusbar
|
||||
finalcut::FStatusBar Statusbar{this};
|
||||
finalcut::FStatusKey key_F1{finalcut::fc::Fkey_f1, "About", &Statusbar};
|
||||
finalcut::FStatusKey key_F2{finalcut::fc::Fkey_f2, "View", &Statusbar};
|
||||
finalcut::FStatusKey key_F3{finalcut::fc::Fkey_f3, "Quit", &Statusbar};
|
||||
finalcut::FStatusKey key_F1{fc::Fkey_f1, "About", &Statusbar};
|
||||
finalcut::FStatusKey key_F2{fc::Fkey_f2, "View", &Statusbar};
|
||||
finalcut::FStatusKey key_F3{fc::Fkey_f3, "Quit", &Statusbar};
|
||||
// Dialog widgets
|
||||
finalcut::FButton MyButton1{this};
|
||||
finalcut::FButton MyButton2{this};
|
||||
@ -362,7 +354,6 @@ class MyDialog : public finalcut::FDialog
|
||||
finalcut::FLabel sum_count{this};
|
||||
finalcut::FString clipboard{};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
MyDialog::MyDialog (finalcut::FWidget* parent)
|
||||
@ -393,11 +384,11 @@ void MyDialog::initMenu()
|
||||
Help.setStatusbarMessage ("Show version and copyright information");
|
||||
|
||||
// "File" menu items
|
||||
Open.addAccelerator (finalcut::fc::Fckey_o); // Ctrl + O
|
||||
Open.addAccelerator (fc::Fckey_o); // Ctrl + O
|
||||
Open.setStatusbarMessage ("Locate and open a text file");
|
||||
Recent.setStatusbarMessage ("View text file");
|
||||
Line1.setSeparator();
|
||||
Quit.addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X
|
||||
Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X
|
||||
Quit.setStatusbarMessage ("Exit the program");
|
||||
|
||||
// "Edit" menu items
|
||||
@ -565,10 +556,12 @@ void MyDialog::initWidgets()
|
||||
// A multiple selection listbox
|
||||
myList.setGeometry(FPoint(38, 1), FSize(14, 17));
|
||||
myList.setText ("Items");
|
||||
|
||||
myList.setStatusbarMessage ("99 items in a list");
|
||||
myList.setMultiSelection();
|
||||
myList.reserve(100);
|
||||
|
||||
for (int z = 1; z < 100; z++)
|
||||
for (int z{1}; z < 100; z++)
|
||||
myList.insert (finalcut::FString() << z << L" placeholder");
|
||||
|
||||
// Text labels
|
||||
@ -584,14 +577,14 @@ void MyDialog::initFlatButtons()
|
||||
MyButton1.setStatusbarMessage ("Sine function");
|
||||
MyButton1.setNoUnderline();
|
||||
MyButton1.setFlat();
|
||||
MyButton1.setDoubleFlatLine (finalcut::fc::bottom);
|
||||
MyButton1.setDoubleFlatLine (fc::bottom);
|
||||
|
||||
MyButton2.setGeometry(FPoint(3, 5), FSize(5, 1));
|
||||
MyButton2.setText (L"&COS");
|
||||
MyButton2.setStatusbarMessage ("Cosine function");
|
||||
MyButton2.setNoUnderline();
|
||||
MyButton2.setFlat();
|
||||
MyButton2.setDoubleFlatLine (finalcut::fc::top);
|
||||
MyButton2.setDoubleFlatLine (fc::top);
|
||||
|
||||
MyButton3.setGeometry(FPoint(10, 3), FSize(5, 3));
|
||||
MyButton3.setText (L"&=");
|
||||
@ -692,7 +685,7 @@ void MyDialog::initLabels()
|
||||
// Text labels
|
||||
headline.setGeometry(FPoint(21, 3), FSize(10, 1));
|
||||
headline.setEmphasis();
|
||||
headline.setAlignment (finalcut::fc::alignCenter);
|
||||
headline.setAlignment (fc::alignCenter);
|
||||
headline = L"List items";
|
||||
|
||||
tagged.setGeometry(FPoint(21, 4), FSize(7, 1));
|
||||
@ -701,7 +694,7 @@ void MyDialog::initLabels()
|
||||
tagged_count << 0;
|
||||
|
||||
sum.setGeometry(FPoint(21, 5), FSize(7, 3));
|
||||
sum.setAlignment (finalcut::fc::alignRight);
|
||||
sum.setAlignment (fc::alignRight);
|
||||
|
||||
sum_count.setGeometry(FPoint(29, 5), FSize(5, 3));
|
||||
sum_count << myList.getCount();
|
||||
@ -745,7 +738,7 @@ void MyDialog::adjustSize()
|
||||
{
|
||||
auto h = getParentWidget()->getHeight() - 4;
|
||||
setHeight (h, false);
|
||||
auto X = int((getDesktopWidth() - getWidth()) / 2);
|
||||
int X = int((getDesktopWidth() - getWidth()) / 2);
|
||||
|
||||
if ( X < 1 )
|
||||
X = 1;
|
||||
@ -779,7 +772,7 @@ void MyDialog::cb_noFunctionMsg (finalcut::FWidget* widget, FDataPtr)
|
||||
void MyDialog::cb_about (finalcut::FWidget*, FDataPtr)
|
||||
{
|
||||
constexpr char libver[] = F_VERSION;
|
||||
const finalcut::FString line(2, finalcut::fc::BoxDrawingsHorizontal);
|
||||
const finalcut::FString line(2, fc::BoxDrawingsHorizontal);
|
||||
|
||||
finalcut::FMessageBox info ( "About"
|
||||
, line + L" The Final Cut " + line + "\n\n"
|
||||
@ -802,7 +795,7 @@ void MyDialog::cb_terminfo (finalcut::FWidget*, FDataPtr)
|
||||
<< " Type: " << getTermType() << "\n"
|
||||
<< " Name: " << getTermFileName() << "\n"
|
||||
<< " Mode: " << getEncodingString() << "\n"
|
||||
<< " Size: " << x << finalcut::fc::Times
|
||||
<< " Size: " << x << fc::Times
|
||||
<< y << "\n"
|
||||
<< "Colors: " << getMaxColor()
|
||||
, finalcut::FMessageBox::Ok, 0, 0, this
|
||||
@ -850,12 +843,12 @@ void MyDialog::cb_drives (finalcut::FWidget*, FDataPtr)
|
||||
}
|
||||
else
|
||||
{
|
||||
net.setForegroundColor (finalcut::fc::White);
|
||||
net.setBackgroundColor (finalcut::fc::DarkGray);
|
||||
drive.setForegroundColor (finalcut::fc::White);
|
||||
drive.setBackgroundColor (finalcut::fc::DarkGray);
|
||||
cd.setForegroundColor (finalcut::fc::White);
|
||||
cd.setBackgroundColor (finalcut::fc::DarkGray);
|
||||
net.setForegroundColor (fc::White);
|
||||
net.setBackgroundColor (fc::DarkGray);
|
||||
drive.setForegroundColor (fc::White);
|
||||
drive.setBackgroundColor (fc::DarkGray);
|
||||
cd.setForegroundColor (fc::White);
|
||||
cd.setBackgroundColor (fc::DarkGray);
|
||||
}
|
||||
|
||||
info2.exec();
|
||||
@ -926,7 +919,7 @@ void MyDialog::cb_updateNumber (finalcut::FWidget* widget, FDataPtr data)
|
||||
const auto& count = list.getCount();
|
||||
int select_num = 0;
|
||||
|
||||
for (std::size_t n = 1; n <= count; n++)
|
||||
for (std::size_t n{1}; n <= count; n++)
|
||||
if ( list.isSelected(n) )
|
||||
select_num++;
|
||||
|
||||
@ -1002,10 +995,10 @@ void MyDialog::cb_setInput (finalcut::FWidget* widget, FDataPtr data)
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
const finalcut::FString ver = F_VERSION; // Library version
|
||||
const finalcut::FString title = "The FINAL CUT "
|
||||
const finalcut::FString ver{F_VERSION}; // Library version
|
||||
const finalcut::FString title { "The FINAL CUT "
|
||||
+ ver
|
||||
+ " (C) 2019 by Markus Gans";
|
||||
+ " (C) 2019 by Markus Gans" };
|
||||
|
||||
// Create the application object app
|
||||
finalcut::FApplication app(argc, argv);
|
||||
|
@ -31,9 +31,6 @@ using finalcut::FSize;
|
||||
// class Watch
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Watch : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -53,8 +50,8 @@ class Watch : public finalcut::FDialog
|
||||
void printTime();
|
||||
|
||||
// Event handlers
|
||||
virtual void onTimer (finalcut::FTimerEvent*) override;
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
void onTimer (finalcut::FTimerEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Callback methods
|
||||
void cb_clock (finalcut::FWidget*, FDataPtr);
|
||||
@ -62,10 +59,10 @@ class Watch : public finalcut::FDialog
|
||||
|
||||
protected:
|
||||
// Method
|
||||
virtual void adjustSize() override;
|
||||
void adjustSize() override;
|
||||
|
||||
private:
|
||||
// Data Members
|
||||
// Data members
|
||||
bool sec{true};
|
||||
finalcut::FLabel time_label{L"Time", this};
|
||||
finalcut::FLabel time_str{L"--:--:--", this};
|
||||
@ -73,7 +70,6 @@ class Watch : public finalcut::FDialog
|
||||
finalcut::FSwitch seconds_sw{L"Seconds", this};
|
||||
finalcut::FButton quit_btn{L"&Quit", this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Watch::Watch (FWidget* parent)
|
||||
@ -127,11 +123,10 @@ Watch::~Watch()
|
||||
//----------------------------------------------------------------------
|
||||
void Watch::printTime()
|
||||
{
|
||||
finalcut::FString str;
|
||||
std::tm now;
|
||||
std::time_t t;
|
||||
finalcut::FString str{};
|
||||
std::tm now{};
|
||||
|
||||
t = std::time(0); // get current time
|
||||
std::time_t t = std::time(0); // get current time
|
||||
localtime_r(&t, &now);
|
||||
|
||||
if ( sec )
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <vector>
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -31,9 +32,6 @@ using finalcut::FSize;
|
||||
// class SmallWindow
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class SmallWindow : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -51,28 +49,29 @@ class SmallWindow : public finalcut::FDialog
|
||||
|
||||
private:
|
||||
// Method
|
||||
virtual void adjustSize() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handlers
|
||||
virtual void onShow (finalcut::FShowEvent*) override;
|
||||
virtual void onTimer (finalcut::FTimerEvent*) override;
|
||||
void onShow (finalcut::FShowEvent*) override;
|
||||
void onTimer (finalcut::FTimerEvent*) override;
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
finalcut::FLabel left_arrow{this};
|
||||
finalcut::FLabel right_arrow{this};
|
||||
finalcut::FLabel top_left_label{this};
|
||||
finalcut::FLabel top_right_label{this};
|
||||
finalcut::FLabel bottom_label{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
SmallWindow::SmallWindow (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
{
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
wchar_t arrow_up, arrow_down;
|
||||
arrow_up = finalcut::fc::BlackUpPointingTriangle;
|
||||
arrow_down = finalcut::fc::BlackDownPointingTriangle;
|
||||
arrow_up = fc::BlackUpPointingTriangle;
|
||||
arrow_down = fc::BlackDownPointingTriangle;
|
||||
|
||||
left_arrow = arrow_up;
|
||||
left_arrow.setForegroundColor (wc.label_inactive_fg);
|
||||
@ -92,16 +91,16 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
|
||||
top_left_label.setGeometry (FPoint(1, 1), FSize(6, 1));
|
||||
|
||||
top_right_label = "zoom";
|
||||
top_right_label.setAlignment (finalcut::fc::alignRight);
|
||||
top_right_label.setAlignment (fc::alignRight);
|
||||
top_right_label.setForegroundColor (wc.label_inactive_fg);
|
||||
top_right_label.setEmphasis();
|
||||
top_right_label.setGeometry (FPoint(int(getClientWidth()) - 5, 1), FSize(6, 1));
|
||||
|
||||
finalcut::FString bottom_label_text = "resize\n"
|
||||
"corner\n";
|
||||
finalcut::FString bottom_label_text ( "resize\n"
|
||||
"corner\n" );
|
||||
bottom_label_text += arrow_down;
|
||||
bottom_label = bottom_label_text;
|
||||
bottom_label.setAlignment (finalcut::fc::alignRight);
|
||||
bottom_label.setAlignment (fc::alignRight);
|
||||
bottom_label.setForegroundColor (wc.label_inactive_fg);
|
||||
bottom_label.setEmphasis();
|
||||
bottom_label.setGeometry (FPoint(13, 3), FSize(6, 3));
|
||||
@ -165,9 +164,6 @@ void SmallWindow::onTimer (finalcut::FTimerEvent*)
|
||||
// class Window
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class Window : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
@ -198,7 +194,7 @@ class Window : public finalcut::FDialog
|
||||
// Disable assignment operator (=)
|
||||
win_data& operator = (const win_data&) = delete;
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
bool is_open{false};
|
||||
finalcut::FString title{};
|
||||
SmallWindow* dgl{nullptr};
|
||||
@ -208,12 +204,12 @@ class Window : public finalcut::FDialog
|
||||
void configureFileMenuItems();
|
||||
void configureDialogButtons();
|
||||
void activateWindow (finalcut::FDialog*);
|
||||
virtual void adjustSize() override;
|
||||
void adjustSize() override;
|
||||
void addClickedCallback (finalcut::FWidget*, WindowCallback);
|
||||
void addClickedCallback (finalcut::FWidget*, FAppCallback);
|
||||
|
||||
// Event handlers
|
||||
virtual void onClose (finalcut::FCloseEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Callback methods
|
||||
void cb_createWindows (finalcut::FWidget*, FDataPtr);
|
||||
@ -222,9 +218,9 @@ class Window : public finalcut::FDialog
|
||||
void cb_previous (finalcut::FWidget*, FDataPtr);
|
||||
void cb_destroyWindow (finalcut::FWidget*, FDataPtr);
|
||||
|
||||
// Data Members
|
||||
// Data members
|
||||
std::vector<win_data*> windows{};
|
||||
finalcut::FString drop_down_symbol{finalcut::fc::BlackDownPointingTriangle};
|
||||
finalcut::FString drop_down_symbol{fc::BlackDownPointingTriangle};
|
||||
finalcut::FMenuBar Menubar{this};
|
||||
finalcut::FMenu File{"&File", &Menubar};
|
||||
finalcut::FDialogListMenu DglList{drop_down_symbol, &Menubar};
|
||||
@ -240,7 +236,7 @@ class Window : public finalcut::FDialog
|
||||
finalcut::FButton CloseButton{this};
|
||||
finalcut::FButton QuitButton{this};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Window::Window (finalcut::FWidget* parent)
|
||||
@ -262,7 +258,7 @@ Window::Window (finalcut::FWidget* parent)
|
||||
Statusbar.setMessage("Status bar message");
|
||||
|
||||
// Generate data vector for the windows
|
||||
for (int n = 1; n <= 6; n++)
|
||||
for (int n{1}; n <= 6; n++)
|
||||
{
|
||||
auto win_dat = new win_data;
|
||||
win_dat->title.sprintf("Window %1d", n);
|
||||
@ -295,12 +291,12 @@ void Window::configureFileMenuItems()
|
||||
New.setStatusbarMessage ("Create the windows");
|
||||
Close.setStatusbarMessage ("Close the windows");
|
||||
Line1.setSeparator();
|
||||
Next.addAccelerator (finalcut::fc::Fmkey_npage); // Meta/Alt + PgDn
|
||||
Next.addAccelerator (fc::Fmkey_npage); // Meta/Alt + PgDn
|
||||
Next.setStatusbarMessage ("Switch to the next window");
|
||||
Previous.addAccelerator (finalcut::fc::Fmkey_ppage); // Meta/Alt + PgUp
|
||||
Previous.addAccelerator (fc::Fmkey_ppage); // Meta/Alt + PgUp
|
||||
Previous.setStatusbarMessage ("Switch to the previous window");
|
||||
Line2.setSeparator();
|
||||
Quit.addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X
|
||||
Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X
|
||||
Quit.setStatusbarMessage ("Exit the program");
|
||||
|
||||
// Add menu item callback
|
||||
@ -346,12 +342,12 @@ void Window::activateWindow (finalcut::FDialog* win)
|
||||
//----------------------------------------------------------------------
|
||||
void Window::adjustSize()
|
||||
{
|
||||
std::size_t w = getDesktopWidth();
|
||||
std::size_t h = getDesktopHeight();
|
||||
int X = int(1 + (w - 40) / 2)
|
||||
, Y = int(1 + (h - 22) / 2)
|
||||
, dx = ( w > 80 ) ? int(w - 80) / 2 : 0
|
||||
, dy = ( h > 24 ) ? int(h - 24) / 2 : 0;
|
||||
std::size_t w = getDesktopWidth();
|
||||
std::size_t h = getDesktopHeight();
|
||||
int X = int(1 + (w - 40) / 2);
|
||||
int Y = int(1 + (h - 22) / 2);
|
||||
int dx = ( w > 80 ) ? int(w - 80) / 2 : 0;
|
||||
int dy = ( h > 24 ) ? int(h - 24) / 2 : 0;
|
||||
|
||||
if ( Y < 2 )
|
||||
Y = 2;
|
||||
@ -364,9 +360,9 @@ void Window::adjustSize()
|
||||
{
|
||||
if ( (*iter)->is_open )
|
||||
{
|
||||
int n = int(std::distance(first, iter))
|
||||
, x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3
|
||||
, y = dy + 11 + int(n / 3) * 3;
|
||||
int n = int(std::distance(first, iter));
|
||||
int x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
|
||||
int y = dy + 11 + int(n / 3) * 3;
|
||||
(*iter)->dgl->setPos (FPoint(x, y));
|
||||
}
|
||||
|
||||
@ -454,11 +450,11 @@ void Window::cb_createWindows (finalcut::FWidget*, FDataPtr)
|
||||
//----------------------------------------------------------------------
|
||||
void Window::cb_closeWindows (finalcut::FWidget*, FDataPtr)
|
||||
{
|
||||
if ( ! dialog_list || dialog_list->empty() )
|
||||
if ( ! getDialogList() || getDialogList()->empty() )
|
||||
return;
|
||||
|
||||
auto iter = dialog_list->end();
|
||||
auto first = dialog_list->begin();
|
||||
auto iter = getDialogList()->end();
|
||||
auto first = getDialogList()->begin();
|
||||
activateWindow(this);
|
||||
|
||||
do
|
||||
@ -474,12 +470,12 @@ void Window::cb_closeWindows (finalcut::FWidget*, FDataPtr)
|
||||
//----------------------------------------------------------------------
|
||||
void Window::cb_next (finalcut::FWidget*, FDataPtr)
|
||||
{
|
||||
if ( ! dialog_list || dialog_list->empty() )
|
||||
if ( ! getDialogList() || getDialogList()->empty() )
|
||||
return;
|
||||
|
||||
auto iter = dialog_list->begin();
|
||||
auto iter = getDialogList()->begin();
|
||||
|
||||
while ( iter != dialog_list->end() )
|
||||
while ( iter != getDialogList()->end() )
|
||||
{
|
||||
if ( static_cast<finalcut::FWindow*>(*iter)->isWindowActive() )
|
||||
{
|
||||
@ -490,8 +486,8 @@ void Window::cb_next (finalcut::FWidget*, FDataPtr)
|
||||
{
|
||||
++next_element;
|
||||
|
||||
if ( next_element == dialog_list->end() )
|
||||
next_element = dialog_list->begin();
|
||||
if ( next_element == getDialogList()->end() )
|
||||
next_element = getDialogList()->begin();
|
||||
|
||||
next = static_cast<finalcut::FDialog*>(*next_element);
|
||||
} while ( ! next->isEnabled()
|
||||
@ -510,10 +506,10 @@ void Window::cb_next (finalcut::FWidget*, FDataPtr)
|
||||
//----------------------------------------------------------------------
|
||||
void Window::cb_previous (finalcut::FWidget*, FDataPtr)
|
||||
{
|
||||
if ( ! dialog_list || dialog_list->empty() )
|
||||
if ( ! getDialogList() || getDialogList()->empty() )
|
||||
return;
|
||||
|
||||
auto iter = dialog_list->end();
|
||||
auto iter = getDialogList()->end();
|
||||
|
||||
do
|
||||
{
|
||||
@ -527,8 +523,8 @@ void Window::cb_previous (finalcut::FWidget*, FDataPtr)
|
||||
|
||||
do
|
||||
{
|
||||
if ( prev_element == dialog_list->begin() )
|
||||
prev_element = dialog_list->end();
|
||||
if ( prev_element == getDialogList()->begin() )
|
||||
prev_element = getDialogList()->end();
|
||||
|
||||
--prev_element;
|
||||
prev = static_cast<finalcut::FDialog*>(*prev_element);
|
||||
@ -541,7 +537,7 @@ void Window::cb_previous (finalcut::FWidget*, FDataPtr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ( iter != dialog_list->begin() );
|
||||
while ( iter != getDialogList()->begin() );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
test -f 8x16graph.pcf.gz && rm 8x16graph.pcf.gz
|
||||
bdftopcf -o 8x16graph.pcf 8x16graph.bdf
|
||||
|
@ -14,7 +14,6 @@ static struct unipair unicode_cp437_pairs[] =
|
||||
// .----------- unicode
|
||||
// | .---- fontpos
|
||||
// | |
|
||||
{0x0000, 0x00},
|
||||
{0x0020, 0x20},
|
||||
{0x0021, 0x21},
|
||||
{0x0022, 0x22},
|
||||
@ -114,65 +113,34 @@ static struct unipair unicode_cp437_pairs[] =
|
||||
{0x00a1, 0xad},
|
||||
{0x00a2, 0x9b},
|
||||
{0x00a3, 0x9c},
|
||||
{0x00a4, 0x0f},
|
||||
{0x00a5, 0x9d},
|
||||
{0x00a6, 0x7c},
|
||||
{0x00a7, 0x15},
|
||||
{0x00a8, 0x22},
|
||||
{0x00a9, 0x43},
|
||||
{0x00aa, 0xa6},
|
||||
{0x00ab, 0xae},
|
||||
{0x00ac, 0xaa},
|
||||
{0x00ad, 0x2d},
|
||||
{0x00ae, 0x52},
|
||||
{0x00b0, 0xf8},
|
||||
{0x00b1, 0xf1},
|
||||
{0x00b2, 0xfd},
|
||||
{0x00b4, 0x27},
|
||||
{0x00b5, 0xe6},
|
||||
{0x00b6, 0x14},
|
||||
{0x00b7, 0xfa},
|
||||
{0x00b8, 0x2c},
|
||||
{0x00ba, 0xa7},
|
||||
{0x00bb, 0xaf},
|
||||
{0x00bc, 0xac},
|
||||
{0x00bd, 0xab},
|
||||
{0x00bf, 0xa8},
|
||||
{0x00c0, 0x41},
|
||||
{0x00c1, 0x41},
|
||||
{0x00c2, 0x41},
|
||||
{0x00c3, 0x41},
|
||||
{0x00c4, 0x8e},
|
||||
{0x00c5, 0x8f},
|
||||
{0x00c6, 0x92},
|
||||
{0x00c7, 0x80},
|
||||
{0x00c8, 0x45},
|
||||
{0x00c9, 0x90},
|
||||
{0x00ca, 0x45},
|
||||
{0x00cb, 0x45},
|
||||
{0x00cc, 0x49},
|
||||
{0x00cd, 0x49},
|
||||
{0x00ce, 0x49},
|
||||
{0x00cf, 0x49},
|
||||
{0x00d0, 0x44},
|
||||
{0x00d1, 0xa5},
|
||||
{0x00d2, 0x4f},
|
||||
{0x00d3, 0x4f},
|
||||
{0x00d4, 0x4f},
|
||||
{0x00d5, 0x4f},
|
||||
{0x00d6, 0x99},
|
||||
{0x00d7, 0x78},
|
||||
{0x00d8, 0xe8},
|
||||
{0x00d9, 0x55},
|
||||
{0x00da, 0x55},
|
||||
{0x00db, 0x55},
|
||||
{0x00dc, 0x9a},
|
||||
{0x00dd, 0x59},
|
||||
{0x00df, 0xe1},
|
||||
{0x00e0, 0x85},
|
||||
{0x00e1, 0xa0},
|
||||
{0x00e2, 0x83},
|
||||
{0x00e3, 0x61},
|
||||
{0x00e4, 0x84},
|
||||
{0x00e5, 0x86},
|
||||
{0x00e6, 0x91},
|
||||
@ -185,20 +153,16 @@ static struct unipair unicode_cp437_pairs[] =
|
||||
{0x00ed, 0xa1},
|
||||
{0x00ee, 0x8c},
|
||||
{0x00ef, 0x8b},
|
||||
{0x00f0, 0xeb},
|
||||
{0x00f1, 0xa4},
|
||||
{0x00f2, 0x95},
|
||||
{0x00f3, 0xa2},
|
||||
{0x00f4, 0x93},
|
||||
{0x00f5, 0x6f},
|
||||
{0x00f6, 0x94},
|
||||
{0x00f7, 0xf6},
|
||||
{0x00f8, 0xed},
|
||||
{0x00f9, 0x97},
|
||||
{0x00fa, 0xa3},
|
||||
{0x00fb, 0x96},
|
||||
{0x00fc, 0x81},
|
||||
{0x00fd, 0x79},
|
||||
{0x00ff, 0x98},
|
||||
{0x0192, 0x9f},
|
||||
{0x0393, 0xe2},
|
||||
@ -215,12 +179,23 @@ static struct unipair unicode_cp437_pairs[] =
|
||||
{0x03c3, 0xe5},
|
||||
{0x03c4, 0xe7},
|
||||
{0x03c6, 0xed},
|
||||
{0x2000, 0x20},
|
||||
{0x2001, 0x20},
|
||||
{0x2002, 0x20},
|
||||
{0x2003, 0x20},
|
||||
{0x2004, 0x20},
|
||||
{0x2005, 0x20},
|
||||
{0x2006, 0x20},
|
||||
{0x2007, 0x20},
|
||||
{0x2008, 0x20},
|
||||
{0x2009, 0x20},
|
||||
{0x200a, 0x20},
|
||||
{0x2022, 0x07},
|
||||
{0x202f, 0x20},
|
||||
{0x203c, 0x13},
|
||||
{0x207f, 0xfc},
|
||||
{0x20a7, 0x9e},
|
||||
{0x2126, 0xea},
|
||||
{0x212a, 0x4b},
|
||||
{0x212b, 0x8f},
|
||||
{0x2190, 0x1b},
|
||||
{0x2191, 0x18},
|
||||
@ -229,7 +204,9 @@ static struct unipair unicode_cp437_pairs[] =
|
||||
{0x2194, 0x1d},
|
||||
{0x2195, 0x12},
|
||||
{0x21a8, 0x17},
|
||||
{0x2205, 0xed},
|
||||
{0x2208, 0xee},
|
||||
{0x220e, 0xfe},
|
||||
{0x2219, 0xf9},
|
||||
{0x221a, 0xfb},
|
||||
{0x221e, 0xec},
|
||||
@ -239,11 +216,13 @@ static struct unipair unicode_cp437_pairs[] =
|
||||
{0x2261, 0xf0},
|
||||
{0x2264, 0xf3},
|
||||
{0x2265, 0xf2},
|
||||
{0x22c5, 0xf9},
|
||||
{0x2300, 0xed},
|
||||
{0x2302, 0x7f},
|
||||
{0x2310, 0xa9},
|
||||
{0x2319, 0x1c},
|
||||
{0x2320, 0xf4},
|
||||
{0x2321, 0xf5},
|
||||
{0x23bd, 0x5f},
|
||||
{0x2500, 0xc4},
|
||||
{0x2502, 0xb3},
|
||||
{0x250c, 0xda},
|
||||
@ -300,7 +279,6 @@ static struct unipair unicode_cp437_pairs[] =
|
||||
{0x25bc, 0x1f},
|
||||
{0x25c0, 0x11},
|
||||
{0x25c4, 0x11},
|
||||
{0x25c6, 0x04},
|
||||
{0x25cb, 0x09},
|
||||
{0x25d8, 0x08},
|
||||
{0x25d9, 0x0a},
|
||||
@ -315,8 +293,7 @@ static struct unipair unicode_cp437_pairs[] =
|
||||
{0x2666, 0x04},
|
||||
{0x266a, 0x0d},
|
||||
{0x266b, 0x0e},
|
||||
{0xf804, 0x5f},
|
||||
{0xfffd, 0xfe}
|
||||
{0x266c, 0x0e}
|
||||
};
|
||||
|
||||
} // namespace fc
|
||||
|
@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
if [ $# -gt 0 ]
|
||||
then
|
||||
eval cppcheck --force --enable=all -I../src/include/ "$@"
|
||||
eval cppcheck --force --std=c++11 --enable=all -I../src/include/ "$@"
|
||||
else
|
||||
eval cppcheck --force --enable=all -I../src/include/ ../src/ ../examples/
|
||||
eval cppcheck --force --std=c++11 --enable=all -I../src/include/ ../src/ ../examples/
|
||||
fi
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
LD_LIBRARY_PATH=../src/.libs/ LD_PRELOAD="/usr/lib64/libprofiler.so.0" CPUPROFILE=../examples/.libs/ui.prof ../examples/.libs/ui
|
||||
pprof --gv ../examples/.libs/ui ../examples/.libs/ui.prof
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
# Protokoliert Funktionsaufrufe in dynamisch hinzugelinkten Bibliotheken
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
DIR="$PWD"
|
||||
cd ../examples/.libs/ || exit
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
find ../src/ \
|
||||
../src/include/final/ \
|
||||
|
@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
xfd -center -columns 16 -fn -misc-8x16graph-medium-r-normal--17-160-75-75-*-80-iso8859-1
|
||||
|
||||
|
@ -27,6 +27,8 @@ libfinal_la_SOURCES = \
|
||||
flistview.cpp \
|
||||
fmenu.cpp \
|
||||
fmouse.cpp \
|
||||
fsystem.cpp \
|
||||
fsystemimpl.cpp \
|
||||
fkeyboard.cpp \
|
||||
fdialoglistmenu.cpp \
|
||||
fmenubar.cpp \
|
||||
@ -41,7 +43,9 @@ libfinal_la_SOURCES = \
|
||||
ftooltip.cpp \
|
||||
ffiledialog.cpp \
|
||||
fkey_map.cpp \
|
||||
fcharmap.cpp \
|
||||
ftextview.cpp \
|
||||
fstartoptions.cpp \
|
||||
fstatusbar.cpp \
|
||||
ftermcap.cpp \
|
||||
ftermcapquirks.cpp \
|
||||
@ -49,6 +53,7 @@ libfinal_la_SOURCES = \
|
||||
ftermfreebsd.cpp \
|
||||
ftermopenbsd.cpp \
|
||||
ftermlinux.cpp \
|
||||
ftermdebugdata.cpp \
|
||||
ftermdetection.cpp \
|
||||
ftermios.cpp \
|
||||
fterm.cpp \
|
||||
@ -71,7 +76,6 @@ finalcutinclude_HEADERS = \
|
||||
include/final/fapplication.h \
|
||||
include/final/fbutton.h \
|
||||
include/final/fbuttongroup.h \
|
||||
include/final/fcharmap.h \
|
||||
include/final/fcheckbox.h \
|
||||
include/final/fcolorpair.h \
|
||||
include/final/fconfig.h \
|
||||
@ -84,6 +88,7 @@ finalcutinclude_HEADERS = \
|
||||
include/final/ffiledialog.h \
|
||||
include/final/final.h \
|
||||
include/final/fkey_map.h \
|
||||
include/final/fcharmap.h \
|
||||
include/final/flabel.h \
|
||||
include/final/flineedit.h \
|
||||
include/final/flistbox.h \
|
||||
@ -110,8 +115,11 @@ finalcutinclude_HEADERS = \
|
||||
include/final/frect.h \
|
||||
include/final/fscrollbar.h \
|
||||
include/final/fscrollview.h \
|
||||
include/final/fstartoptions.h \
|
||||
include/final/fstatusbar.h \
|
||||
include/final/fstring.h \
|
||||
include/final/fsystem.h \
|
||||
include/final/fsystemimpl.h \
|
||||
include/final/ftermcap.h \
|
||||
include/final/ftermcapquirks.h \
|
||||
include/final/ftermxterminal.h \
|
||||
|
@ -39,6 +39,8 @@ INCLUDE_HEADERS = \
|
||||
fprogressbar.h \
|
||||
fradiobutton.h \
|
||||
frect.h \
|
||||
fsystem.h \
|
||||
fsystemimpl.h \
|
||||
fscrollbar.h \
|
||||
fscrollview.h \
|
||||
fstatusbar.h \
|
||||
@ -46,8 +48,10 @@ INCLUDE_HEADERS = \
|
||||
fmouse.h \
|
||||
fkeyboard.h \
|
||||
ftermcap.h \
|
||||
fstartoptions.h \
|
||||
fterm.h \
|
||||
ftermdata.h \
|
||||
ftermdebugdata.h \
|
||||
ftermios.h \
|
||||
ftermdetection.h \
|
||||
ftermcapquirks.h \
|
||||
@ -104,12 +108,17 @@ OBJS = \
|
||||
ftooltip.o \
|
||||
ffiledialog.o \
|
||||
fkey_map.o \
|
||||
fcharmap.o \
|
||||
ftextview.o \
|
||||
fstatusbar.o \
|
||||
fmouse.o \
|
||||
fsystem.o \
|
||||
fsystemimpl.o \
|
||||
fkeyboard.o \
|
||||
fstartoptions.o \
|
||||
ftermcap.o \
|
||||
fterm.o \
|
||||
ftermdebugdata.o \
|
||||
ftermios.o \
|
||||
ftermdetection.o \
|
||||
ftermcapquirks.o \
|
||||
@ -152,7 +161,10 @@ all: dep $(OBJS)
|
||||
$(LIB): all
|
||||
|
||||
debug:
|
||||
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -Wall -Wextra -Wpedantic -Weverything -Wpadded -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-implicit-fallthrough -Wno-reserved-id-macro"
|
||||
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -Wall -Wextra -Wpedantic -Weverything -Wno-padded -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-implicit-fallthrough -Wno-reserved-id-macro -Wno-format-nonliteral"
|
||||
|
||||
unittest:
|
||||
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -DUNIT_TEST -Wall -Wextra -Wpedantic -Weverything -Wno-padded -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-implicit-fallthrough -Wno-reserved-id-macro -Wno-format-nonliteral"
|
||||
|
||||
profile:
|
||||
$(MAKE) $(MAKEFILE) PROFILE="-pg"
|
||||
|
@ -43,11 +43,15 @@ INCLUDE_HEADERS = \
|
||||
fscrollview.h \
|
||||
fstatusbar.h \
|
||||
fstring.h \
|
||||
fsystem.h \
|
||||
fsystemimpl.h \
|
||||
fmouse.h \
|
||||
fkeyboard.h \
|
||||
fstartoptions.h \
|
||||
ftermcap.h \
|
||||
fterm.h \
|
||||
ftermdata.h \
|
||||
ftermdebugdata.h \
|
||||
ftermios.h \
|
||||
ftermdetection.h \
|
||||
ftermcapquirks.h \
|
||||
@ -104,12 +108,17 @@ OBJS = \
|
||||
ftooltip.o \
|
||||
ffiledialog.o \
|
||||
fkey_map.o \
|
||||
fcharmap.o \
|
||||
ftextview.o \
|
||||
fstatusbar.o \
|
||||
fmouse.o \
|
||||
fsystem.o \
|
||||
fsystemimpl.o \
|
||||
fkeyboard.o \
|
||||
ftermcap.o \
|
||||
fstartoptions.o \
|
||||
fterm.o \
|
||||
ftermdebugdata.o \
|
||||
ftermios.o \
|
||||
ftermdetection.o \
|
||||
ftermcapquirks.o \
|
||||
@ -153,6 +162,9 @@ $(LIB): all
|
||||
debug:
|
||||
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -Wall -Wextra -Wpedantic"
|
||||
|
||||
unittest:
|
||||
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -DUNIT_TEST -Wall -Wextra -Wpedantic"
|
||||
|
||||
profile:
|
||||
$(MAKE) $(MAKEFILE) PROFILE="-pg"
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2013-2018 Markus Gans *
|
||||
* Copyright 2013-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -24,35 +24,41 @@
|
||||
#include <string>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/fmenu.h"
|
||||
#include "final/fmenubar.h"
|
||||
#include "final/fmessagebox.h"
|
||||
#include "final/fmouse.h"
|
||||
#include "final/fstartoptions.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/ftermios.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
#include "final/fwindow.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// Global application object
|
||||
static FApplication* app_object = nullptr;
|
||||
static FApplication* app_object{nullptr};
|
||||
|
||||
// Flag to exit the local event loop
|
||||
static bool app_exit_loop = false;
|
||||
static bool app_exit_loop{false};
|
||||
|
||||
// Static attributes
|
||||
FWidget* FWidget::main_widget = nullptr; // main application widget
|
||||
FWidget* FWidget::active_window = nullptr; // the active window
|
||||
FWidget* FWidget::focus_widget = nullptr; // has keyboard input focus
|
||||
FWidget* FWidget::clicked_widget = nullptr; // is focused by click
|
||||
FWidget* FWidget::open_menu = nullptr; // currently open menu
|
||||
FWidget* FWidget::move_size_widget = nullptr; // move/size by keyboard
|
||||
FWidget* FApplication::keyboard_widget = nullptr; // has the keyboard focus
|
||||
FKeyboard* FApplication::keyboard = nullptr; // keyboard access
|
||||
FMouseControl* FApplication::mouse = nullptr; // mouse control
|
||||
int FApplication::loop_level = 0; // event loop level
|
||||
int FApplication::quit_code = 0;
|
||||
bool FApplication::quit_now = false;
|
||||
FWidget* FWidget::main_widget {nullptr}; // main application widget
|
||||
FWidget* FWidget::active_window {nullptr}; // the active window
|
||||
FWidget* FWidget::focus_widget {nullptr}; // has keyboard input focus
|
||||
FWidget* FWidget::clicked_widget {nullptr}; // is focused by click
|
||||
FWidget* FWidget::open_menu {nullptr}; // currently open menu
|
||||
FWidget* FWidget::move_size_widget {nullptr}; // move/size by keyboard
|
||||
FWidget* FApplication::keyboard_widget {nullptr}; // has the keyboard focus
|
||||
FKeyboard* FApplication::keyboard {nullptr}; // keyboard access
|
||||
FMouseControl* FApplication::mouse {nullptr}; // mouse control
|
||||
int FApplication::loop_level {0}; // event loop level
|
||||
int FApplication::quit_code {0};
|
||||
bool FApplication::quit_now {false};
|
||||
|
||||
FApplication::eventQueue* FApplication::event_queue = nullptr;
|
||||
FApplication::eventQueue* FApplication::event_queue{nullptr};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -76,7 +82,7 @@ FApplication::FApplication ( const int& _argc
|
||||
|
||||
if ( ! (_argc && _argv) )
|
||||
{
|
||||
static char* empty = C_STR("");
|
||||
static char* empty{C_STR("")};
|
||||
app_argc = 0;
|
||||
app_argv = static_cast<char**>(&empty);
|
||||
}
|
||||
@ -123,11 +129,10 @@ int FApplication::exec() // run
|
||||
//----------------------------------------------------------------------
|
||||
int FApplication::enter_loop() // event loop
|
||||
{
|
||||
bool old_app_exit_loop;
|
||||
loop_level++;
|
||||
quit_now = false;
|
||||
|
||||
old_app_exit_loop = app_exit_loop;
|
||||
bool old_app_exit_loop = app_exit_loop;
|
||||
app_exit_loop = false;
|
||||
|
||||
while ( ! (quit_now || app_exit_loop) )
|
||||
@ -178,7 +183,7 @@ bool FApplication::sendEvent ( const FObject* receiver
|
||||
const auto r_widget = static_cast<const FWidget*>(receiver);
|
||||
auto widget = const_cast<FWidget*>(r_widget);
|
||||
|
||||
if ( modal_dialogs > 0 )
|
||||
if ( getModalDialogCounter() > 0 )
|
||||
{
|
||||
const FWidget* window;
|
||||
|
||||
@ -260,15 +265,13 @@ bool FApplication::eventInQueue()
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::removeQueuedEvent (const FObject* receiver)
|
||||
{
|
||||
bool retval;
|
||||
|
||||
if ( ! eventInQueue() )
|
||||
return false;
|
||||
|
||||
if ( ! receiver )
|
||||
return false;
|
||||
|
||||
retval = false;
|
||||
bool retval{false};
|
||||
auto iter = event_queue->begin();
|
||||
|
||||
while ( iter != event_queue->end() )
|
||||
@ -294,7 +297,7 @@ FWidget* FApplication::processParameters (const int& argc, char* argv[])
|
||||
showParameterUsage();
|
||||
}
|
||||
|
||||
getInitValues().setDefault();
|
||||
getStartOptions().setDefault();
|
||||
cmd_options (argc, argv);
|
||||
return 0;
|
||||
}
|
||||
@ -362,7 +365,7 @@ void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
|
||||
void FApplication::init (uInt64 key_time, uInt64 dblclick_time)
|
||||
{
|
||||
// Initialize keyboard
|
||||
keyboard = FVTerm::getKeyboard();
|
||||
keyboard = FVTerm::getFKeyboard();
|
||||
|
||||
// Set the keyboard keypress timeout
|
||||
if ( keyboard )
|
||||
@ -377,7 +380,7 @@ void FApplication::init (uInt64 key_time, uInt64 dblclick_time)
|
||||
}
|
||||
|
||||
// Initialize mouse control
|
||||
mouse = FVTerm::getMouseControl();
|
||||
mouse = FVTerm::getFMouseControl();
|
||||
|
||||
// Set stdin number for a gpm-mouse
|
||||
if ( mouse )
|
||||
@ -405,8 +408,6 @@ void FApplication::cmd_options (const int& argc, char* argv[])
|
||||
|
||||
while ( true )
|
||||
{
|
||||
int c, idx = 0;
|
||||
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{C_STR("encoding"), required_argument, 0, 0 },
|
||||
@ -428,7 +429,8 @@ void FApplication::cmd_options (const int& argc, char* argv[])
|
||||
};
|
||||
|
||||
opterr = 0;
|
||||
c = getopt_long (argc, argv, "", long_options, &idx);
|
||||
int idx{0};
|
||||
int c = getopt_long (argc, argv, "", long_options, &idx);
|
||||
|
||||
if ( c == -1 )
|
||||
break;
|
||||
@ -441,13 +443,13 @@ void FApplication::cmd_options (const int& argc, char* argv[])
|
||||
encoding = encoding.toLower();
|
||||
|
||||
if ( encoding.includes("utf8") )
|
||||
getInitValues().encoding = fc::UTF8;
|
||||
getStartOptions().encoding = fc::UTF8;
|
||||
else if ( encoding.includes("vt100") )
|
||||
getInitValues().encoding = fc::VT100;
|
||||
getStartOptions().encoding = fc::VT100;
|
||||
else if ( encoding.includes("pc") )
|
||||
getInitValues().encoding = fc::PC;
|
||||
getStartOptions().encoding = fc::PC;
|
||||
else if ( encoding.includes("ascii") )
|
||||
getInitValues().encoding = fc::ASCII;
|
||||
getStartOptions().encoding = fc::ASCII;
|
||||
else if ( encoding.includes("help") )
|
||||
showParameterUsage();
|
||||
else
|
||||
@ -456,43 +458,49 @@ void FApplication::cmd_options (const int& argc, char* argv[])
|
||||
}
|
||||
|
||||
if ( std::strcmp(long_options[idx].name, "no-mouse") == 0 )
|
||||
getInitValues().mouse_support = false;
|
||||
getStartOptions().mouse_support = false;
|
||||
|
||||
if ( std::strcmp(long_options[idx].name, "no-optimized-cursor") == 0 )
|
||||
getInitValues().cursor_optimisation = false;
|
||||
getStartOptions().cursor_optimisation = false;
|
||||
|
||||
if ( std::strcmp(long_options[idx].name, "no-terminal-detection") == 0 )
|
||||
getInitValues().terminal_detection = false;
|
||||
getStartOptions().terminal_detection = false;
|
||||
|
||||
if ( std::strcmp(long_options[idx].name, "no-color-change") == 0 )
|
||||
getInitValues().color_change = false;
|
||||
getStartOptions().color_change = false;
|
||||
|
||||
if ( std::strcmp(long_options[idx].name, "vgafont") == 0 )
|
||||
getInitValues().vgafont = true;
|
||||
getStartOptions().vgafont = true;
|
||||
|
||||
if ( std::strcmp(long_options[idx].name, "newfont") == 0 )
|
||||
getInitValues().newfont = true;
|
||||
getStartOptions().newfont = true;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
|
||||
getInitValues().meta_sends_escape = false;
|
||||
getStartOptions().meta_sends_escape = false;
|
||||
|
||||
if ( std::strcmp(long_options[idx].name, "no-cursorstyle-change") == 0 )
|
||||
getInitValues().change_cursorstyle = false;
|
||||
getStartOptions().change_cursorstyle = false;
|
||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
|
||||
getInitValues().meta_sends_escape = false;
|
||||
getStartOptions().meta_sends_escape = false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FStartOptions& FApplication::getStartOptions()
|
||||
{
|
||||
return FStartOptions::getFStartOptions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FApplication::findKeyboardWidget()
|
||||
{
|
||||
// Find the widget that has the keyboard focus
|
||||
|
||||
FWidget* widget = nullptr;
|
||||
FWidget* widget{nullptr};
|
||||
auto focus = getFocusWidget();
|
||||
auto move_size = getMoveSizeWidget();
|
||||
|
||||
@ -679,7 +687,7 @@ bool FApplication::processDialogSwitchAccelerator()
|
||||
{
|
||||
FKey key = keyboard->getKey();
|
||||
std::size_t n = key - fc::Fmkey_0;
|
||||
std::size_t s = dialog_list->size();
|
||||
std::size_t s = getDialogList()->size();
|
||||
|
||||
if ( s > 0 && s >= n )
|
||||
{
|
||||
@ -689,12 +697,12 @@ bool FApplication::processDialogSwitchAccelerator()
|
||||
if ( move_size )
|
||||
{
|
||||
auto w = move_size;
|
||||
setMoveSizeWidget(0);
|
||||
setMoveSizeWidget(nullptr);
|
||||
w->redraw();
|
||||
}
|
||||
|
||||
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
|
||||
sendEvent (dialog_list->at(n - 1), &a_ev);
|
||||
sendEvent (getDialogList()->at(n - 1), &a_ev);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -705,14 +713,14 @@ bool FApplication::processDialogSwitchAccelerator()
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::processAccelerator (const FWidget*& widget)
|
||||
{
|
||||
bool accpt = false;
|
||||
bool accpt{false};
|
||||
|
||||
if ( widget
|
||||
&& widget->accelerator_list
|
||||
&& ! widget->accelerator_list->empty() )
|
||||
&& widget->getAcceleratorList()
|
||||
&& ! widget->getAcceleratorList()->empty() )
|
||||
{
|
||||
auto iter = widget->accelerator_list->begin();
|
||||
auto last = widget->accelerator_list->end();
|
||||
auto iter = widget->getAcceleratorList()->begin();
|
||||
auto last = widget->getAcceleratorList()->end();
|
||||
|
||||
while ( iter != last )
|
||||
{
|
||||
@ -727,7 +735,7 @@ bool FApplication::processAccelerator (const FWidget*& widget)
|
||||
if ( move_size )
|
||||
{
|
||||
auto w = move_size;
|
||||
setMoveSizeWidget(0);
|
||||
setMoveSizeWidget(nullptr);
|
||||
w->redraw();
|
||||
}
|
||||
|
||||
@ -747,7 +755,7 @@ bool FApplication::processAccelerator (const FWidget*& widget)
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::getMouseEvent()
|
||||
{
|
||||
bool mouse_event_occurred = false;
|
||||
bool mouse_event_occurred{false};
|
||||
|
||||
if ( mouse && mouse->hasData() )
|
||||
{
|
||||
@ -805,7 +813,7 @@ void FApplication::unsetMoveSizeMode()
|
||||
if ( move_size )
|
||||
{
|
||||
auto w = move_size;
|
||||
setMoveSizeWidget(0);
|
||||
setMoveSizeWidget(nullptr);
|
||||
w->redraw();
|
||||
}
|
||||
}
|
||||
@ -829,7 +837,7 @@ void FApplication::closeOpenMenu()
|
||||
return;
|
||||
}
|
||||
|
||||
bool is_window_menu;
|
||||
bool is_window_menu{false};
|
||||
auto super = menu->getSuperMenu();
|
||||
|
||||
if ( super && menu->isWindowsMenu(super) )
|
||||
@ -907,7 +915,7 @@ void FApplication::sendMouseEvent()
|
||||
return;
|
||||
|
||||
const auto& mouse_position = mouse->getPos();
|
||||
int key_state = 0;
|
||||
int key_state{0};
|
||||
|
||||
if ( mouse->isShiftKeyPressed() )
|
||||
key_state |= fc::ShiftButton;
|
||||
@ -1009,7 +1017,7 @@ void FApplication::sendMouseLeftClickEvent ( const FPoint& widgetMousePos
|
||||
|
||||
if ( ! mouse->isRightButtonPressed()
|
||||
&& ! mouse->isMiddleButtonPressed() )
|
||||
setClickedWidget(0);
|
||||
setClickedWidget(nullptr);
|
||||
|
||||
sendEvent (released_widget, &m_up_ev);
|
||||
}
|
||||
@ -1043,7 +1051,7 @@ void FApplication::sendMouseRightClickEvent ( const FPoint& widgetMousePos
|
||||
|
||||
if ( ! mouse->isLeftButtonPressed()
|
||||
&& ! mouse->isMiddleButtonPressed() )
|
||||
setClickedWidget(0);
|
||||
setClickedWidget(nullptr);
|
||||
|
||||
sendEvent (released_widget, &m_up_ev);
|
||||
}
|
||||
@ -1069,7 +1077,7 @@ void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos
|
||||
|
||||
// gnome-terminal sends no released on middle click
|
||||
if ( isGnomeTerminal() )
|
||||
setClickedWidget(0);
|
||||
setClickedWidget(nullptr);
|
||||
}
|
||||
else if ( mouse->isMiddleButtonReleased() )
|
||||
{
|
||||
@ -1082,7 +1090,7 @@ void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos
|
||||
if ( ! mouse->isLeftButtonPressed()
|
||||
&& ! mouse->isRightButtonPressed() )
|
||||
{
|
||||
setClickedWidget(0);
|
||||
setClickedWidget(nullptr);
|
||||
}
|
||||
|
||||
sendEvent (released_widget, &m_up_ev);
|
||||
@ -1105,7 +1113,7 @@ void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
|
||||
, mouse_position
|
||||
, fc::WheelUp );
|
||||
auto scroll_over_widget = clicked;
|
||||
setClickedWidget(0);
|
||||
setClickedWidget(nullptr);
|
||||
sendEvent(scroll_over_widget, &wheel_ev);
|
||||
}
|
||||
|
||||
@ -1116,7 +1124,7 @@ void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
|
||||
, mouse_position
|
||||
, fc::WheelDown );
|
||||
auto scroll_over_widget = clicked;
|
||||
setClickedWidget(0);
|
||||
setClickedWidget(nullptr);
|
||||
sendEvent (scroll_over_widget, &wheel_ev);
|
||||
}
|
||||
}
|
||||
@ -1155,17 +1163,17 @@ void FApplication::processCloseWidget()
|
||||
{
|
||||
updateTerminal (FVTerm::stop_refresh);
|
||||
|
||||
if ( close_widget && ! close_widget->empty() )
|
||||
if ( getWidgetCloseList() && ! getWidgetCloseList()->empty() )
|
||||
{
|
||||
auto iter = close_widget->begin();
|
||||
auto iter = getWidgetCloseList()->begin();
|
||||
|
||||
while ( iter != close_widget->end() && *iter )
|
||||
while ( iter != getWidgetCloseList()->end() && *iter )
|
||||
{
|
||||
delete *iter;
|
||||
++iter;
|
||||
}
|
||||
|
||||
close_widget->clear();
|
||||
getWidgetCloseList()->clear();
|
||||
}
|
||||
|
||||
updateTerminal (FVTerm::start_refresh);
|
||||
@ -1174,7 +1182,7 @@ void FApplication::processCloseWidget()
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::processNextEvent()
|
||||
{
|
||||
uInt num_events = 0;
|
||||
uInt num_events{0};
|
||||
|
||||
processKeyboardEvent();
|
||||
processMouseEvent();
|
||||
|
134
src/fbutton.cpp
134
src/fbutton.cpp
@ -21,6 +21,8 @@
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fcolorpair.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/fbutton.h"
|
||||
#include "final/fstatusbar.h"
|
||||
|
||||
@ -128,7 +130,7 @@ void FButton::setInactiveBackgroundColor (FColor color)
|
||||
//----------------------------------------------------------------------
|
||||
bool FButton::setNoUnderline (bool enable)
|
||||
{
|
||||
return (flags.no_underline = enable);
|
||||
return (setFlags().no_underline = enable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -177,7 +179,7 @@ bool FButton::setFocus (bool enable)
|
||||
//----------------------------------------------------------------------
|
||||
bool FButton::setFlat (bool enable)
|
||||
{
|
||||
return (flags.flat = enable);
|
||||
return (setFlags().flat = enable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -187,16 +189,16 @@ bool FButton::setShadow (bool enable)
|
||||
&& getEncoding() != fc::VT100
|
||||
&& getEncoding() != fc::ASCII )
|
||||
{
|
||||
flags.shadow = true;
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize(1, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
flags.shadow = false;
|
||||
setFlags().shadow = false;
|
||||
setShadowSize(FSize(0, 0));
|
||||
}
|
||||
|
||||
return flags.shadow;
|
||||
return getFlags().shadow;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -215,9 +217,9 @@ bool FButton::setDown (bool enable)
|
||||
void FButton::setText (const FString& txt)
|
||||
{
|
||||
if ( txt.isNull() )
|
||||
text = "";
|
||||
text.setString("");
|
||||
else
|
||||
text = txt;
|
||||
text.setString(txt);
|
||||
|
||||
detectHotkey();
|
||||
}
|
||||
@ -225,8 +227,7 @@ void FButton::setText (const FString& txt)
|
||||
//----------------------------------------------------------------------
|
||||
void FButton::hide()
|
||||
{
|
||||
std::size_t s, f, size;
|
||||
FColor fg, bg;
|
||||
FColor fg{}, bg{};
|
||||
auto parent_widget = getParentWidget();
|
||||
FWidget::hide();
|
||||
|
||||
@ -237,21 +238,22 @@ void FButton::hide()
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
fg = wc.dialog_fg;
|
||||
bg = wc.dialog_bg;
|
||||
}
|
||||
|
||||
setColor (fg, bg);
|
||||
s = hasShadow() ? 1 : 0;
|
||||
f = isFlat() ? 1 : 0;
|
||||
size = getWidth() + s + (f << 1);
|
||||
std::size_t s = hasShadow() ? 1 : 0;
|
||||
std::size_t f = isFlat() ? 1 : 0;
|
||||
std::size_t size = getWidth() + s + (f << 1);
|
||||
|
||||
if ( size == 0 )
|
||||
return;
|
||||
|
||||
auto blank = createBlankArray(size + 1);
|
||||
char* blank = createBlankArray(size + 1);
|
||||
|
||||
for (std::size_t y = 0; y < getHeight() + s + (f << 1); y++)
|
||||
for (std::size_t y{0}; y < getHeight() + s + (f << 1); y++)
|
||||
{
|
||||
print() << FPoint(1 - int(f), 1 + int(y - f)) << blank;
|
||||
}
|
||||
@ -307,7 +309,7 @@ void FButton::onMouseDown (FMouseEvent* ev)
|
||||
getStatusBar()->drawMessage();
|
||||
}
|
||||
|
||||
FPoint tPos = ev->getTermPos();
|
||||
FPoint tPos(ev->getTermPos());
|
||||
|
||||
if ( getTermGeometry().contains(tPos) )
|
||||
setDown();
|
||||
@ -334,7 +336,7 @@ void FButton::onMouseMove (FMouseEvent* ev)
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
return;
|
||||
|
||||
FPoint tPos = ev->getTermPos();
|
||||
FPoint tPos(ev->getTermPos());
|
||||
|
||||
if ( click_animation )
|
||||
{
|
||||
@ -408,6 +410,7 @@ void FButton::onFocusOut (FFocusEvent*)
|
||||
//----------------------------------------------------------------------
|
||||
void FButton::init()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.button_active_fg);
|
||||
setBackgroundColor (wc.button_active_bg);
|
||||
setShadow();
|
||||
@ -421,6 +424,9 @@ void FButton::setHotkeyAccelerator()
|
||||
{
|
||||
FKey hotkey = getHotkey(text);
|
||||
|
||||
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
|
||||
hotkey -= 0xfee0;
|
||||
|
||||
if ( hotkey )
|
||||
{
|
||||
if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
|
||||
@ -447,31 +453,6 @@ inline void FButton::detectHotkey()
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t FButton::getHotkeyPos ( wchar_t src[]
|
||||
, wchar_t dest[]
|
||||
, std::size_t length )
|
||||
{
|
||||
// find hotkey position in string
|
||||
// + generate a new string without the '&'-sign
|
||||
wchar_t* txt = src;
|
||||
std::size_t pos = NOT_SET;
|
||||
|
||||
for (std::size_t i = 0; i < length; i++)
|
||||
{
|
||||
if ( i < length && txt[i] == L'&' && pos == NOT_SET )
|
||||
{
|
||||
pos = i;
|
||||
i++;
|
||||
src++;
|
||||
}
|
||||
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline std::size_t FButton::clickAnimationIndent (FWidget* parent_widget)
|
||||
{
|
||||
@ -479,7 +460,7 @@ inline std::size_t FButton::clickAnimationIndent (FWidget* parent_widget)
|
||||
return 0;
|
||||
|
||||
// noshadow + indent one character to the right
|
||||
if ( flags.flat )
|
||||
if ( getFlags().flat )
|
||||
clearFlatBorder();
|
||||
else if ( hasShadow() )
|
||||
clearShadow();
|
||||
@ -488,9 +469,9 @@ inline std::size_t FButton::clickAnimationIndent (FWidget* parent_widget)
|
||||
setColor ( parent_widget->getForegroundColor()
|
||||
, parent_widget->getBackgroundColor() );
|
||||
|
||||
for (std::size_t y = 1; y <= getHeight(); y++)
|
||||
for (int y{1}; y <= int(getHeight()); y++)
|
||||
{
|
||||
print() << FPoint(1, int(y)) << ' '; // clear one left █
|
||||
print() << FPoint(1, y) << ' '; // clear one left █
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -507,14 +488,14 @@ inline void FButton::clearRightMargin (FWidget* parent_widget)
|
||||
setColor ( parent_widget->getForegroundColor()
|
||||
, parent_widget->getBackgroundColor() );
|
||||
|
||||
for (int y = 1; y <= int(getHeight()); y++)
|
||||
for (int y{1}; y <= int(getHeight()); y++)
|
||||
{
|
||||
if ( isMonochron() )
|
||||
setReverse(true); // Light background
|
||||
|
||||
print() << FPoint(1 + int(getWidth()), y) << ' '; // clear right
|
||||
|
||||
if ( flags.active && isMonochron() )
|
||||
if ( getFlags().active && isMonochron() )
|
||||
setReverse(false); // Dark background
|
||||
}
|
||||
}
|
||||
@ -526,7 +507,7 @@ inline void FButton::drawMarginLeft()
|
||||
|
||||
setColor (getForegroundColor(), button_bg);
|
||||
|
||||
for (std::size_t y = 0; y < getHeight(); y++)
|
||||
for (std::size_t y{0}; y < getHeight(); y++)
|
||||
{
|
||||
print() << FPoint(1 + int(indent), 1 + int(y));
|
||||
|
||||
@ -542,7 +523,7 @@ inline void FButton::drawMarginRight()
|
||||
{
|
||||
// Print right margin
|
||||
|
||||
for (std::size_t y = 0; y < getHeight(); y++)
|
||||
for (std::size_t y{0}; y < getHeight(); y++)
|
||||
{
|
||||
print() << FPoint(int(getWidth() + indent), 1 + int(y));
|
||||
|
||||
@ -561,19 +542,19 @@ inline void FButton::drawTopBottomBackground()
|
||||
if ( getHeight() < 2 )
|
||||
return;
|
||||
|
||||
for (std::size_t y = 0; y < vcenter_offset; y++)
|
||||
for (std::size_t y{0}; y < vcenter_offset; y++)
|
||||
{
|
||||
print() << FPoint(2 + int(indent), 1 + int(y));
|
||||
|
||||
for (std::size_t x = 1; x < getWidth() - 1; x++)
|
||||
for (std::size_t x{1}; x < getWidth() - 1; x++)
|
||||
print (space_char); // █
|
||||
}
|
||||
|
||||
for (std::size_t y = vcenter_offset + 1; y < getHeight(); y++)
|
||||
for (std::size_t y{vcenter_offset + 1}; y < getHeight(); y++)
|
||||
{
|
||||
print() << FPoint(2 + int(indent), 1 + int(y));
|
||||
|
||||
for (std::size_t x = 1; x < getWidth() - 1; x++)
|
||||
for (std::size_t x{1}; x < getWidth() - 1; x++)
|
||||
print (space_char); // █
|
||||
}
|
||||
}
|
||||
@ -581,14 +562,14 @@ inline void FButton::drawTopBottomBackground()
|
||||
//----------------------------------------------------------------------
|
||||
inline void FButton::drawButtonTextLine (wchar_t button_text[])
|
||||
{
|
||||
std::size_t pos;
|
||||
std::size_t pos{};
|
||||
print() << FPoint(2 + int(indent), 1 + int(vcenter_offset))
|
||||
<< FColorPair (button_fg, button_bg);
|
||||
|
||||
if ( getWidth() < txtlength + 1 )
|
||||
if ( getWidth() < column_width + 1 )
|
||||
center_offset = 0;
|
||||
else
|
||||
center_offset = (getWidth() - txtlength - 1) / 2;
|
||||
center_offset = (getWidth() - column_width - 1) / 2;
|
||||
|
||||
// Print button text line
|
||||
for (pos = 0; pos < center_offset; pos++)
|
||||
@ -601,24 +582,24 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
|
||||
setCursorPos (FPoint ( 2 + int(center_offset + hotkeypos)
|
||||
, 1 + int(vcenter_offset) )); // hotkey
|
||||
|
||||
if ( ! flags.active && isMonochron() )
|
||||
if ( ! getFlags().active && isMonochron() )
|
||||
setReverse(true); // Light background
|
||||
|
||||
if ( active_focus && (isMonochron() || getMaxColor() < 16) )
|
||||
setBold();
|
||||
|
||||
for ( std::size_t z = 0
|
||||
; pos < center_offset + txtlength && z < getWidth() - 2
|
||||
; z++, pos++)
|
||||
for ( std::size_t z{0}, columns{0}
|
||||
; pos < center_offset + column_width && columns + 2 < getWidth()
|
||||
; z++)
|
||||
{
|
||||
if ( z == hotkeypos && flags.active )
|
||||
if ( z == hotkeypos && getFlags().active )
|
||||
{
|
||||
setColor (button_hotkey_fg, button_bg);
|
||||
|
||||
if ( ! active_focus && getMaxColor() < 16 )
|
||||
setBold();
|
||||
|
||||
if ( ! flags.no_underline )
|
||||
if ( ! getFlags().no_underline )
|
||||
setUnderline();
|
||||
|
||||
print (button_text[z]);
|
||||
@ -626,7 +607,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
|
||||
if ( ! active_focus && getMaxColor() < 16 )
|
||||
unsetBold();
|
||||
|
||||
if ( ! flags.no_underline )
|
||||
if ( ! getFlags().no_underline )
|
||||
unsetUnderline();
|
||||
|
||||
setColor (button_fg, button_bg);
|
||||
@ -635,9 +616,13 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
|
||||
{
|
||||
print (button_text[z]);
|
||||
}
|
||||
|
||||
auto char_width = getColumnWidth (button_text[z]);
|
||||
columns += char_width;
|
||||
pos += char_width;
|
||||
}
|
||||
|
||||
if ( txtlength >= getWidth() - 1 )
|
||||
if ( column_width + 1 >= getWidth() )
|
||||
{
|
||||
// Print ellipsis
|
||||
print() << FPoint(int(getWidth() + indent) - 2, 1) << "..";
|
||||
@ -646,18 +631,19 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
|
||||
if ( active_focus && (isMonochron() || getMaxColor() < 16) )
|
||||
unsetBold();
|
||||
|
||||
for (pos = center_offset + txtlength; pos < getWidth() - 2; pos++)
|
||||
for (pos = center_offset + column_width; pos < getWidth() - 2; pos++)
|
||||
print (space_char); // █
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FButton::draw()
|
||||
{
|
||||
wchar_t* button_text;
|
||||
wchar_t* button_text{};
|
||||
auto parent_widget = getParentWidget();
|
||||
txtlength = text.getLength();
|
||||
auto txtlength = text.getLength();
|
||||
column_width = getColumnWidth(text);
|
||||
space_char = int(' ');
|
||||
active_focus = flags.active && flags.focus;
|
||||
active_focus = getFlags().active && getFlags().focus;
|
||||
|
||||
try
|
||||
{
|
||||
@ -678,19 +664,19 @@ void FButton::draw()
|
||||
// Clear right margin after animation
|
||||
clearRightMargin (parent_widget);
|
||||
|
||||
if ( ! flags.active && isMonochron() )
|
||||
if ( ! getFlags().active && isMonochron() )
|
||||
space_char = fc::MediumShade; // ▒ simulates greyed out at Monochron
|
||||
|
||||
if ( isMonochron() && (flags.active || flags.focus) )
|
||||
if ( isMonochron() && (getFlags().active || getFlags().focus) )
|
||||
setReverse(false); // Dark background
|
||||
|
||||
if ( flags.flat && ! button_down )
|
||||
if ( getFlags().flat && ! button_down )
|
||||
drawFlatBorder();
|
||||
|
||||
hotkeypos = getHotkeyPos(text.wc_str(), button_text, uInt(txtlength));
|
||||
hotkeypos = finalcut::getHotkeyPos(text.wc_str(), button_text, uInt(txtlength));
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
txtlength--;
|
||||
column_width--;
|
||||
|
||||
if ( getHeight() >= 2 )
|
||||
vcenter_offset = (getHeight() - 1) / 2;
|
||||
@ -710,7 +696,7 @@ void FButton::draw()
|
||||
drawTopBottomBackground();
|
||||
|
||||
// Draw button shadow
|
||||
if ( ! flags.flat && flags.shadow && ! button_down )
|
||||
if ( ! getFlags().flat && getFlags().shadow && ! button_down )
|
||||
drawShadow();
|
||||
|
||||
if ( isMonochron() )
|
||||
@ -723,7 +709,7 @@ void FButton::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void FButton::updateStatusBar()
|
||||
{
|
||||
if ( ! flags.focus || ! getStatusBar() )
|
||||
if ( ! getFlags().focus || ! getStatusBar() )
|
||||
return;
|
||||
|
||||
const auto& msg = getStatusbarMessage();
|
||||
|
@ -23,6 +23,9 @@
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fbuttongroup.h"
|
||||
#include "final/fcolorpair.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/fsize.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/ftogglebutton.h"
|
||||
|
||||
@ -61,7 +64,7 @@ FButtonGroup::~FButtonGroup() // destructor
|
||||
while ( iter != buttonlist.end() )
|
||||
{
|
||||
auto toggle_button = static_cast<FToggleButton*>(*iter);
|
||||
toggle_button->setGroup(0);
|
||||
toggle_button->setGroup(nullptr);
|
||||
iter = buttonlist.erase(iter);
|
||||
}
|
||||
}
|
||||
@ -114,7 +117,7 @@ bool FButtonGroup::setEnable (bool enable)
|
||||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::setText (const FString& txt)
|
||||
{
|
||||
text = txt;
|
||||
text.setString(txt);
|
||||
|
||||
if ( isEnabled() )
|
||||
{
|
||||
@ -140,17 +143,12 @@ bool FButtonGroup::hasFocusedButton() const
|
||||
if ( buttonlist.empty() )
|
||||
return false;
|
||||
|
||||
auto iter = buttonlist.begin();
|
||||
auto last = buttonlist.end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : buttonlist)
|
||||
{
|
||||
auto toggle_button = static_cast<FToggleButton*>(*iter);
|
||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||
|
||||
if ( toggle_button->hasFocus() )
|
||||
return true;
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -162,17 +160,12 @@ bool FButtonGroup::hasCheckedButton() const
|
||||
if ( buttonlist.empty() )
|
||||
return false;
|
||||
|
||||
auto iter = buttonlist.begin();
|
||||
auto last = buttonlist.end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : buttonlist)
|
||||
{
|
||||
auto toggle_button = static_cast<FToggleButton*>(*iter);
|
||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||
|
||||
if ( toggle_button->isChecked() )
|
||||
return true;
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -181,21 +174,16 @@ bool FButtonGroup::hasCheckedButton() const
|
||||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::hide()
|
||||
{
|
||||
std::size_t size;
|
||||
FColor fg, bg;
|
||||
FColor fg{}, bg{};
|
||||
FWidget::hide();
|
||||
auto parent_widget = getParentWidget();
|
||||
|
||||
if ( ! buttonlist.empty() )
|
||||
{
|
||||
auto iter = buttonlist.begin();
|
||||
auto last = buttonlist.end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : buttonlist)
|
||||
{
|
||||
auto toggle_button = static_cast<FToggleButton*>(*iter);
|
||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||
toggle_button->hide();
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,19 +194,20 @@ void FButtonGroup::hide()
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
fg = wc.dialog_fg;
|
||||
bg = wc.dialog_bg;
|
||||
}
|
||||
|
||||
setColor (fg, bg);
|
||||
size = getWidth();
|
||||
std::size_t size = getWidth();
|
||||
|
||||
if ( size == 0 )
|
||||
return;
|
||||
|
||||
auto blank = createBlankArray(size + 1);
|
||||
char* blank = createBlankArray(size + 1);
|
||||
|
||||
for (int y = 0; y < int(getHeight()); y++)
|
||||
for (int y{0}; y < int(getHeight()); y++)
|
||||
{
|
||||
FWidget::setPrintPos (FPoint(1, 1 + y));
|
||||
print (blank);
|
||||
@ -270,7 +259,7 @@ void FButtonGroup::remove (FToggleButton* button)
|
||||
if ( toggle_button == button )
|
||||
{
|
||||
iter = buttonlist.erase(iter);
|
||||
button->setGroup(0);
|
||||
button->setGroup(nullptr);
|
||||
button->delCallback(this);
|
||||
break;
|
||||
}
|
||||
@ -296,7 +285,7 @@ void FButtonGroup::checkScrollSize (const FRect& r)
|
||||
|
||||
if ( ! scrollgeometry.contains(r) )
|
||||
{
|
||||
FRect r_combined = scrollgeometry.combined(r);
|
||||
FRect r_combined (scrollgeometry.combined(r));
|
||||
setScrollSize (r_combined.getSize());
|
||||
}
|
||||
}
|
||||
@ -321,19 +310,18 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
|
||||
{
|
||||
if ( hasCheckedButton() && ! buttonlist.empty() )
|
||||
{
|
||||
auto iter = buttonlist.begin();
|
||||
auto last = buttonlist.end();
|
||||
in_ev->ignore();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : buttonlist)
|
||||
{
|
||||
auto toggle_button = static_cast<FToggleButton*>(*iter);
|
||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||
|
||||
if ( toggle_button->isChecked() )
|
||||
{
|
||||
if ( isRadioButton(toggle_button) )
|
||||
{
|
||||
auto prev_element = getFocusWidget();
|
||||
in_ev->ignore();
|
||||
|
||||
toggle_button->setFocus();
|
||||
|
||||
FFocusEvent cfi (fc::ChildFocusIn_Event);
|
||||
@ -342,6 +330,9 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
|
||||
FFocusEvent in (fc::FocusIn_Event);
|
||||
FApplication::sendEvent(toggle_button, &in);
|
||||
|
||||
if ( in.isAccepted() )
|
||||
in_ev->accept();
|
||||
|
||||
if ( prev_element )
|
||||
prev_element->redraw();
|
||||
|
||||
@ -350,14 +341,12 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
} // end of range-based for loop
|
||||
}
|
||||
|
||||
if ( in_ev->isAccepted() )
|
||||
if ( ! in_ev->isAccepted() )
|
||||
{
|
||||
in_ev->ignore();
|
||||
in_ev->accept();
|
||||
auto prev_element = getFocusWidget();
|
||||
|
||||
if ( in_ev->getFocusType() == fc::FocusNextWidget )
|
||||
@ -387,6 +376,9 @@ void FButtonGroup::setHotkeyAccelerator()
|
||||
{
|
||||
FKey hotkey = getHotkey(text);
|
||||
|
||||
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
|
||||
hotkey -= 0xfee0;
|
||||
|
||||
if ( hotkey )
|
||||
{
|
||||
if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
|
||||
@ -422,12 +414,11 @@ void FButtonGroup::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::drawLabel()
|
||||
{
|
||||
wchar_t* LabelText;
|
||||
|
||||
if ( text.isNull() || text.isEmpty() )
|
||||
return;
|
||||
|
||||
FString txt = " " + text + " ";
|
||||
wchar_t* LabelText{};
|
||||
FString txt{" " + text + " "};
|
||||
std::size_t length = txt.getLength();
|
||||
|
||||
try
|
||||
@ -443,7 +434,7 @@ void FButtonGroup::drawLabel()
|
||||
wchar_t* src = const_cast<wchar_t*>(txt.wc_str());
|
||||
wchar_t* dest = const_cast<wchar_t*>(LabelText);
|
||||
unsetViewportPrint();
|
||||
auto hotkeypos = getHotkeyPos(src, dest, length);
|
||||
auto hotkeypos = finalcut::getHotkeyPos(src, dest, length);
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
length--;
|
||||
@ -461,7 +452,7 @@ void FButtonGroup::drawLabel()
|
||||
|
||||
// private methods of FButtonGroup
|
||||
//----------------------------------------------------------------------
|
||||
bool FButtonGroup::isRadioButton (FToggleButton* button) const
|
||||
bool FButtonGroup::isRadioButton (const FToggleButton* button) const
|
||||
{
|
||||
if ( ! button )
|
||||
return false;
|
||||
@ -473,42 +464,30 @@ bool FButtonGroup::isRadioButton (FToggleButton* button) const
|
||||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::init()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.label_fg);
|
||||
setBackgroundColor (wc.label_bg);
|
||||
setMinimumSize (FSize(7, 4));
|
||||
setMinimumSize (FSize(7, 3));
|
||||
buttonlist.clear(); // no buttons yet
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t FButtonGroup::getHotkeyPos ( wchar_t src[]
|
||||
, wchar_t dest[]
|
||||
, std::size_t length )
|
||||
{
|
||||
// find hotkey position in string
|
||||
// + generate a new string without the '&'-sign
|
||||
std::size_t pos = NOT_SET;
|
||||
wchar_t* txt = src;
|
||||
|
||||
for (std::size_t i = 0; i < length; i++)
|
||||
{
|
||||
if ( i < length && txt[i] == L'&' && pos == NOT_SET )
|
||||
{
|
||||
pos = i;
|
||||
i++;
|
||||
src++;
|
||||
}
|
||||
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::drawText ( wchar_t LabelText[]
|
||||
, std::size_t hotkeypos
|
||||
, std::size_t length )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
std::size_t column_width = getColumnWidth(LabelText);
|
||||
bool ellipsis{false};
|
||||
|
||||
if ( column_width > getClientWidth() )
|
||||
{
|
||||
std::size_t len = getClientWidth() - 3;
|
||||
FString s = finalcut::getColumnSubString (LabelText, 1, len);
|
||||
length = s.getLength();
|
||||
ellipsis = true;
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
@ -517,18 +496,18 @@ void FButtonGroup::drawText ( wchar_t LabelText[]
|
||||
else
|
||||
setColor(wc.label_inactive_fg, wc.label_inactive_bg);
|
||||
|
||||
for (std::size_t z = 0; z < length; z++)
|
||||
for (std::size_t z{0}; z < length; z++)
|
||||
{
|
||||
if ( (z == hotkeypos) && flags.active )
|
||||
if ( (z == hotkeypos) && getFlags().active )
|
||||
{
|
||||
setColor (wc.label_hotkey_fg, wc.label_hotkey_bg);
|
||||
|
||||
if ( ! flags.no_underline )
|
||||
if ( ! getFlags().no_underline )
|
||||
setUnderline();
|
||||
|
||||
print (LabelText[z]);
|
||||
|
||||
if ( ! flags.no_underline )
|
||||
if ( ! getFlags().no_underline )
|
||||
unsetUnderline();
|
||||
|
||||
setColor (wc.label_emphasis_fg, wc.label_bg);
|
||||
@ -537,6 +516,9 @@ void FButtonGroup::drawText ( wchar_t LabelText[]
|
||||
print (LabelText[z]);
|
||||
}
|
||||
|
||||
if ( ellipsis ) // Print ellipsis
|
||||
print() << FColorPair (wc.label_ellipsis_fg, wc.label_bg) << "..";
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
}
|
||||
@ -546,16 +528,13 @@ void FButtonGroup::directFocus()
|
||||
{
|
||||
if ( ! hasFocusedButton() )
|
||||
{
|
||||
bool found_checked = false;
|
||||
bool found_checked{false};
|
||||
|
||||
if ( hasCheckedButton() && ! buttonlist.empty() )
|
||||
{
|
||||
auto iter = buttonlist.begin();
|
||||
auto last = buttonlist.end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : buttonlist)
|
||||
{
|
||||
auto toggle_button = static_cast<FToggleButton*>(*iter);
|
||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||
|
||||
if ( toggle_button->isChecked() )
|
||||
{
|
||||
@ -576,9 +555,7 @@ void FButtonGroup::directFocus()
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
} // end of range-based for loop
|
||||
}
|
||||
|
||||
if ( ! found_checked )
|
||||
@ -615,12 +592,9 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, FDataPtr)
|
||||
if ( buttonlist.empty() )
|
||||
return;
|
||||
|
||||
auto iter = buttonlist.begin();
|
||||
auto last = buttonlist.end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : buttonlist)
|
||||
{
|
||||
auto toggle_button = static_cast<FToggleButton*>(*iter);
|
||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||
|
||||
if ( toggle_button != button
|
||||
&& toggle_button->isChecked()
|
||||
@ -631,8 +605,6 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, FDataPtr)
|
||||
if ( toggle_button->isShown() )
|
||||
toggle_button->redraw();
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
715
src/fcharmap.cpp
Normal file
715
src/fcharmap.cpp
Normal file
@ -0,0 +1,715 @@
|
||||
/***********************************************************************
|
||||
* fcharmap.cpp - Character mapping and encoding *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2019 Markus Gans *
|
||||
* *
|
||||
* The 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. *
|
||||
* *
|
||||
* The 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/fc.h"
|
||||
#include "final/ftypes.h"
|
||||
#include "final/fcharmap.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
namespace fc
|
||||
{
|
||||
|
||||
uInt character[][fc::NUM_OF_ENCODINGS] =
|
||||
{
|
||||
// .--------------------- Unicode (UTF-8)
|
||||
// | .--------------- VT100
|
||||
// | | .--------- PC (IBM-437)
|
||||
// | | | .---- ASCII (7-Bit)
|
||||
// | | | |
|
||||
{0x20ac, 0, 0xee, 'E'}, // € - Euro
|
||||
{0x00a3, '}', 0x9c, 'P'}, // £ - Pound
|
||||
{0x00a7, '$', 0x15, '$'}, // § - Section
|
||||
{0x25d8, '*', 0x08, '*'}, // ◘ - InverseBullet
|
||||
{0x25d9, '*', 0x0a, '*'}, // ◙ - InverseWhiteCircle
|
||||
{0x203c, '!', 0x13, '!'}, // ‼ - DoubleExclamationMark
|
||||
{0x2195, 'I', 0x12, 'I'}, // ↕ - UpDownArrow
|
||||
{0x2194, '-', 0x1d, '-'}, // ↔ - LeftRightArrow
|
||||
{0x25ac, '_', 0x16, '_'}, // ▬ - BlackRectangle
|
||||
{0x2191, '^', 0x18, '^'}, // ↑ - UpwardsArrow
|
||||
{0x2193, 'v', 0x19, 'v'}, // ↓ - DownwardsArrow
|
||||
{0x2192, '>', 0x1a, '>'}, // → - RightwardsArrow
|
||||
{0x2190, '<', 0x1b, '<'}, // ← - LeftwardsArrow
|
||||
{0x203a, '>', 0xaf, '>'}, // › - SingleRightAngleQuotationMark
|
||||
{0x2039, '<', 0xae, '<'}, // ‹ - SingleLeftAngleQuotationMark
|
||||
{0x2026, '.', '.', '.'}, // … - HorizontalEllipsis
|
||||
{0x03c0, '{', 0xe3, 'n'}, // π - Pi
|
||||
{0x207F, 'I', 0xfc, ' '}, // ⁿ - SuperscriptLatinSmallLetterN
|
||||
{0x2265, 'z', 0xf2, '>'}, // ≥ - GreaterThanOrEqualTo
|
||||
{0x2264, 'y', 0xf3, '<'}, // ≤ - LessThanOrEqualTo
|
||||
{0x2260, 0, 0xd8, '#'}, // ≠ - NotEqualTo
|
||||
{0x00b1, 'g', 0xf1, '#'}, // ± - PlusMinus
|
||||
{0x00f7, '/', 0xf6, '/'}, // ÷ - Division sign
|
||||
{0x00d7, 0, 'x', 'x'}, // × - Multiplication sign
|
||||
{0x02e3, '~', 0xfc, '`'}, // ˣ - Modifier letter small x
|
||||
{0x00b0, 'f', 0xb0, 'o'}, // ° - Degree
|
||||
{0x2022, '`', 0x04, '*'}, // • - Bullet
|
||||
{0x00b7, '`', 0xfa, '.'}, // · - small Bullet
|
||||
{0x25cf, '`', 0x04, '*'}, // ● - BlackCircle
|
||||
{0x2666, '`', 0x04, '*'}, // ◆ - BlackDiamondSuit
|
||||
{0x2424, 'h', ' ', ' '}, //  - SymbolForNewline (1)
|
||||
{0x240b, 'i', ' ', ' '}, // ␋ - SymbolForVerticalTab (1)
|
||||
{0x2409, 'b', ' ', ' '}, // ␉ - SymbolForHorizontalTab (1)
|
||||
{0x240c, 'c', ' ', ' '}, // ␌ - SymbolForFormFeed (1)
|
||||
{0x240d, 'd', ' ', ' '}, // ␍ - SymbolForCarriageReturn (1)
|
||||
{0x240a, 'e', ' ', ' '}, // ␊ - SymbolForLineFeed (1)
|
||||
{0x2592, 'a', 0xb0, '#'}, // ▒ - MediumShade
|
||||
{0x2588, '0', 0xdb, '#'}, // █ - FullBlock
|
||||
{0x25ae, '_', 0xfe, '#'}, // ▮ - BlackVerticalRectangle (1)
|
||||
{0x258c, 0, 0xdd, ' '}, // ▌ - LeftHalfBlock
|
||||
{0x2590, 0, 0xde, ' '}, // ▐ - RightHalfBlock
|
||||
{0x2584, 0, 0xdc, ' '}, // ▄ - LowerHalfBlock
|
||||
{0x2580, 0, 0xdf, ' '}, // ▀ - UpperHalfBlock
|
||||
{0x2500, 'q', 0xc4, '-'}, // ─ - BoxDrawingsHorizontal
|
||||
{0x2502, 'x', 0xb3, '|'}, // │ - BoxDrawingsVertical
|
||||
{0x250c, 'l', 0xda, '.'}, // ┌ - BoxDrawingsDownAndRight
|
||||
{0x2510, 'k', 0xbf, '.'}, // ┐ - BoxDrawingsDownAndLeft
|
||||
{0x2514, 'm', 0xc0, '`'}, // └ - BoxDrawingsUpAndRight
|
||||
{0x2518, 'j', 0xd9, '\''}, // ┘ - BoxDrawingsUpAndLeft
|
||||
{0x253c, 'n', 0xc5, '+'}, // ┼ - BoxDrawingsCross
|
||||
{0x252c, 'w', 0xc2, '+'}, // ┬ - BoxDrawingsDownAndHorizontal
|
||||
{0x2524, 'u', 0xb4, '+'}, // ┤ - BoxDrawingsVerticalAndLeft
|
||||
{0x251c, 't', 0xc3, '+'}, // ├ - BoxDrawingsVerticalAndRight
|
||||
{0x2534, 'v', 0xc1, '+'}, // ┴ - BoxDrawingsUpAndHorizontal
|
||||
{0x23ba, 'o', '~', '~'}, // ⎺ - HorizontalScanLine1 (1)
|
||||
{0x23bb, 'p', 0xc4, '-'}, // ⎻ - HorizontalScanLine3 (1)
|
||||
{0x23bc, 'r', 0xc4, '-'}, // ⎼ - HorizontalScanLine7 (1)
|
||||
{0x23bd, 's', '_', '_'}, // ⎽ - HorizontalScanLine9 (1)
|
||||
{0x25b2, '-', 0x1e, '^'}, // ▲ - BlackUpPointingTriangle
|
||||
{0x25bc, '.', 0x1f, 'v'}, // ▼ - BlackDownPointingTriangle
|
||||
{0x25b6, '+', 0x10, '>'}, // ▶ - BlackRightPointingTriangle
|
||||
{0x25c0, ',', 0x11, '<'}, // ◀ - BlackLeftPointingTriangle (1)
|
||||
{0x25ba, '+', 0x10, '>'}, // ► - BlackRightPointingPointer (1)
|
||||
{0x25c4, ',', 0x11, '<'}, // ◄ - BlackLeftPointingPointer
|
||||
{0x1ab4, 0, 0xb4, 0}, // ⊐ - NF_rev_left_arrow2 (2)
|
||||
{0x1ab5, 0, 0xb5, 0}, // ► - NF_rev_right_arrow2 (2)
|
||||
{0x1ab7, 0, 0xb7, 0}, // ) - NF_radio_button3 (2)
|
||||
{0x1ab8, 0, 0xb8, 0}, // ⎤ - NF_rev_border_corner_upper_right (2)
|
||||
{0x1ab9, 0, 0xb9, 0}, // ⎹ - NF_rev_border_line_right (2)
|
||||
{0x1aba, 0, 0xba, 0}, // ┤ - NF_rev_border_line_vertical_left (2)
|
||||
{0x1abb, 0, 0xbb, 0}, // ⎦ - NF_rev_border_corner_lower_right (2)
|
||||
{0x1abc, 0, 0xbc, 0}, // ⎸ - NF_border_line_left (2)
|
||||
{0x1abd, 0, 0xbd, 0}, //⎹◣ - NF_rev_up_arrow2 (2)
|
||||
{0x1abe, 0, 0xbe, 0}, //⎹◤ - NF_rev_down_arrow2 (2)
|
||||
{0x1ac0, 0, 0xc0, 0}, // └ - NF_border_corner_middle_lower_left (2)
|
||||
{0x1ac1, 0, 0xc1, 0}, // ◢⎸ - NF_rev_up_arrow1 (2)
|
||||
{0x1ac2, 0, 0xc2, 0}, // ◥⎸ - NF_rev_down_arrow1 (2)
|
||||
{0x1ac3, 0, 0xc3, 0}, // ├ - NF_border_line_vertical_right (2)
|
||||
{0x1ac5, 0, 0xc5, 0}, // = - NF_border_line_up_and_down (2)
|
||||
{0x1ac6, 0, 0xc6, 0}, // = - NF_shadow_box_middle (2)
|
||||
{0x1ac7, 0, 0xc7, 0}, // = - NF_shadow_box_hdd (2)
|
||||
{0x1ac8, 0, 0xc8, 0}, // ◄ - NF_rev_left_arrow1 (2)
|
||||
{0x1ac9, 0, 0xc9, 0}, // ⊏ - NF_rev_right_arrow1 (2)
|
||||
{0x1aca, 0, 0xca, 0}, // [ - NF_rev_menu_button1 (2)
|
||||
{0x1acb, 0, 0xcb, 0}, // - - NF_rev_menu_button2 (2)
|
||||
{0x1acc, 0, 0xcc, 0}, // ┌ - NF_border_corner_middle_upper_left (2)
|
||||
{0x1acd, 0, 0xcd, 0}, // = - NF_shadow_box_cd (2)
|
||||
{0x1ace, 0, 0xce, 0}, // [ - NF_shadow_box_left (2)
|
||||
{0x1acf, 0, 0xcf, 0}, // ┘ - NF_border_corner_middle_lower_right (2)
|
||||
{0x1ad0, 0, 0xd0, 0}, // ┐ - NF_border_corner_middle_upper_right (2)
|
||||
{0x1ad1, 0, 0xd1, 0}, // = - NF_shadow_box_net (2)
|
||||
{0x1ad2, 0, 0xd2, 0}, // ◢ - NF_rev_up_pointing_triangle1 (2)
|
||||
{0x1ad3, 0, 0xd3, 0}, // ⎣ - NF_border_corner_lower_left (2)
|
||||
{0x1ad4, 0, 0xd4, 0}, // _ - NF_border_line_bottom (2)
|
||||
{0x1ad5, 0, 0xd5, 0}, // O - NF_radio_button2 (2)
|
||||
{0x1ad6, 0, 0xd6, 0}, // ● - NF_radio_button2_checked (2)
|
||||
{0x1ad7, 0, 0xd7, 0}, // ◥ - NF_rev_down_pointing_triangle1 (2)
|
||||
{0x1ad8, 0, 0xd8, 0}, // ¯ - NF_border_line_upper (2)
|
||||
{0x1ad9, 0, 0xd9, 0}, // ( - NF_radio_button1 (2)
|
||||
{0x1ada, 0, 0xda, 0}, // ⎡ - NF_border_corner_upper_left (2)
|
||||
{0x1adc, 0, 0xdc, 0}, // ✓ - NF_shadow_box_checked (2)
|
||||
{0x1ae7, 0, 0xe7, 0}, // ║ - NF_rev_border_line_right_and_left (2)
|
||||
{0x1ae8, 0, 0xe8, 0}, // ◣ - NF_rev_up_pointing_triangle2 (2)
|
||||
{0x1ae9, 0, 0xe9, 0}, // ◤ - NF_rev_down_pointing_triangle2 (2)
|
||||
{0x1af4, 0, 0xf4, 0}, // ] - NF_rev_menu_button3 (2)
|
||||
{0x1af5, 0, 0xf5, 0}, // ] - NF_shadow_box_right (2)
|
||||
{0x1afb, 0, 0xfb, 0}, // ✓ - NF_check_mark (2)
|
||||
{0x221a, 0, 0xfb, 'x'}, // √ - square root
|
||||
{0x25cf, '`', 0x04, '*'} // ● - black circle
|
||||
};
|
||||
|
||||
/*
|
||||
* (1) Not defined in Windows Glyph List 4 (WGL4)
|
||||
* (2) Only supported in use with newfont
|
||||
*/
|
||||
|
||||
const std::size_t lastCharItem = \
|
||||
std::size_t((sizeof(character) / sizeof(character[0])) - 1);
|
||||
|
||||
|
||||
int vt100_key_to_utf8[][2] =
|
||||
{
|
||||
{fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ►
|
||||
{fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄
|
||||
{fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}, // ▲
|
||||
{fc::vt100_key_darrow , fc::BlackDownPointingTriangle}, // ▼
|
||||
{fc::vt100_key_block , fc::FullBlock}, // █
|
||||
{fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}, // ⁿ
|
||||
{fc::vt100_key_blackrect, fc::BlackVerticalRectangle}, // ▮
|
||||
{fc::vt100_key_diamond , fc::BlackDiamondSuit}, // ◆
|
||||
{fc::vt100_key_ckboard , fc::MediumShade}, // ▒
|
||||
{fc::vt100_key_htab , fc::SymbolForHorizontalTab}, // ␉
|
||||
{fc::vt100_key_ff , fc::SymbolForFormFeed}, // ␌
|
||||
{fc::vt100_key_cr , fc::SymbolForCarriageReturn}, // ␍
|
||||
{fc::vt100_key_lf , fc::SymbolForLineFeed}, // ␊
|
||||
{fc::vt100_key_degree , fc::Degree}, // °
|
||||
{fc::vt100_key_plminus , fc::PlusMinus}, // ±
|
||||
{fc::vt100_key_board , fc::SymbolForNewline}, // 
|
||||
{fc::vt100_key_lantern , fc::SymbolForVerticalTab}, // ␋
|
||||
{fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}, // ┘
|
||||
{fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}, // ┐
|
||||
{fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}, // ┌
|
||||
{fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}, // └
|
||||
{fc::vt100_key_plus , fc::BoxDrawingsCross}, // ┼
|
||||
{fc::vt100_key_s1 , fc::HorizontalScanLine1}, // ⎺
|
||||
{fc::vt100_key_s3 , fc::HorizontalScanLine3}, // ⎻
|
||||
{fc::vt100_key_hline , fc::BoxDrawingsHorizontal}, // ─
|
||||
{fc::vt100_key_s7 , fc::HorizontalScanLine7}, // ⎼
|
||||
{fc::vt100_key_s9 , fc::HorizontalScanLine9}, // ⎽
|
||||
{fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}, // ├
|
||||
{fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}, // ┤
|
||||
{fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}, // ┴
|
||||
{fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}, // ┬
|
||||
{fc::vt100_key_vline , fc::BoxDrawingsVertical}, // │
|
||||
{fc::vt100_key_lequal , fc::LessThanOrEqualTo}, // ≤
|
||||
{fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}, // ≥
|
||||
{fc::vt100_key_pi , fc::Pi}, // π
|
||||
{fc::vt100_key_nequal , fc::NotEqualTo}, // ≠
|
||||
{fc::vt100_key_sterling , fc::Pound}, // £
|
||||
{fc::vt100_key_bullet , fc::SmallBullet}, // ·
|
||||
{fc::vt100_key_diamond , fc::Bullet} // ◆
|
||||
};
|
||||
|
||||
const std::size_t lastKeyItem = \
|
||||
std::size_t((sizeof(vt100_key_to_utf8) / sizeof(vt100_key_to_utf8[0])) - 1);
|
||||
|
||||
|
||||
wchar_t cp437_to_ucs[][2] =
|
||||
{
|
||||
{0x00, 0x0000}, // null
|
||||
{0x01, 0x263a}, // white smiling face
|
||||
{0x02, 0x263b}, // black smiling face
|
||||
{0x03, 0x2665}, // black heart suit
|
||||
{0x04, 0x2666}, // black diamond suit
|
||||
{0x05, 0x2663}, // black club suit
|
||||
{0x06, 0x2660}, // black spade suit
|
||||
{0x07, 0x2022}, // bullet
|
||||
{0x08, 0x25d8}, // inverse bullet
|
||||
{0x09, 0x25cb}, // white circle
|
||||
{0x0a, 0x25d9}, // inverse white circle
|
||||
{0x0b, 0x2642}, // male sign
|
||||
{0x0c, 0x2640}, // female sign
|
||||
{0x0d, 0x266a}, // eighth note
|
||||
{0x0e, 0x266b}, // beamed eighth notes
|
||||
{0x0f, 0x263c}, // white sun with rays
|
||||
{0x10, 0x25ba}, // black right-pointing pointer
|
||||
{0x11, 0x25c4}, // black left-pointing pointer
|
||||
{0x12, 0x2195}, // up down arrow
|
||||
{0x13, 0x203c}, // double exclamation mark
|
||||
{0x14, 0x00b6}, // pilcrow sign
|
||||
{0x15, 0x00a7}, // section sign
|
||||
{0x16, 0x25ac}, // black rectangle
|
||||
{0x17, 0x21a8}, // up down arrow with base
|
||||
{0x18, 0x2191}, // upwards arrow
|
||||
{0x19, 0x2193}, // downwards arrow
|
||||
{0x1a, 0x2192}, // rightwards arrow
|
||||
{0x1b, 0x2190}, // leftwards arrow
|
||||
{0x1c, 0x221f}, // right angle
|
||||
{0x1d, 0x2194}, // left right arrow
|
||||
{0x1e, 0x25b2}, // black up-pointing triangle
|
||||
{0x1f, 0x25bc}, // black down-pointing triangle
|
||||
{0x20, 0x0020}, // space
|
||||
{0x21, 0x0021}, // exclamation mark
|
||||
{0x22, 0x0022}, // quotation mark
|
||||
{0x23, 0x0023}, // number sign
|
||||
{0x24, 0x0024}, // dollar sign
|
||||
{0x25, 0x0025}, // percent sign
|
||||
{0x26, 0x0026}, // ampersand
|
||||
{0x27, 0x0027}, // apostrophe
|
||||
{0x28, 0x0028}, // left parenthesis
|
||||
{0x29, 0x0029}, // right parenthesis
|
||||
{0x2a, 0x002a}, // asterisk
|
||||
{0x2b, 0x002b}, // plus sign
|
||||
{0x2c, 0x002c}, // comma
|
||||
{0x2d, 0x002d}, // hyphen-minus
|
||||
{0x2e, 0x002e}, // full stop
|
||||
{0x2f, 0x002f}, // solidus
|
||||
{0x30, 0x0030}, // digit zero
|
||||
{0x31, 0x0031}, // digit one
|
||||
{0x32, 0x0032}, // digit two
|
||||
{0x33, 0x0033}, // digit three
|
||||
{0x34, 0x0034}, // digit four
|
||||
{0x35, 0x0035}, // digit five
|
||||
{0x36, 0x0036}, // digit six
|
||||
{0x37, 0x0037}, // digit seven
|
||||
{0x38, 0x0038}, // digit eight
|
||||
{0x39, 0x0039}, // digit nine
|
||||
{0x3a, 0x003a}, // colon
|
||||
{0x3b, 0x003b}, // semicolon
|
||||
{0x3c, 0x003c}, // less-than sign
|
||||
{0x3d, 0x003d}, // equals sign
|
||||
{0x3e, 0x003e}, // greater-than sign
|
||||
{0x3f, 0x003f}, // question mark
|
||||
{0x40, 0x0040}, // commercial at
|
||||
{0x41, 0x0041}, // latin capital letter a
|
||||
{0x42, 0x0042}, // latin capital letter b
|
||||
{0x43, 0x0043}, // latin capital letter c
|
||||
{0x44, 0x0044}, // latin capital letter d
|
||||
{0x45, 0x0045}, // latin capital letter e
|
||||
{0x46, 0x0046}, // latin capital letter f
|
||||
{0x47, 0x0047}, // latin capital letter g
|
||||
{0x48, 0x0048}, // latin capital letter h
|
||||
{0x49, 0x0049}, // latin capital letter i
|
||||
{0x4a, 0x004a}, // latin capital letter j
|
||||
{0x4b, 0x004b}, // latin capital letter k
|
||||
{0x4c, 0x004c}, // latin capital letter l
|
||||
{0x4d, 0x004d}, // latin capital letter m
|
||||
{0x4e, 0x004e}, // latin capital letter n
|
||||
{0x4f, 0x004f}, // latin capital letter o
|
||||
{0x50, 0x0050}, // latin capital letter p
|
||||
{0x51, 0x0051}, // latin capital letter q
|
||||
{0x52, 0x0052}, // latin capital letter r
|
||||
{0x53, 0x0053}, // latin capital letter s
|
||||
{0x54, 0x0054}, // latin capital letter t
|
||||
{0x55, 0x0055}, // latin capital letter u
|
||||
{0x56, 0x0056}, // latin capital letter v
|
||||
{0x57, 0x0057}, // latin capital letter w
|
||||
{0x58, 0x0058}, // latin capital letter x
|
||||
{0x59, 0x0059}, // latin capital letter y
|
||||
{0x5a, 0x005a}, // latin capital letter z
|
||||
{0x5b, 0x005b}, // left square bracket
|
||||
{0x5c, 0x005c}, // reverse solidus
|
||||
{0x5d, 0x005d}, // right square bracket
|
||||
{0x5e, 0x005e}, // circumflex accent
|
||||
{0x5f, 0x005f}, // low line
|
||||
{0x60, 0x0060}, // grave accent
|
||||
{0x61, 0x0061}, // latin small letter a
|
||||
{0x62, 0x0062}, // latin small letter b
|
||||
{0x63, 0x0063}, // latin small letter c
|
||||
{0x64, 0x0064}, // latin small letter d
|
||||
{0x65, 0x0065}, // latin small letter e
|
||||
{0x66, 0x0066}, // latin small letter f
|
||||
{0x67, 0x0067}, // latin small letter g
|
||||
{0x68, 0x0068}, // latin small letter h
|
||||
{0x69, 0x0069}, // latin small letter i
|
||||
{0x6a, 0x006a}, // latin small letter j
|
||||
{0x6b, 0x006b}, // latin small letter k
|
||||
{0x6c, 0x006c}, // latin small letter l
|
||||
{0x6d, 0x006d}, // latin small letter m
|
||||
{0x6e, 0x006e}, // latin small letter n
|
||||
{0x6f, 0x006f}, // latin small letter o
|
||||
{0x70, 0x0070}, // latin small letter p
|
||||
{0x71, 0x0071}, // latin small letter q
|
||||
{0x72, 0x0072}, // latin small letter r
|
||||
{0x73, 0x0073}, // latin small letter s
|
||||
{0x74, 0x0074}, // latin small letter t
|
||||
{0x75, 0x0075}, // latin small letter u
|
||||
{0x76, 0x0076}, // latin small letter v
|
||||
{0x77, 0x0077}, // latin small letter w
|
||||
{0x78, 0x0078}, // latin small letter x
|
||||
{0x79, 0x0079}, // latin small letter y
|
||||
{0x7a, 0x007a}, // latin small letter z
|
||||
{0x7b, 0x007b}, // left curly bracket
|
||||
{0x7c, 0x007c}, // vertical line
|
||||
{0x7d, 0x007d}, // right curly bracket
|
||||
{0x7e, 0x007e}, // tilde
|
||||
{0x7f, 0x007f}, // house
|
||||
{0x80, 0x00c7}, // latin capital letter c with cedilla
|
||||
{0x81, 0x00fc}, // latin small letter u with diaeresis
|
||||
{0x82, 0x00e9}, // latin small letter e with acute
|
||||
{0x83, 0x00e2}, // latin small letter a with circumflex
|
||||
{0x84, 0x00e4}, // latin small letter a with diaeresis
|
||||
{0x85, 0x00e0}, // latin small letter a with grave
|
||||
{0x86, 0x00e5}, // latin small letter a with ring above
|
||||
{0x87, 0x00e7}, // latin small letter c with cedilla
|
||||
{0x88, 0x00ea}, // latin small letter e with circumflex
|
||||
{0x89, 0x00eb}, // latin small letter e with diaeresis
|
||||
{0x8a, 0x00e8}, // latin small letter e with grave
|
||||
{0x8b, 0x00ef}, // latin small letter i with diaeresis
|
||||
{0x8c, 0x00ee}, // latin small letter i with circumflex
|
||||
{0x8d, 0x00ec}, // latin small letter i with grave
|
||||
{0x8e, 0x00c4}, // latin capital letter a with diaeresis
|
||||
{0x8f, 0x00c5}, // latin capital letter a with ring above
|
||||
{0x90, 0x00c9}, // latin capital letter e with acute
|
||||
{0x91, 0x00e6}, // latin small ligature ae
|
||||
{0x92, 0x00c6}, // latin capital ligature ae
|
||||
{0x93, 0x00f4}, // latin small letter o with circumflex
|
||||
{0x94, 0x00f6}, // latin small letter o with diaeresis
|
||||
{0x95, 0x00f2}, // latin small letter o with grave
|
||||
{0x96, 0x00fb}, // latin small letter u with circumflex
|
||||
{0x97, 0x00f9}, // latin small letter u with grave
|
||||
{0x98, 0x00ff}, // latin small letter y with diaeresis
|
||||
{0x99, 0x00d6}, // latin capital letter o with diaeresis
|
||||
{0x9a, 0x00dc}, // latin capital letter u with diaeresis
|
||||
{0x9b, 0x00a2}, // cent sign
|
||||
{0x9c, 0x00a3}, // pound sign
|
||||
{0x9d, 0x00a5}, // yen sign
|
||||
{0x9e, 0x20a7}, // peseta sign
|
||||
{0x9f, 0x0192}, // latin small letter f with hook
|
||||
{0xa0, 0x00e1}, // latin small letter a with acute
|
||||
{0xa1, 0x00ed}, // latin small letter i with acute
|
||||
{0xa2, 0x00f3}, // latin small letter o with acute
|
||||
{0xa3, 0x00fa}, // latin small letter u with acute
|
||||
{0xa4, 0x00f1}, // latin small letter n with tilde
|
||||
{0xa5, 0x00d1}, // latin capital letter n with tilde
|
||||
{0xa6, 0x00aa}, // feminine ordinal indicator
|
||||
{0xa7, 0x00ba}, // masculine ordinal indicator
|
||||
{0xa8, 0x00bf}, // inverted question mark
|
||||
{0xa9, 0x2310}, // reversed not sign
|
||||
{0xaa, 0x00ac}, // not sign
|
||||
{0xab, 0x00bd}, // vulgar fraction one half
|
||||
{0xac, 0x00bc}, // vulgar fraction one quarter
|
||||
{0xad, 0x00a1}, // inverted exclamation mark
|
||||
{0xae, 0x00ab}, // left-pointing double angle quotation mark
|
||||
{0xaf, 0x00bb}, // right-pointing double angle quotation mark
|
||||
{0xb0, 0x2591}, // light shade
|
||||
{0xb1, 0x2592}, // medium shade
|
||||
{0xb2, 0x2593}, // dark shade
|
||||
{0xb3, 0x2502}, // box drawings light vertical
|
||||
{0xb4, 0x2524}, // box drawings light vertical and left
|
||||
{0xb5, 0x2561}, // box drawings vertical single and left double
|
||||
{0xb6, 0x2562}, // box drawings vertical double and left single
|
||||
{0xb7, 0x2556}, // box drawings down double and left single
|
||||
{0xb8, 0x2555}, // box drawings down single and left double
|
||||
{0xb9, 0x2563}, // box drawings double vertical and left
|
||||
{0xba, 0x2551}, // box drawings double vertical
|
||||
{0xbb, 0x2557}, // box drawings double down and left
|
||||
{0xbc, 0x255d}, // box drawings double up and left
|
||||
{0xbd, 0x255c}, // box drawings up double and left single
|
||||
{0xbe, 0x255b}, // box drawings up single and left double
|
||||
{0xbf, 0x2510}, // box drawings light down and left
|
||||
{0xc0, 0x2514}, // box drawings light up and right
|
||||
{0xc1, 0x2534}, // box drawings light up and horizontal
|
||||
{0xc2, 0x252c}, // box drawings light down and horizontal
|
||||
{0xc3, 0x251c}, // box drawings light vertical and right
|
||||
{0xc4, 0x2500}, // box drawings light horizontal
|
||||
{0xc5, 0x253c}, // box drawings light vertical and horizontal
|
||||
{0xc6, 0x255e}, // box drawings vertical single and right double
|
||||
{0xc7, 0x255f}, // box drawings vertical double and right single
|
||||
{0xc8, 0x255a}, // box drawings double up and right
|
||||
{0xc9, 0x2554}, // box drawings double down and right
|
||||
{0xca, 0x2569}, // box drawings double up and horizontal
|
||||
{0xcb, 0x2566}, // box drawings double down and horizontal
|
||||
{0xcc, 0x2560}, // box drawings double vertical and right
|
||||
{0xcd, 0x2550}, // box drawings double horizontal
|
||||
{0xce, 0x256c}, // box drawings double vertical and horizontal
|
||||
{0xcf, 0x2567}, // box drawings up single and horizontal double
|
||||
{0xd0, 0x2568}, // box drawings up double and horizontal single
|
||||
{0xd1, 0x2564}, // box drawings down single and horizontal double
|
||||
{0xd2, 0x2565}, // box drawings down double and horizontal single
|
||||
{0xd3, 0x2559}, // box drawings up double and right single
|
||||
{0xd4, 0x2558}, // box drawings up single and right double
|
||||
{0xd5, 0x2552}, // box drawings down single and right double
|
||||
{0xd6, 0x2553}, // box drawings down double and right single
|
||||
{0xd7, 0x256b}, // box drawings vertical double and horizontal single
|
||||
{0xd8, 0x256a}, // box drawings vertical single and horizontal double
|
||||
{0xd9, 0x2518}, // box drawings light up and left
|
||||
{0xda, 0x250c}, // box drawings light down and right
|
||||
{0xdb, 0x2588}, // full block
|
||||
{0xdc, 0x2584}, // lower half block
|
||||
{0xdd, 0x258c}, // left half block
|
||||
{0xde, 0x2590}, // right half block
|
||||
{0xdf, 0x2580}, // upper half block
|
||||
{0xe0, 0x03b1}, // greek small letter alpha
|
||||
{0xe1, 0x00df}, // latin small letter sharp s
|
||||
{0xe2, 0x0393}, // greek capital letter gamma
|
||||
{0xe3, 0x03c0}, // greek small letter pi
|
||||
{0xe4, 0x03a3}, // greek capital letter sigma
|
||||
{0xe5, 0x03c3}, // greek small letter sigma
|
||||
{0xe6, 0x00b5}, // micro sign
|
||||
{0xe7, 0x03c4}, // greek small letter tau
|
||||
{0xe8, 0x03a6}, // greek capital letter phi
|
||||
{0xe9, 0x0398}, // greek capital letter theta
|
||||
{0xea, 0x03a9}, // greek capital letter omega
|
||||
{0xeb, 0x03b4}, // greek small letter delta
|
||||
{0xec, 0x221e}, // infinity
|
||||
{0xed, 0x03c6}, // greek small letter phi
|
||||
{0xee, 0x03b5}, // greek small letter epsilon
|
||||
{0xef, 0x2229}, // intersection
|
||||
{0xf0, 0x2261}, // identical to
|
||||
{0xf1, 0x00b1}, // plus-minus sign
|
||||
{0xf2, 0x2265}, // greater-than or equal to
|
||||
{0xf3, 0x2264}, // less-than or equal to
|
||||
{0xf4, 0x2320}, // top half integral
|
||||
{0xf5, 0x2321}, // bottom half integral
|
||||
{0xf6, 0x00f7}, // division sign
|
||||
{0xf7, 0x2248}, // almost equal to
|
||||
{0xf8, 0x00b0}, // degree sign
|
||||
{0xf9, 0x2219}, // bullet operator
|
||||
{0xfa, 0x00b7}, // middle dot
|
||||
{0xfb, 0x221a}, // square root
|
||||
{0xfc, 0x207f}, // superscript latin small letter n
|
||||
{0xfd, 0x00b2}, // superscript two
|
||||
{0xfe, 0x25a0}, // black square
|
||||
{0xff, 0x00a0} // no-break space
|
||||
};
|
||||
|
||||
const std::size_t lastCP437Item = \
|
||||
std::size_t((sizeof(cp437_to_ucs) / sizeof(cp437_to_ucs[0])) - 1);
|
||||
|
||||
// Based on http://www.unicode.org/charts/PDF/UFF00.pdf
|
||||
wchar_t halfWidth_fullWidth[][2] =
|
||||
{
|
||||
// Fullwidth ASCII variants
|
||||
{0x0020, 0x3000}, // ' ' -> ' '
|
||||
{0x0021, 0xff01}, // ! -> !
|
||||
{0x0022, 0xff02}, // " -> "
|
||||
{0x0023, 0xff03}, // # -> #
|
||||
{0x0024, 0xff04}, // $ -> $
|
||||
{0x0025, 0xff05}, // % -> %
|
||||
{0x0026, 0xff06}, // & -> &
|
||||
{0x0027, 0xff07}, // ' -> '
|
||||
{0x0028, 0xff08}, // ( -> (
|
||||
{0x0029, 0xff09}, // ) -> )
|
||||
{0x002a, 0xff0a}, // * -> *
|
||||
{0x002b, 0xff0b}, // + -> +
|
||||
{0x002c, 0xff0c}, // , -> ,
|
||||
{0x002d, 0xff0d}, // - -> -
|
||||
{0x002e, 0xff0e}, // . -> .
|
||||
{0x002f, 0xff0f}, // / -> /
|
||||
{0x0030, 0xff10}, // 0 -> 0
|
||||
{0x0031, 0xff11}, // 1 -> 1
|
||||
{0x0032, 0xff12}, // 2 -> 2
|
||||
{0x0033, 0xff13}, // 3 -> 3
|
||||
{0x0034, 0xff14}, // 4 -> 4
|
||||
{0x0035, 0xff15}, // 5 -> 5
|
||||
{0x0036, 0xff16}, // 6 -> 6
|
||||
{0x0037, 0xff17}, // 7 -> 7
|
||||
{0x0038, 0xff18}, // 8 -> 8
|
||||
{0x0039, 0xff19}, // 9 -> 9
|
||||
{0x003a, 0xff1a}, // : -> :
|
||||
{0x003b, 0xff1b}, // ; -> ;
|
||||
{0x003c, 0xff1c}, // < -> <
|
||||
{0x003d, 0xff1d}, // = -> =
|
||||
{0x003e, 0xff1e}, // > -> >
|
||||
{0x003f, 0xff1f}, // ? -> ?
|
||||
{0x0040, 0xff20}, // @ -> @
|
||||
{0x0041, 0xff21}, // A -> A
|
||||
{0x0042, 0xff22}, // B -> B
|
||||
{0x0043, 0xff23}, // C -> C
|
||||
{0x0044, 0xff24}, // D -> D
|
||||
{0x0045, 0xff25}, // E -> E
|
||||
{0x0046, 0xff26}, // F -> F
|
||||
{0x0047, 0xff27}, // G -> G
|
||||
{0x0048, 0xff28}, // H -> H
|
||||
{0x0049, 0xff29}, // I -> I
|
||||
{0x004a, 0xff2a}, // J -> J
|
||||
{0x004b, 0xff2b}, // K -> K
|
||||
{0x004c, 0xff2c}, // L -> L
|
||||
{0x004d, 0xff2d}, // M -> M
|
||||
{0x004e, 0xff2e}, // N -> N
|
||||
{0x004f, 0xff2f}, // O -> O
|
||||
{0x0050, 0xff30}, // P -> P
|
||||
{0x0051, 0xff31}, // Q -> Q
|
||||
{0x0052, 0xff32}, // R -> R
|
||||
{0x0053, 0xff33}, // S -> S
|
||||
{0x0054, 0xff34}, // T -> T
|
||||
{0x0055, 0xff35}, // U -> U
|
||||
{0x0056, 0xff36}, // V -> V
|
||||
{0x0057, 0xff37}, // W -> W
|
||||
{0x0058, 0xff38}, // X -> X
|
||||
{0x0059, 0xff39}, // Y -> Y
|
||||
{0x005a, 0xff3a}, // Z -> Z
|
||||
{0x005b, 0xff3b}, // [ -> [
|
||||
{0x005c, 0xff3c}, // \ -> \
|
||||
{0x005d, 0xff3c}, // ] -> ]
|
||||
{0x005e, 0xff3e}, // ^ -> ^
|
||||
{0x005f, 0xff3f}, // _ -> _
|
||||
{0x0060, 0xff40}, // ` -> `
|
||||
{0x0061, 0xff41}, // a -> a
|
||||
{0x0062, 0xff42}, // b -> b
|
||||
{0x0063, 0xff43}, // c -> c
|
||||
{0x0064, 0xff44}, // d -> d
|
||||
{0x0065, 0xff45}, // e -> e
|
||||
{0x0066, 0xff46}, // f -> f
|
||||
{0x0067, 0xff47}, // g -> g
|
||||
{0x0068, 0xff48}, // h -> h
|
||||
{0x0069, 0xff49}, // i -> i
|
||||
{0x006a, 0xff4a}, // j -> j
|
||||
{0x006b, 0xff4b}, // k -> k
|
||||
{0x006c, 0xff4c}, // l -> l
|
||||
{0x006d, 0xff4d}, // m -> m
|
||||
{0x006e, 0xff4e}, // n -> n
|
||||
{0x006f, 0xff4f}, // o -> o
|
||||
{0x0070, 0xff50}, // p -> p
|
||||
{0x0071, 0xff51}, // q -> q
|
||||
{0x0072, 0xff52}, // r -> r
|
||||
{0x0073, 0xff53}, // s -> s
|
||||
{0x0074, 0xff54}, // t -> t
|
||||
{0x0075, 0xff55}, // u -> u
|
||||
{0x0076, 0xff56}, // v -> v
|
||||
{0x0077, 0xff57}, // w -> w
|
||||
{0x0078, 0xff58}, // x -> x
|
||||
{0x0079, 0xff59}, // y -> y
|
||||
{0x007a, 0xff5a}, // z -> z
|
||||
{0x007b, 0xff5b}, // { -> {
|
||||
{0x007c, 0xff5c}, // | -> |
|
||||
{0x007d, 0xff5d}, // } -> }
|
||||
{0x007e, 0xff5e}, // ~ -> ~
|
||||
{0x007e, 0x0301}, // ~ -> 〜
|
||||
// Fullwidth brackets
|
||||
{0xff5f, 0x2e28}, // ⦅ -> ⸨
|
||||
{0xff60, 0x2e29}, // ⦆ -> ⸩
|
||||
// Halfwidth CJK punctuation
|
||||
{0xff61, 0x3002}, // 。 -> 。
|
||||
{0xff62, 0x300c}, // 「 -> 「
|
||||
{0xff63, 0x300d}, // 」 -> 」
|
||||
{0xff64, 0x3001}, // 、 -> 、
|
||||
// Halfwidth Katakana variants
|
||||
{0xff65, 0x30fb}, // ・ -> ・
|
||||
{0xff66, 0x30f2}, // ヲ -> ヲ
|
||||
{0xff67, 0x30a1}, // ァ -> ァ
|
||||
{0xff68, 0x30a3}, // ィ -> ィ
|
||||
{0xff69, 0x30a5}, // ゥ -> ゥ
|
||||
{0xff6a, 0x30a7}, // ェ -> ェ
|
||||
{0xff6b, 0x30a9}, // ォ -> ォ
|
||||
{0xff6c, 0x30e3}, // ャ -> ャ
|
||||
{0xff6d, 0x30e5}, // ュ -> ュ
|
||||
{0xff6e, 0x30e7}, // ョ -> ョ
|
||||
{0xff6f, 0x30c3}, // ッ -> ッ
|
||||
{0xff70, 0x30fc}, // ー -> ー
|
||||
{0xff71, 0x30a2}, // ア -> ア
|
||||
{0xff72, 0x30a4}, // イ -> イ
|
||||
{0xff73, 0x30a6}, // ウ -> ウ
|
||||
{0xff74, 0x30a8}, // エ -> エ
|
||||
{0xff75, 0x30aa}, // オ -> オ
|
||||
{0xff76, 0x30ab}, // カ -> カ
|
||||
{0xff77, 0x30ad}, // キ -> キ
|
||||
{0xff78, 0x30af}, // ク -> ク
|
||||
{0xff79, 0x30b1}, // ケ -> ケ
|
||||
{0xff7a, 0x30b3}, // コ -> コ
|
||||
{0xff7b, 0x30b5}, // サ -> サ
|
||||
{0xff7c, 0x30b7}, // シ -> シ
|
||||
{0xff7d, 0x30b9}, // ス -> ス
|
||||
{0xff7e, 0x30bb}, // セ -> セ
|
||||
{0xff7f, 0x30bd}, // ソ -> ソ
|
||||
{0xff80, 0x30bf}, // タ -> タ
|
||||
{0xff81, 0x30c1}, // チ -> チ
|
||||
{0xff82, 0x30c4}, // ツ -> ツ
|
||||
{0xff83, 0x30c6}, // テ -> テ
|
||||
{0xff84, 0x30c8}, // ト -> ト
|
||||
{0xff85, 0x30ca}, // ナ -> ナ
|
||||
{0xff86, 0x30cb}, // ニ -> ニ
|
||||
{0xff87, 0x30cc}, // ヌ -> ヌ
|
||||
{0xff88, 0x30cd}, // ネ -> ネ
|
||||
{0xff89, 0x30ce}, // ノ -> ノ
|
||||
{0xff8a, 0x30cf}, // ハ -> ハ
|
||||
{0xff8b, 0x30d2}, // ヒ -> ヒ
|
||||
{0xff8c, 0x30d5}, // フ -> フ
|
||||
{0xff8d, 0x30d8}, // ヘ -> ヘ
|
||||
{0xff8e, 0x30db}, // ホ -> ホ
|
||||
{0xff8f, 0x30de}, // マ -> マ
|
||||
{0xff90, 0x30df}, // ミ -> ミ
|
||||
{0xff91, 0x30e0}, // ム -> ム
|
||||
{0xff92, 0x30e1}, // メ -> メ
|
||||
{0xff93, 0x30e2}, // モ -> モ
|
||||
{0xff94, 0x30e4}, // ヤ -> ヤ
|
||||
{0xff95, 0x30e6}, // ユ -> ユ
|
||||
{0xff96, 0x30e8}, // ヨ -> ヨ
|
||||
{0xff97, 0x30e9}, // ラ -> ラ
|
||||
{0xff98, 0x30ea}, // リ -> リ
|
||||
{0xff99, 0x30eb}, // ル -> ル
|
||||
{0xff9a, 0x30ec}, // レ -> レ
|
||||
{0xff9b, 0x30ed}, // ロ -> ロ
|
||||
{0xff9c, 0x30ef}, // ワ -> ワ
|
||||
{0xff9d, 0x30f3}, // ン -> ン
|
||||
{0xff9e, 0x3099}, // ゙ -> ゙
|
||||
{0xff9f, 0x309a}, // ゚ -> ゚
|
||||
// Halfwidth Hangul variants
|
||||
{0xffa0, 0x3164}, // ᅠ-> ᅠ
|
||||
{0xffa1, 0x3131}, // ᄀ -> ㄱ
|
||||
{0xffa2, 0x3132}, // ᄁ -> ㄲ
|
||||
{0xffa3, 0x3133}, // ᆪ -> ㄳ
|
||||
{0xffa4, 0x3134}, // ᄂ -> ㄴ
|
||||
{0xffa5, 0x3135}, // ᆬ -> ㄵ
|
||||
{0xffa6, 0x3136}, // ᆭ -> ㄶ
|
||||
{0xffa7, 0x3137}, // ᄃ -> ㄷ
|
||||
{0xffa8, 0x3138}, // ᄄ -> ㄸ
|
||||
{0xffa9, 0x3139}, // ᄅ -> ㄹ
|
||||
{0xffaa, 0x313a}, // ᆰ -> ㄺ
|
||||
{0xffab, 0x313b}, // ᆱ -> ㄻ
|
||||
{0xffac, 0x313c}, // ᆲ -> ㄼ
|
||||
{0xffad, 0x313d}, // ᆳ -> ㄽ
|
||||
{0xffae, 0x313e}, // ᆴ -> ㄾ
|
||||
{0xffaf, 0x313f}, // ᆵ -> ㄿ
|
||||
{0xffb0, 0x3140}, // ᄚ -> ㅀ
|
||||
{0xffb1, 0x3141}, // ᄆ -> ㅁ
|
||||
{0xffb2, 0x3142}, // ᄇ -> ㅂ
|
||||
{0xffb3, 0x3143}, // ᄈ -> ㅃ
|
||||
{0xffb4, 0x3144}, // ᄡ -> ㅄ
|
||||
{0xffb5, 0x3145}, // ᄉ -> ㅅ
|
||||
{0xffb6, 0x3146}, // ᄊ -> ㅆ
|
||||
{0xffb7, 0x3147}, // ᄋ -> ㅇ
|
||||
{0xffb8, 0x3148}, // ᄌ -> ㅈ
|
||||
{0xffb9, 0x3149}, // ᄍ -> ㅉ
|
||||
{0xffba, 0x314a}, // ᄎ -> ㅊ
|
||||
{0xffbb, 0x314b}, // ᄏ -> ㅋ
|
||||
{0xffbc, 0x314c}, // ᄐ -> ㅌ
|
||||
{0xffbd, 0x314d}, // ᄑ -> ㅍ
|
||||
{0xffbe, 0x314e}, // ᄒ -> ㅎ
|
||||
{0xffc2, 0x314f}, // ᅡ -> ㅏ
|
||||
{0xffc3, 0x3150}, // ᅢ -> ㅐ
|
||||
{0xffc4, 0x3151}, // ᅣ -> ㅑ
|
||||
{0xffc5, 0x3152}, // ᅤ -> ㅒ
|
||||
{0xffc6, 0x3153}, // ᅥ -> ㅓ
|
||||
{0xffc7, 0x3154}, // ᅦ -> ㅔ
|
||||
{0xffca, 0x3155}, // ᅧ -> ㅕ
|
||||
{0xffcb, 0x3156}, // ᅨ -> ㅖ
|
||||
{0xffcc, 0x3157}, // ᅩ -> ㅗ
|
||||
{0xffcd, 0x3158}, // ᅪ -> ㅘ
|
||||
{0xffce, 0x3159}, // ᅫ -> ㅙ
|
||||
{0xffcf, 0x315a}, // ᅬ -> ㅚ
|
||||
{0xffd2, 0x315b}, // ᅭ -> ㅛ
|
||||
{0xffd3, 0x315c}, // ᅮ -> ㅜ
|
||||
{0xffd4, 0x315d}, // ᅯ -> ㅝ
|
||||
{0xffd5, 0x315e}, // ᅰ -> ㅞ
|
||||
{0xffd6, 0x315f}, // ᅱ -> ㅟ
|
||||
{0xffd7, 0x3160}, // ᅲ -> ㅠ
|
||||
{0xffda, 0x3161}, // ᅳ -> ㅡ
|
||||
{0xffdb, 0x3162}, // ᅴ -> ㅢ
|
||||
{0xffdc, 0x3163}, // ᅵ -> ㅣ
|
||||
// Fullwidth symbol variants
|
||||
{0x00a2, 0xffe0}, // ¢ -> ¢
|
||||
{0x00a3, 0xffe1}, // £ -> £
|
||||
{0x00ac, 0xffe2}, // ¬ -> ¬
|
||||
{0x00af, 0xffe3}, // ¯ ->  ̄
|
||||
{0x00a6, 0xffe4}, // ¦ -> ¦
|
||||
{0x00a5, 0xffe5}, // ¥ -> ¥
|
||||
{0x20a9, 0xffe6}, // ₩ -> ₩
|
||||
// Halfwidth symbol variants
|
||||
{0xffe8, 0x2502}, // │ -> │
|
||||
{0xffe9, 0x2190}, // ← -> ←
|
||||
{0xffea, 0x2191}, // ↑ -> ↑
|
||||
{0xffeb, 0x2192}, // → -> →
|
||||
{0xffec, 0x2193}, // ↓ -> ↓
|
||||
{0xffed, 0x25a0}, // ■ -> ■
|
||||
{0xffee, 0x25cb} // ○ -> ○
|
||||
};
|
||||
|
||||
const std::size_t lastHalfWidthItem = \
|
||||
std::size_t((sizeof(halfWidth_fullWidth) / sizeof(halfWidth_fullWidth[0])) - 1);
|
||||
|
||||
} // namespace fc
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -20,6 +20,7 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fcheckbox.h"
|
||||
|
||||
namespace finalcut
|
||||
@ -53,14 +54,17 @@ FCheckBox::~FCheckBox() // destructor
|
||||
//----------------------------------------------------------------------
|
||||
void FCheckBox::init()
|
||||
{
|
||||
label_offset_pos = 4;
|
||||
button_width = 4;
|
||||
setLabelOffsetPos(4);
|
||||
setButtonWidth(4);
|
||||
setVisibleCursor();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FCheckBox::draw()
|
||||
{
|
||||
if ( ! isVisible() )
|
||||
return;
|
||||
|
||||
drawCheckButton();
|
||||
drawLabel();
|
||||
FToggleButton::draw();
|
||||
@ -69,9 +73,6 @@ void FCheckBox::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void FCheckBox::drawCheckButton()
|
||||
{
|
||||
if ( ! isVisible() )
|
||||
return;
|
||||
|
||||
print() << FPoint(1, 1);
|
||||
setColor();
|
||||
|
||||
@ -83,31 +84,39 @@ void FCheckBox::drawCheckButton()
|
||||
setReverse(true);
|
||||
}
|
||||
|
||||
if ( checked )
|
||||
{
|
||||
if ( isNewFont() )
|
||||
print (CHECKBOX_ON);
|
||||
else
|
||||
{
|
||||
print ('[');
|
||||
print (fc::Times); // Times ×
|
||||
print (']');
|
||||
}
|
||||
}
|
||||
if ( isChecked() )
|
||||
drawChecked();
|
||||
else
|
||||
{
|
||||
if ( isNewFont() )
|
||||
print (CHECKBOX);
|
||||
else
|
||||
{
|
||||
print ('[');
|
||||
print (' ');
|
||||
print (']');
|
||||
}
|
||||
}
|
||||
drawUnchecked();
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FCheckBox::drawChecked()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
print (CHECKBOX_ON);
|
||||
else
|
||||
{
|
||||
print ('[');
|
||||
print (fc::Times); // Times ×
|
||||
print (']');
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FCheckBox::drawUnchecked()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
print (CHECKBOX);
|
||||
else
|
||||
{
|
||||
print ('[');
|
||||
print (' ');
|
||||
print (']');
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2018 Markus Gans *
|
||||
* Copyright 2015-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -20,6 +20,7 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fcheckmenuitem.h"
|
||||
#include "final/fmenu.h"
|
||||
|
||||
@ -54,7 +55,7 @@ FCheckMenuItem::~FCheckMenuItem() // destructor
|
||||
//----------------------------------------------------------------------
|
||||
void FCheckMenuItem::init (FWidget* parent)
|
||||
{
|
||||
checkable = true;
|
||||
setCheckable();
|
||||
|
||||
if ( ! parent )
|
||||
return;
|
||||
@ -75,7 +76,11 @@ void FCheckMenuItem::processToggle()
|
||||
//----------------------------------------------------------------------
|
||||
void FCheckMenuItem::processClicked()
|
||||
{
|
||||
checked = ! checked;
|
||||
if ( isChecked() )
|
||||
unsetChecked();
|
||||
else
|
||||
setChecked();
|
||||
|
||||
processToggle();
|
||||
emitCallback("clicked");
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018 Markus Gans *
|
||||
* Copyright 2018-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -20,6 +20,7 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fcolorpalette.h"
|
||||
|
||||
namespace finalcut
|
||||
@ -78,22 +79,7 @@ void FColorPalette::set16ColorPalette (funcp setPalette)
|
||||
//----------------------------------------------------------------------
|
||||
void FColorPalette::reset8ColorPalette (funcp setPalette)
|
||||
{
|
||||
setPalette (fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::Blue, 0x00, 0x00, 0xaa);
|
||||
setPalette (fc::Green, 0x00, 0xaa, 0x00);
|
||||
setPalette (fc::Cyan, 0x00, 0x55, 0xaa);
|
||||
setPalette (fc::Red, 0xaa, 0x00, 0x00);
|
||||
setPalette (fc::Magenta, 0xaa, 0x00, 0xaa);
|
||||
setPalette (fc::Brown, 0xaa, 0xaa, 0x00);
|
||||
setPalette (fc::LightGray, 0xaa, 0xaa, 0xaa);
|
||||
setPalette (fc::DarkGray, 0x55, 0x55, 0x55);
|
||||
setPalette (fc::LightBlue, 0x55, 0x55, 0xff);
|
||||
setPalette (fc::LightGreen, 0x55, 0xff, 0x55);
|
||||
setPalette (fc::LightCyan, 0x55, 0xff, 0xff);
|
||||
setPalette (fc::LightRed, 0xff, 0x55, 0x55);
|
||||
setPalette (fc::LightMagenta, 0xff, 0x55, 0xff);
|
||||
setPalette (fc::Yellow, 0xff, 0xff, 0x55);
|
||||
setPalette (fc::White, 0xff, 0xff, 0xff);
|
||||
reset16ColorPalette(setPalette);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
174
src/fdialog.cpp
174
src/fdialog.cpp
@ -24,7 +24,11 @@
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fdialog.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/fmenuitem.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/ftooltip.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -56,8 +60,6 @@ FDialog::~FDialog() // destructor
|
||||
bool is_quit = fapp->isQuit();
|
||||
delete dialog_menu;
|
||||
dgl_menuitem = nullptr;
|
||||
delete accelerator_list;
|
||||
accelerator_list = nullptr;
|
||||
|
||||
if ( ! is_quit )
|
||||
switchToPrevWindow(this);
|
||||
@ -76,7 +78,7 @@ bool FDialog::setDialogWidget (bool enable)
|
||||
if ( isDialogWidget() == enable )
|
||||
return true;
|
||||
|
||||
flags.dialog_widget = enable;
|
||||
setFlags().dialog_widget = enable;
|
||||
|
||||
if ( enable )
|
||||
setTermOffsetWithPadding();
|
||||
@ -92,12 +94,12 @@ bool FDialog::setModal (bool enable)
|
||||
if ( isModal() == enable )
|
||||
return true;
|
||||
|
||||
flags.modal = enable;
|
||||
setFlags().modal = enable;
|
||||
|
||||
if ( enable )
|
||||
modal_dialogs++;
|
||||
setModalDialogCounter()++;
|
||||
else
|
||||
modal_dialogs--;
|
||||
setModalDialogCounter()--;
|
||||
|
||||
return enable;
|
||||
}
|
||||
@ -106,7 +108,7 @@ bool FDialog::setModal (bool enable)
|
||||
//----------------------------------------------------------------------
|
||||
bool FDialog::setScrollable (bool enable)
|
||||
{
|
||||
return (flags.scrollable = enable);
|
||||
return (setFlags().scrollable = enable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -163,7 +165,7 @@ int FDialog::exec()
|
||||
//----------------------------------------------------------------------
|
||||
void FDialog::setPos (const FPoint& pos, bool)
|
||||
{
|
||||
FRect old_geometry, restore;
|
||||
|
||||
setPos_error = false;
|
||||
|
||||
// Avoid to move widget completely outside the terminal
|
||||
@ -181,15 +183,19 @@ void FDialog::setPos (const FPoint& pos, bool)
|
||||
const auto& shadow = getShadow();
|
||||
std::size_t width = getWidth() + shadow.getWidth(); // width + right shadow
|
||||
std::size_t height = getHeight() + shadow.getHeight(); // height + bottom shadow
|
||||
old_geometry = getTermGeometryWithShadow();
|
||||
FRect old_geometry (getTermGeometryWithShadow());
|
||||
|
||||
// move to the new position
|
||||
FWindow::setPos(pos, false);
|
||||
putArea (getTermPos(), vwin);
|
||||
putArea (getTermPos(), getVWin());
|
||||
|
||||
// restoring the non-covered terminal areas
|
||||
if ( getTermGeometry().overlap(old_geometry) )
|
||||
{
|
||||
FRect restore{};
|
||||
std::size_t d_width = std::size_t(std::abs(dx));
|
||||
std::size_t d_height = std::size_t(std::abs(dy));
|
||||
|
||||
// dx > 0 : move left
|
||||
// dx = 0 : move vertical
|
||||
// dx < 0 : move right
|
||||
@ -197,9 +203,6 @@ void FDialog::setPos (const FPoint& pos, bool)
|
||||
// dy = 0 : move horizontal
|
||||
// dy < 0 : move down
|
||||
|
||||
std::size_t d_width = std::size_t(std::abs(dx));
|
||||
std::size_t d_height = std::size_t(std::abs(dy));
|
||||
|
||||
if ( dx > 0 )
|
||||
{
|
||||
if ( dy > 0 )
|
||||
@ -291,7 +294,7 @@ void FDialog::setSize (const FSize& size, bool adjust)
|
||||
|
||||
// get adjust width and height
|
||||
std::size_t w = getWidth() + shadow.getWidth();
|
||||
std::size_t h = getHeight()+ shadow.getHeight();
|
||||
std::size_t h = getHeight() + shadow.getHeight();
|
||||
|
||||
// dw > 0 : scale down width
|
||||
// dw = 0 : scale only height
|
||||
@ -514,7 +517,7 @@ void FDialog::onMouseUp (FMouseEvent* ev)
|
||||
&& titlebar_x < getTermX() + int(getWidth())
|
||||
&& titlebar_y == int(getTermY()) )
|
||||
{
|
||||
FPoint deltaPos = ms.termPos - titlebar_click_pos;
|
||||
FPoint deltaPos(ms.termPos - titlebar_click_pos);
|
||||
move (deltaPos);
|
||||
titlebar_click_pos = ms.termPos;
|
||||
}
|
||||
@ -558,7 +561,7 @@ void FDialog::onMouseMove (FMouseEvent* ev)
|
||||
|
||||
if ( ! titlebar_click_pos.isOrigin() )
|
||||
{
|
||||
FPoint deltaPos = ms.termPos - titlebar_click_pos;
|
||||
FPoint deltaPos(ms.termPos - titlebar_click_pos);
|
||||
move (deltaPos);
|
||||
titlebar_click_pos = ms.termPos;
|
||||
}
|
||||
@ -582,15 +585,14 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
|
||||
getZoomButtonWidth(),
|
||||
false // mouse_over_menu
|
||||
};
|
||||
int x, y;
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
return;
|
||||
|
||||
x = getTermX();
|
||||
y = getTermY();
|
||||
int x = getTermX();
|
||||
int y = getTermY();
|
||||
FRect title_button(x, y, 3, 1);
|
||||
FPoint tPos = ms.termPos;
|
||||
FPoint tPos(ms.termPos);
|
||||
|
||||
if ( title_button.contains(tPos) )
|
||||
{
|
||||
@ -604,7 +606,7 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
|
||||
if ( window_focus_widget )
|
||||
window_focus_widget->setFocus();
|
||||
|
||||
setClickedWidget(0);
|
||||
setClickedWidget(nullptr);
|
||||
|
||||
if ( isModal() )
|
||||
done (FDialog::Reject);
|
||||
@ -679,15 +681,15 @@ void FDialog::onWindowInactive (FEvent*)
|
||||
//----------------------------------------------------------------------
|
||||
void FDialog::onWindowRaised (FEvent*)
|
||||
{
|
||||
if ( ! (isShown() && isShown()) )
|
||||
if ( ! isShown() )
|
||||
return;
|
||||
|
||||
putArea (getTermPos(), vwin);
|
||||
putArea (getTermPos(), getVWin());
|
||||
|
||||
// Handle always-on-top windows
|
||||
if ( always_on_top_list && ! always_on_top_list->empty() )
|
||||
if ( getAlwaysOnTopList() && ! getAlwaysOnTopList()->empty() )
|
||||
{
|
||||
for (auto&& win : *always_on_top_list)
|
||||
for (auto&& win : *getAlwaysOnTopList())
|
||||
putArea (win->getTermPos(), win->getVWin());
|
||||
}
|
||||
}
|
||||
@ -695,13 +697,13 @@ void FDialog::onWindowRaised (FEvent*)
|
||||
//----------------------------------------------------------------------
|
||||
void FDialog::onWindowLowered (FEvent*)
|
||||
{
|
||||
if ( ! window_list )
|
||||
if ( ! getWindowList() )
|
||||
return;
|
||||
|
||||
if ( window_list->empty() )
|
||||
if ( getWindowList()->empty() )
|
||||
return;
|
||||
|
||||
for (auto&& win : *window_list)
|
||||
for (auto&& win : *getWindowList())
|
||||
putArea (win->getTermPos(), win->getVWin());
|
||||
}
|
||||
|
||||
@ -734,7 +736,7 @@ void FDialog::draw()
|
||||
drawTitleBar();
|
||||
setCursorPos(FPoint(2, int(getHeight()) - 1));
|
||||
|
||||
if ( flags.shadow )
|
||||
if ( getFlags().shadow )
|
||||
drawDialogShadow();
|
||||
|
||||
if ( isMonochron() )
|
||||
@ -744,7 +746,7 @@ void FDialog::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void FDialog::drawDialogShadow()
|
||||
{
|
||||
if ( isMonochron() && ! flags.trans_shadow )
|
||||
if ( isMonochron() && ! getFlags().trans_shadow )
|
||||
return;
|
||||
|
||||
drawShadow();
|
||||
@ -782,6 +784,7 @@ void FDialog::init()
|
||||
addDialog(this);
|
||||
setActiveWindow(this);
|
||||
setTransparentShadow();
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
auto old_focus = FWidget::getFocusWidget();
|
||||
@ -792,15 +795,8 @@ void FDialog::init()
|
||||
old_focus->redraw();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
accelerator_list = new Accelerators();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
// Create your own accelerator list for this dialog
|
||||
createWidgetAcceleratorList();
|
||||
|
||||
// Add the dialog menu
|
||||
initDialogMenu();
|
||||
@ -821,9 +817,9 @@ void FDialog::initDialogMenu()
|
||||
return;
|
||||
}
|
||||
|
||||
FPoint p = getPos();
|
||||
FPoint p(getPos());
|
||||
p.y_ref()++;
|
||||
dialog_menu->setPos (p);
|
||||
dialog_menu->setPos(p);
|
||||
dgl_menuitem = dialog_menu->getItem();
|
||||
dgl_menuitem->ignorePadding();
|
||||
dgl_menuitem->unsetFocusable();
|
||||
@ -909,39 +905,41 @@ void FDialog::initCloseMenuItem (FMenu* menu)
|
||||
//----------------------------------------------------------------------
|
||||
void FDialog::drawBorder()
|
||||
{
|
||||
int x1 = 1
|
||||
, x2 = 1 + int(getWidth()) - 1
|
||||
, y1 = 2
|
||||
, y2 = 1 + int(getHeight()) - 1;
|
||||
|
||||
if ( (getMoveSizeWidget() == this || ! resize_click_pos.isOrigin() )
|
||||
&& ! isZoomed() )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.dialog_resize_fg, getBackgroundColor());
|
||||
}
|
||||
else
|
||||
setColor();
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( isNewFont() ) // Draw a newfont U-shaped frame
|
||||
{
|
||||
for (int y = y1; y < y2; y++)
|
||||
FRect r(FPoint(1, 1), getSize());
|
||||
|
||||
for (int y = r.getY1() + 1; y < r.getY2(); y++)
|
||||
{
|
||||
print() << FPoint(x1, y) // Border left ⎸
|
||||
<< fc::NF_border_line_left;
|
||||
print() << FPoint(x2, y) // Border right⎹
|
||||
<< fc::NF_rev_border_line_right;
|
||||
print() << FPoint(r.getX1(), y)
|
||||
<< fc::NF_border_line_left // border left ⎸
|
||||
<< FPoint(r.getX2(), y)
|
||||
<< fc::NF_rev_border_line_right; // border right⎹
|
||||
}
|
||||
|
||||
print() << FPoint(x1, y2) // Lower left corner border ⎣
|
||||
print() << r.getLowerLeftPos() // lower left corner border ⎣
|
||||
<< fc::NF_border_corner_lower_left;
|
||||
|
||||
for (std::size_t x = 1; x < getWidth() - 1; x++) // low line _
|
||||
print (fc::NF_border_line_bottom);
|
||||
for (int x = r.getX1() + 1; x < r.getX2(); x++)
|
||||
print (fc::NF_border_line_bottom); // low line _
|
||||
|
||||
print() << FPoint(x2, y2) // Lower right corner border ⎦
|
||||
<< fc::NF_rev_border_corner_lower_right;
|
||||
// lower right corner border ⎦
|
||||
print (fc::NF_rev_border_corner_lower_right);
|
||||
}
|
||||
else
|
||||
{
|
||||
FWidget::drawBorder(x1, y1, x2, y2);
|
||||
FRect box(FPoint(1, 2), getSize());
|
||||
box.scaleBy(0, -1);
|
||||
finalcut::drawBorder(this, box);
|
||||
}
|
||||
}
|
||||
|
||||
@ -973,6 +971,7 @@ void FDialog::drawBarButton()
|
||||
{
|
||||
// Print the title button
|
||||
print() << FPoint(1, 1);
|
||||
const auto& wc = getFWidgetColors();
|
||||
|
||||
if ( dialog_menu && dialog_menu->isShown() )
|
||||
setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg);
|
||||
@ -1025,6 +1024,8 @@ void FDialog::drawZoomButton()
|
||||
if ( ! isResizeable() )
|
||||
return;
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
|
||||
if ( zoom_button_pressed )
|
||||
setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg);
|
||||
else
|
||||
@ -1090,8 +1091,9 @@ inline void FDialog::drawZoomedButton()
|
||||
void FDialog::drawTextBar()
|
||||
{
|
||||
// Fill with spaces (left of the title)
|
||||
std::size_t center_offset = 0;
|
||||
std::size_t x = 1;
|
||||
std::size_t center_offset{0};
|
||||
std::size_t x{1};
|
||||
const auto& wc = getFWidgetColors();
|
||||
|
||||
if ( getMaxColor() < 16 )
|
||||
setBold();
|
||||
@ -1101,9 +1103,9 @@ void FDialog::drawTextBar()
|
||||
else
|
||||
setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg);
|
||||
|
||||
std::size_t width = getWidth();
|
||||
std::size_t zoom_btn = getZoomButtonWidth();
|
||||
std::size_t length = tb_text.getLength();
|
||||
auto width = getWidth();
|
||||
auto zoom_btn = getZoomButtonWidth();
|
||||
auto length = getColumnWidth(tb_text);
|
||||
|
||||
if ( width > length + MENU_BTN + zoom_btn )
|
||||
center_offset = (width - length - MENU_BTN - zoom_btn) / 2;
|
||||
@ -1137,17 +1139,17 @@ void FDialog::restoreOverlaidWindows()
|
||||
{
|
||||
// Restoring overlaid windows
|
||||
|
||||
if ( ! window_list || window_list->empty() )
|
||||
if ( ! getWindowList() || getWindowList()->empty() )
|
||||
return;
|
||||
|
||||
bool overlaid = false;
|
||||
bool overlaid{false};
|
||||
|
||||
for (auto&& win : *window_list)
|
||||
for (auto&& win : *getWindowList())
|
||||
{
|
||||
if ( overlaid )
|
||||
putArea (win->getTermPos(), win->getVWin());
|
||||
|
||||
if ( vwin == win->getVWin() )
|
||||
if ( getVWin() == win->getVWin() )
|
||||
overlaid = true;
|
||||
}
|
||||
}
|
||||
@ -1163,9 +1165,9 @@ void FDialog::setCursorToFocusWidget()
|
||||
&& focus->isShown()
|
||||
&& focus->hasVisibleCursor() )
|
||||
{
|
||||
FPoint cursor_pos = focus->getCursorPos();
|
||||
FPoint cursor_pos(focus->getCursorPos());
|
||||
focus->setCursorPos(cursor_pos);
|
||||
updateVTermCursor(vwin);
|
||||
updateVTermCursor(getVWin());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1204,7 +1206,7 @@ void FDialog::openMenu()
|
||||
else
|
||||
{
|
||||
setOpenMenu(dialog_menu);
|
||||
FPoint pos = getPos();
|
||||
FPoint pos(getPos());
|
||||
pos.y_ref()++;
|
||||
dialog_menu->setPos (pos);
|
||||
dialog_menu->setVisible();
|
||||
@ -1480,11 +1482,11 @@ void FDialog::resizeMouseDown (const mouseStates& ms)
|
||||
if ( isResizeable() && isLowerRightResizeCorner(ms) )
|
||||
{
|
||||
resize_click_pos = ms.termPos;
|
||||
FPoint lower_right_pos = getTermGeometry().getLowerRightPos();
|
||||
FPoint lower_right_pos(getTermGeometry().getLowerRightPos());
|
||||
|
||||
if ( ms.termPos != lower_right_pos )
|
||||
{
|
||||
FPoint deltaPos = ms.termPos - lower_right_pos;
|
||||
FPoint deltaPos(ms.termPos - lower_right_pos);
|
||||
int w = lower_right_pos.getX() + deltaPos.getX() - getTermX() + 1;
|
||||
int h = lower_right_pos.getY() + deltaPos.getY() - getTermY() + 1;
|
||||
const FSize& size = FSize(std::size_t(w), std::size_t(h));
|
||||
@ -1507,8 +1509,8 @@ void FDialog::resizeMouseUpMove (const mouseStates& ms, bool mouse_up)
|
||||
resize_click_pos = ms.termPos;
|
||||
int x2 = resize_click_pos.getX()
|
||||
, y2 = resize_click_pos.getY()
|
||||
, x2_offset = 0
|
||||
, y2_offset = 0;
|
||||
, x2_offset{0}
|
||||
, y2_offset{0};
|
||||
|
||||
if ( r )
|
||||
{
|
||||
@ -1518,8 +1520,8 @@ void FDialog::resizeMouseUpMove (const mouseStates& ms, bool mouse_up)
|
||||
|
||||
if ( ms.termPos != getTermGeometry().getLowerRightPos() )
|
||||
{
|
||||
int w, h;
|
||||
FPoint deltaPos = ms.termPos - resize_click_pos;
|
||||
int w{}, h{};
|
||||
FPoint deltaPos(ms.termPos - resize_click_pos);
|
||||
|
||||
if ( x2 - x2_offset <= int(getMaxWidth()) )
|
||||
w = resize_click_pos.getX() + deltaPos.getX() - getTermX() + 1;
|
||||
@ -1564,7 +1566,7 @@ void FDialog::cancelMouseResize()
|
||||
//----------------------------------------------------------------------
|
||||
inline void FDialog::acceptMoveSize()
|
||||
{
|
||||
setMoveSizeWidget(0);
|
||||
setMoveSizeWidget(nullptr);
|
||||
|
||||
if ( tooltip )
|
||||
delete tooltip;
|
||||
@ -1576,7 +1578,7 @@ inline void FDialog::acceptMoveSize()
|
||||
//----------------------------------------------------------------------
|
||||
inline void FDialog::cancelMoveSize()
|
||||
{
|
||||
setMoveSizeWidget(0);
|
||||
setMoveSizeWidget(nullptr);
|
||||
|
||||
if ( tooltip )
|
||||
delete tooltip;
|
||||
@ -1594,24 +1596,24 @@ inline void FDialog::cancelMoveSize()
|
||||
void FDialog::addDialog (FWidget* obj)
|
||||
{
|
||||
// Add the dialog object obj to the dialog list
|
||||
if ( dialog_list )
|
||||
dialog_list->push_back(obj);
|
||||
if ( getDialogList() )
|
||||
getDialogList()->push_back(obj);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FDialog::delDialog (FWidget* obj)
|
||||
{
|
||||
// Delete the dialog object obj from the dialog list
|
||||
if ( ! dialog_list || dialog_list->empty() )
|
||||
if ( ! getDialogList() || getDialogList()->empty() )
|
||||
return;
|
||||
|
||||
auto iter = dialog_list->begin();
|
||||
auto iter = getDialogList()->begin();
|
||||
|
||||
while ( iter != dialog_list->end() )
|
||||
while ( iter != getDialogList()->end() )
|
||||
{
|
||||
if ( (*iter) == obj )
|
||||
{
|
||||
dialog_list->erase(iter);
|
||||
getDialogList()->erase(iter);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1675,7 +1677,7 @@ void FDialog::cb_zoom (FWidget*, FDataPtr)
|
||||
{
|
||||
dialog_menu->unselectItem();
|
||||
dialog_menu->hide();
|
||||
setClickedWidget(0);
|
||||
setClickedWidget(nullptr);
|
||||
drawTitleBar();
|
||||
zoomWindow();
|
||||
setZoomItem();
|
||||
@ -1686,7 +1688,7 @@ void FDialog::cb_close (FWidget*, FDataPtr)
|
||||
{
|
||||
dialog_menu->unselectItem();
|
||||
dialog_menu->hide();
|
||||
setClickedWidget(0);
|
||||
setClickedWidget(nullptr);
|
||||
drawTitleBar();
|
||||
close();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2016-2018 Markus Gans *
|
||||
* Copyright 2016-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -20,6 +20,7 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fdialoglistmenu.h"
|
||||
|
||||
namespace finalcut
|
||||
@ -53,8 +54,8 @@ FDialogListMenu::~FDialogListMenu()
|
||||
//----------------------------------------------------------------------
|
||||
void FDialogListMenu::init()
|
||||
{
|
||||
auto menuitem = getItem();
|
||||
menuitem->dialog_index = true;
|
||||
auto m_item = getItem();
|
||||
m_item->dialog_index = true;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -21,12 +21,15 @@
|
||||
***********************************************************************/
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
#undef __STRICT_ANSI__ // need for realpath and strdup
|
||||
#undef __STRICT_ANSI__ // need for strdup
|
||||
#include <strings.h> // need for strcasecmp
|
||||
#endif
|
||||
|
||||
#include <pwd.h>
|
||||
#include <vector>
|
||||
|
||||
#include "final/fevent.h"
|
||||
#include "final/fsystem.h"
|
||||
#include "final/ffiledialog.h"
|
||||
|
||||
namespace finalcut
|
||||
@ -58,20 +61,20 @@ const FString fileChooser ( FWidget* parent
|
||||
, const FString& filter
|
||||
, FFileDialog::DialogType type )
|
||||
{
|
||||
FString ret;
|
||||
FString path = dirname;
|
||||
FString file_filter = filter;
|
||||
FString ret{};
|
||||
FString path(dirname);
|
||||
FString file_filter(filter);
|
||||
|
||||
if ( path.isNull() || path.isEmpty() )
|
||||
{
|
||||
path = FFileDialog::getHomeDir();
|
||||
path.setString(FFileDialog::getHomeDir());
|
||||
|
||||
if ( path.isNull() || path.isEmpty() )
|
||||
path = FString("/");
|
||||
path.setString("/");
|
||||
}
|
||||
|
||||
if ( file_filter.isNull() || file_filter.isEmpty() )
|
||||
file_filter = FString("*");
|
||||
file_filter.setString("*");
|
||||
|
||||
FFileDialog fileopen ( path
|
||||
, file_filter
|
||||
@ -86,6 +89,8 @@ const FString fileChooser ( FWidget* parent
|
||||
return ret;
|
||||
}
|
||||
|
||||
// static class attributes
|
||||
FSystem* FFileDialog::fsystem{nullptr};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FFileDialog
|
||||
@ -174,9 +179,9 @@ const FString FFileDialog::getSelectedFile() const
|
||||
void FFileDialog::setPath (const FString& dir)
|
||||
{
|
||||
const char* const dirname = dir.c_str();
|
||||
char resolved_path[MAXPATHLEN];
|
||||
FString r_dir;
|
||||
struct stat sb;
|
||||
char resolved_path[MAXPATHLEN]{};
|
||||
FString r_dir{};
|
||||
struct stat sb{};
|
||||
|
||||
if ( stat(dirname, &sb) != 0 )
|
||||
{
|
||||
@ -199,10 +204,10 @@ void FFileDialog::setPath (const FString& dir)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( realpath(dir.c_str(), resolved_path) != 0 )
|
||||
r_dir = resolved_path;
|
||||
if ( fsystem->realpath(dir.c_str(), resolved_path) != 0 )
|
||||
r_dir.setString(resolved_path);
|
||||
else
|
||||
r_dir = dir;
|
||||
r_dir.setString(dir);
|
||||
|
||||
if ( r_dir[r_dir.getLength() - 1] != '/' )
|
||||
directory = r_dir + "/";
|
||||
@ -275,10 +280,7 @@ const FString FFileDialog::fileSaveChooser ( FWidget* parent
|
||||
//----------------------------------------------------------------------
|
||||
void FFileDialog::adjustSize()
|
||||
{
|
||||
int X, Y;
|
||||
std::size_t max_width;
|
||||
std::size_t max_height;
|
||||
std::size_t h;
|
||||
std::size_t max_width{}, max_height{};
|
||||
auto root_widget = getRootWidget();
|
||||
|
||||
if ( root_widget )
|
||||
@ -293,7 +295,7 @@ void FFileDialog::adjustSize()
|
||||
max_height = 24;
|
||||
}
|
||||
|
||||
h = max_height - 6;
|
||||
std::size_t h = max_height - 6;
|
||||
|
||||
if ( h < 15 ) // minimum
|
||||
h = 15;
|
||||
@ -302,13 +304,13 @@ void FFileDialog::adjustSize()
|
||||
h = 30;
|
||||
|
||||
setHeight (h, false);
|
||||
X = 1 + int((max_width - getWidth()) / 2);
|
||||
Y = 1 + int((max_height - getHeight()) / 3);
|
||||
int X = 1 + int((max_width - getWidth()) / 2);
|
||||
int Y = 1 + int((max_height - getHeight()) / 3);
|
||||
setPos(FPoint(X, Y), false);
|
||||
filebrowser.setHeight (h - 8, false);
|
||||
hidden.setY (int(h) - 4, false);
|
||||
cancel.setY (int(h) - 4, false);
|
||||
open.setY (int(h) - 4, false);
|
||||
hidden_check.setY (int(h) - 4, false);
|
||||
cancel_btn.setY (int(h) - 4, false);
|
||||
open_btn.setY (int(h) - 4, false);
|
||||
FDialog::adjustSize();
|
||||
printPath(directory);
|
||||
}
|
||||
@ -320,7 +322,10 @@ void FFileDialog::init()
|
||||
{
|
||||
static constexpr std::size_t w = 42;
|
||||
static constexpr std::size_t h = 15;
|
||||
int x, y;
|
||||
int x{}, y{};
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
setGeometry(FPoint(1, 1), FSize(w, h), false);
|
||||
auto parent_widget = getParentWidget();
|
||||
@ -355,18 +360,18 @@ inline void FFileDialog::widgetSettings (const FPoint& pos)
|
||||
filebrowser.setGeometry (FPoint(2, 3), FSize(38, 6));
|
||||
printPath (directory);
|
||||
|
||||
hidden.setText ("&hidden files");
|
||||
hidden.setGeometry (FPoint(2, 10), FSize(16, 1));
|
||||
hidden_check.setText ("&hidden files");
|
||||
hidden_check.setGeometry (FPoint(2, 10), FSize(16, 1));
|
||||
|
||||
cancel.setText ("&Cancel");
|
||||
cancel.setGeometry(FPoint(19, 10), FSize(9, 1));
|
||||
cancel_btn.setText ("&Cancel");
|
||||
cancel_btn.setGeometry(FPoint(19, 10), FSize(9, 1));
|
||||
|
||||
if ( dlg_type == FFileDialog::Save )
|
||||
open.setText ("&Save");
|
||||
open_btn.setText ("&Save");
|
||||
else
|
||||
open.setText ("&Open");
|
||||
open_btn.setText ("&Open");
|
||||
|
||||
open.setGeometry(FPoint(30, 10), FSize(9, 1));
|
||||
open_btn.setGeometry(FPoint(30, 10), FSize(9, 1));
|
||||
setGeometry (pos, getSize());
|
||||
}
|
||||
|
||||
@ -391,19 +396,19 @@ void FFileDialog::initCallbacks()
|
||||
F_METHOD_CALLBACK (this, &FFileDialog::cb_processClicked)
|
||||
);
|
||||
|
||||
hidden.addCallback
|
||||
hidden_check.addCallback
|
||||
(
|
||||
"toggled",
|
||||
F_METHOD_CALLBACK (this, &FFileDialog::cb_processShowHidden)
|
||||
);
|
||||
|
||||
cancel.addCallback
|
||||
cancel_btn.addCallback
|
||||
(
|
||||
"clicked",
|
||||
F_METHOD_CALLBACK (this, &FFileDialog::cb_processCancel)
|
||||
);
|
||||
|
||||
open.addCallback
|
||||
open_btn.addCallback
|
||||
(
|
||||
"clicked",
|
||||
F_METHOD_CALLBACK (this, &FFileDialog::cb_processOpen)
|
||||
@ -414,7 +419,7 @@ void FFileDialog::initCallbacks()
|
||||
inline bool FFileDialog::pattern_match ( const char* const pattern
|
||||
, char fname[] )
|
||||
{
|
||||
char search[128] = { };
|
||||
char search[128]{};
|
||||
|
||||
if ( show_hidden && fname[0] == '.' && fname[1] != '\0' ) // hidden files
|
||||
{
|
||||
@ -444,34 +449,37 @@ void FFileDialog::clear()
|
||||
std::free (entry.name);
|
||||
|
||||
dir_entries.clear();
|
||||
dir_entries.shrink_to_fit();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FFileDialog::numOfDirs()
|
||||
long FFileDialog::numOfDirs()
|
||||
{
|
||||
if ( dir_entries.empty() )
|
||||
return 0;
|
||||
|
||||
int n = 0;
|
||||
|
||||
for (auto&& entry : dir_entries)
|
||||
if ( entry.directory && std::strcmp(entry.name, ".") != 0 )
|
||||
n++;
|
||||
|
||||
long n = std::count_if ( std::begin(dir_entries)
|
||||
, std::end(dir_entries)
|
||||
, [] (dir_entry& entry)
|
||||
{
|
||||
return entry.directory
|
||||
&& std::strcmp(entry.name, ".") != 0;
|
||||
}
|
||||
);
|
||||
return n;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FFileDialog::sortDir()
|
||||
{
|
||||
int start, dir_num;
|
||||
long start{};
|
||||
|
||||
if ( std::strcmp((*dir_entries.begin()).name, "..") == 0 )
|
||||
start = 1;
|
||||
else
|
||||
start = 0;
|
||||
|
||||
dir_num = numOfDirs();
|
||||
long dir_num = numOfDirs();
|
||||
// directories first
|
||||
std::sort ( dir_entries.begin() + start
|
||||
, dir_entries.end()
|
||||
@ -554,7 +562,7 @@ int FFileDialog::readDir()
|
||||
void FFileDialog::getEntry (const char* const dir, struct dirent* d_entry)
|
||||
{
|
||||
const char* const filter = filter_pattern.c_str();
|
||||
dir_entry entry;
|
||||
dir_entry entry{};
|
||||
|
||||
entry.name = strdup(d_entry->d_name);
|
||||
|
||||
@ -567,7 +575,7 @@ void FFileDialog::getEntry (const char* const dir, struct dirent* d_entry)
|
||||
entry.symbolic_link = (d_entry->d_type & DT_LNK ) == DT_LNK;
|
||||
entry.socket = (d_entry->d_type & DT_SOCK) == DT_SOCK;
|
||||
#else
|
||||
struct stat s;
|
||||
struct stat s{};
|
||||
stat (entry.name, &s);
|
||||
entry.fifo = S_ISFIFO (s.st_mode);
|
||||
entry.character_device = S_ISCHR (s.st_mode);
|
||||
@ -594,9 +602,12 @@ void FFileDialog::followSymLink (const char* const dir, dir_entry& entry)
|
||||
if ( ! entry.symbolic_link )
|
||||
return; // No symbolic link
|
||||
|
||||
char resolved_path[MAXPATHLEN] = { };
|
||||
char symLink[MAXPATHLEN] = { };
|
||||
struct stat sb;
|
||||
char resolved_path[MAXPATHLEN]{};
|
||||
char symLink[MAXPATHLEN]{};
|
||||
struct stat sb{};
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
std::strncpy (symLink, dir, sizeof(symLink));
|
||||
symLink[sizeof(symLink) - 1] = '\0';
|
||||
@ -605,7 +616,7 @@ void FFileDialog::followSymLink (const char* const dir, dir_entry& entry)
|
||||
, sizeof(symLink) - std::strlen(symLink) - 1);
|
||||
symLink[sizeof(symLink) - 1] = '\0';
|
||||
|
||||
if ( realpath(symLink, resolved_path) == 0 )
|
||||
if ( fsystem->realpath(symLink, resolved_path) == 0 )
|
||||
return; // Cannot follow the symlink
|
||||
|
||||
if ( lstat(resolved_path, &sb) == -1 )
|
||||
@ -640,7 +651,7 @@ void FFileDialog::selectDirectoryEntry (const char* const name)
|
||||
if ( dir_entries.empty() )
|
||||
return;
|
||||
|
||||
std::size_t i = 1;
|
||||
std::size_t i{1};
|
||||
|
||||
for (auto&& entry : dir_entries)
|
||||
{
|
||||
@ -658,8 +669,11 @@ void FFileDialog::selectDirectoryEntry (const char* const name)
|
||||
//----------------------------------------------------------------------
|
||||
int FFileDialog::changeDir (const FString& dirname)
|
||||
{
|
||||
FString lastdir = directory;
|
||||
FString newdir = dirname;
|
||||
FString lastdir(directory);
|
||||
FString newdir(dirname);
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( newdir.includes('~') )
|
||||
newdir = newdir.replace('~', getHomeDir());
|
||||
@ -687,13 +701,13 @@ int FFileDialog::changeDir (const FString& dirname)
|
||||
filename.setText('/');
|
||||
else
|
||||
{
|
||||
auto baseName = basename(C_STR(lastdir.c_str()));
|
||||
auto baseName = basename(lastdir.c_str());
|
||||
selectDirectoryEntry (baseName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FString firstname = dir_entries[0].name;
|
||||
FString firstname(dir_entries[0].name);
|
||||
|
||||
if ( dir_entries[0].directory )
|
||||
filename.setText(firstname + '/');
|
||||
@ -714,10 +728,16 @@ int FFileDialog::changeDir (const FString& dirname)
|
||||
void FFileDialog::printPath (const FString& txt)
|
||||
{
|
||||
const auto& path = txt;
|
||||
const uInt max_width = uInt(filebrowser.getWidth()) - 4;
|
||||
const std::size_t max_width = filebrowser.getWidth() - 4;
|
||||
std::size_t column_width = getColumnWidth(path);
|
||||
|
||||
if ( path.getLength() > max_width )
|
||||
filebrowser.setText(".." + path.right(max_width - 2));
|
||||
if ( column_width > max_width )
|
||||
{
|
||||
const std::size_t width = max_width - 2;
|
||||
std::size_t first = column_width + 1 - width;
|
||||
FString sub_str(getColumnSubString (path, first, width));
|
||||
filebrowser.setText(".." + sub_str);
|
||||
}
|
||||
else
|
||||
filebrowser.setText(path);
|
||||
}
|
||||
@ -725,11 +745,16 @@ void FFileDialog::printPath (const FString& txt)
|
||||
//----------------------------------------------------------------------
|
||||
const FString FFileDialog::getHomeDir()
|
||||
{
|
||||
struct passwd pwd;
|
||||
struct passwd* pwd_ptr;
|
||||
char buf[1024];
|
||||
struct passwd pwd{};
|
||||
struct passwd* pwd_ptr{};
|
||||
char buf[1024]{};
|
||||
|
||||
if ( getpwuid_r (geteuid(), &pwd, buf, sizeof(buf), &pwd_ptr) )
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
uid_t euid = fsystem->geteuid();
|
||||
|
||||
if ( fsystem->getpwuid_r(euid, &pwd, buf, sizeof(buf), &pwd_ptr) )
|
||||
return FString("");
|
||||
else
|
||||
return FString(pwd.pw_dir);
|
||||
@ -759,26 +784,27 @@ void FFileDialog::cb_processActivate (FWidget*, FDataPtr)
|
||||
}
|
||||
else
|
||||
{
|
||||
bool found = false;
|
||||
bool found{false};
|
||||
const auto& input = filename.getText().trim();
|
||||
|
||||
if ( ! dir_entries.empty() )
|
||||
{
|
||||
const auto& input = filename.getText().trim();
|
||||
|
||||
for (auto&& entry : dir_entries)
|
||||
{
|
||||
if ( entry.name && input && ! input.isNull()
|
||||
&& std::strcmp(entry.name, input) == 0
|
||||
&& entry.directory )
|
||||
{
|
||||
found = true;
|
||||
changeDir(input);
|
||||
break;
|
||||
}
|
||||
}
|
||||
found = std::any_of ( std::begin(dir_entries)
|
||||
, std::end(dir_entries)
|
||||
, [&input] (dir_entry& entry)
|
||||
{
|
||||
return entry.name
|
||||
&& input
|
||||
&& ! input.isNull()
|
||||
&& std::strcmp(entry.name, input) == 0
|
||||
&& entry.directory;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! found )
|
||||
if ( found )
|
||||
changeDir(input);
|
||||
else
|
||||
done (FDialog::Accept);
|
||||
}
|
||||
}
|
||||
@ -794,9 +820,9 @@ void FFileDialog::cb_processRowChanged (FWidget*, FDataPtr)
|
||||
const auto& name = FString(dir_entries[n - 1].name);
|
||||
|
||||
if ( dir_entries[n - 1].directory )
|
||||
filename.setText( name + '/' );
|
||||
filename.setText(name + '/');
|
||||
else
|
||||
filename.setText( name );
|
||||
filename.setText(name);
|
||||
|
||||
filename.redraw();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018 Markus Gans *
|
||||
* Copyright 2018-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -20,8 +20,9 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <final/fc.h>
|
||||
#include <final/fkey_map.h>
|
||||
#include "final/fc.h"
|
||||
#include "final/fkey_map.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018 Markus Gans *
|
||||
* Copyright 2018-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -30,17 +30,23 @@
|
||||
|
||||
#include "final/fkeyboard.h"
|
||||
#include "final/fkey_map.h"
|
||||
#include "final/fobject.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermios.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
#include "final/ftermlinux.h"
|
||||
#endif
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
uInt64 FKeyboard::key_timeout = 100000; // 100 ms (default timeout for keypress)
|
||||
uInt64 FKeyboard::key_timeout{100000}; // 100 ms (default timeout for keypress)
|
||||
struct timeval FKeyboard::time_keypressed{};
|
||||
|
||||
#if defined(__linux__)
|
||||
FTermLinux* FKeyboard::linux = nullptr;
|
||||
FTermLinux* FKeyboard::linux{nullptr};
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -96,7 +102,7 @@ void FKeyboard::fetchKeyCode()
|
||||
//----------------------------------------------------------------------
|
||||
const FString FKeyboard::getKeyName (FKey keynum)
|
||||
{
|
||||
for (std::size_t i = 0; fc::FkeyName[i].string[0] != 0; i++)
|
||||
for (std::size_t i{0}; fc::FkeyName[i].string[0] != 0; i++)
|
||||
if ( fc::FkeyName[i].num && fc::FkeyName[i].num == keynum )
|
||||
return FString(fc::FkeyName[i].string);
|
||||
|
||||
@ -112,6 +118,14 @@ void FKeyboard::setTermcapMap (fc::fkeymap* keymap)
|
||||
key_map = keymap;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FKeyboard::init()
|
||||
{
|
||||
#if defined(__linux__)
|
||||
linux = FTerm::getFTermLinux();
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool& FKeyboard::unprocessedInput()
|
||||
{
|
||||
@ -121,16 +135,15 @@ bool& FKeyboard::unprocessedInput()
|
||||
//----------------------------------------------------------------------
|
||||
bool FKeyboard::isKeyPressed()
|
||||
{
|
||||
int result;
|
||||
fd_set ifds;
|
||||
struct timeval tv;
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
int stdin_no = FTermios::getStdIn();
|
||||
|
||||
FD_ZERO(&ifds);
|
||||
FD_SET(stdin_no, &ifds);
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 100000; // 100 ms
|
||||
result = select (stdin_no + 1, &ifds, 0, 0, &tv);
|
||||
int result = select (stdin_no + 1, &ifds, 0, 0, &tv);
|
||||
|
||||
if ( result > 0 && FD_ISSET(stdin_no, &ifds) )
|
||||
FD_CLR (stdin_no, &ifds);
|
||||
@ -221,14 +234,14 @@ inline FKey FKeyboard::getTermcapKey()
|
||||
if ( ! key_map )
|
||||
return NOT_SET;
|
||||
|
||||
for (std::size_t i = 0; key_map[i].tname[0] != 0; i++)
|
||||
for (std::size_t i{0}; key_map[i].tname[0] != 0; i++)
|
||||
{
|
||||
char* k = key_map[i].string;
|
||||
std::size_t len = ( k ) ? std::strlen(k) : 0;
|
||||
|
||||
if ( k && std::strncmp(k, fifo_buf, len) == 0 ) // found
|
||||
{
|
||||
std::size_t n;
|
||||
std::size_t n{};
|
||||
|
||||
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove founded entry
|
||||
fifo_buf[n - len] = fifo_buf[n];
|
||||
@ -251,14 +264,14 @@ inline FKey FKeyboard::getMetaKey()
|
||||
|
||||
assert ( FIFO_BUF_SIZE > 0 );
|
||||
|
||||
for (std::size_t i = 0; fc::Fmetakey[i].string[0] != 0; i++)
|
||||
for (std::size_t i{0}; fc::Fmetakey[i].string[0] != 0; i++)
|
||||
{
|
||||
char* kmeta = fc::Fmetakey[i].string; // The string is never null
|
||||
std::size_t len = std::strlen(kmeta);
|
||||
|
||||
if ( std::strncmp(kmeta, fifo_buf, len) == 0 ) // found
|
||||
{
|
||||
std::size_t n;
|
||||
std::size_t n{};
|
||||
|
||||
if ( len == 2 && ( fifo_buf[1] == 'O'
|
||||
|| fifo_buf[1] == '['
|
||||
@ -287,15 +300,15 @@ inline FKey FKeyboard::getSingleKey()
|
||||
{
|
||||
// Looking for single key code in the buffer
|
||||
|
||||
std::size_t n{};
|
||||
std::size_t len{1};
|
||||
uChar firstchar = uChar(fifo_buf[0]);
|
||||
std::size_t n;
|
||||
std::size_t len = 1;
|
||||
FKey keycode;
|
||||
FKey keycode{};
|
||||
|
||||
// Look for a utf-8 character
|
||||
if ( utf8_input && (firstchar & 0xc0) == 0xc0 )
|
||||
{
|
||||
char utf8char[5] = { }; // Init array with '\0'
|
||||
char utf8char[5]{}; // Init array with '\0'
|
||||
|
||||
if ( (firstchar & 0xe0) == 0xc0 )
|
||||
len = 2;
|
||||
@ -304,7 +317,7 @@ inline FKey FKeyboard::getSingleKey()
|
||||
else if ( (firstchar & 0xf8) == 0xf0 )
|
||||
len = 4;
|
||||
|
||||
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);
|
||||
|
||||
keycode = UTF8decode(utf8char);
|
||||
@ -359,14 +372,14 @@ bool FKeyboard::isKeypressTimeout()
|
||||
//----------------------------------------------------------------------
|
||||
FKey FKeyboard::UTF8decode (const char utf8[])
|
||||
{
|
||||
FKey ucs = 0; // Universal coded character
|
||||
FKey ucs{0}; // Universal coded character
|
||||
constexpr std::size_t max = 4;
|
||||
std::size_t len = std::strlen(utf8);
|
||||
|
||||
if ( len > max )
|
||||
len = max;
|
||||
|
||||
for (std::size_t i = 0; i < len; ++i)
|
||||
for (std::size_t i{0}; i < len; ++i)
|
||||
{
|
||||
uChar ch = uChar(utf8[i]);
|
||||
|
||||
@ -408,9 +421,8 @@ FKey FKeyboard::UTF8decode (const char utf8[])
|
||||
//----------------------------------------------------------------------
|
||||
inline ssize_t FKeyboard::readKey()
|
||||
{
|
||||
ssize_t bytes;
|
||||
setNonBlockingInput();
|
||||
bytes = read(FTermios::getStdIn(), &read_buf, READ_BUF_SIZE - 1);
|
||||
ssize_t bytes = read(FTermios::getStdIn(), &read_buf, READ_BUF_SIZE - 1);
|
||||
unsetNonBlockingInput();
|
||||
return bytes;
|
||||
}
|
||||
@ -418,14 +430,14 @@ inline ssize_t FKeyboard::readKey()
|
||||
//----------------------------------------------------------------------
|
||||
void FKeyboard::parseKeyBuffer()
|
||||
{
|
||||
ssize_t bytesread;
|
||||
ssize_t bytesread{};
|
||||
FObject::getCurrentTime (&time_keypressed);
|
||||
|
||||
while ( (bytesread = readKey()) > 0 )
|
||||
{
|
||||
if ( bytesread + fifo_offset <= int(FIFO_BUF_SIZE) )
|
||||
{
|
||||
for (std::size_t i = 0; i < std::size_t(bytesread); i++)
|
||||
for (std::size_t i{0}; i < std::size_t(bytesread); i++)
|
||||
{
|
||||
fifo_buf[fifo_offset] = read_buf[i];
|
||||
fifo_offset++;
|
||||
|
127
src/flabel.cpp
127
src/flabel.cpp
@ -23,6 +23,8 @@
|
||||
#include <memory>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fcolorpair.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/flabel.h"
|
||||
#include "final/fstatusbar.h"
|
||||
|
||||
@ -181,24 +183,6 @@ void FLabel::setAlignment (fc::text_alignment align)
|
||||
alignment = align;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FLabel::setEmphasis (bool enable)
|
||||
{
|
||||
if ( emphasis != enable )
|
||||
emphasis = enable;
|
||||
|
||||
return enable;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FLabel::setReverseMode (bool enable)
|
||||
{
|
||||
if ( reverse_mode != enable )
|
||||
reverse_mode = enable;
|
||||
|
||||
return enable;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FLabel::setEnable (bool enable)
|
||||
{
|
||||
@ -215,7 +199,7 @@ bool FLabel::setEnable (bool enable)
|
||||
//----------------------------------------------------------------------
|
||||
void FLabel::setText (const FString& txt)
|
||||
{
|
||||
text = txt;
|
||||
text.setString(txt);
|
||||
multiline_text = text.split("\r\n");
|
||||
|
||||
if ( int(multiline_text.size()) > 1 )
|
||||
@ -234,7 +218,7 @@ void FLabel::setText (const FString& txt)
|
||||
void FLabel::hide()
|
||||
{
|
||||
FWidget::hide();
|
||||
hideSize (getSize());
|
||||
hideArea (getSize());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -340,41 +324,20 @@ void FLabel::init()
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t FLabel::getHotkeyPos ( wchar_t src[]
|
||||
, wchar_t dest[]
|
||||
, std::size_t length )
|
||||
{
|
||||
// find hotkey position in string
|
||||
// + generate a new string without the '&'-sign
|
||||
std::size_t hotkeypos = NOT_SET;
|
||||
wchar_t* txt = src;
|
||||
|
||||
for (std::size_t i = 0; i < length; i++)
|
||||
{
|
||||
if ( i < length && txt[i] == L'&' && hotkeypos == NOT_SET )
|
||||
{
|
||||
hotkeypos = i;
|
||||
i++;
|
||||
src++;
|
||||
}
|
||||
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
return hotkeypos;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLabel::setHotkeyAccelerator()
|
||||
{
|
||||
FKey hotkey = getHotkey(text);
|
||||
|
||||
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
|
||||
hotkey -= 0xfee0;
|
||||
|
||||
if ( hotkey )
|
||||
{
|
||||
if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
|
||||
@ -394,7 +357,7 @@ void FLabel::setHotkeyAccelerator()
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t FLabel::getAlignOffset (std::size_t length)
|
||||
{
|
||||
std::size_t width = std::size_t(getWidth());
|
||||
std::size_t width(getWidth());
|
||||
|
||||
switch ( alignment )
|
||||
{
|
||||
@ -420,6 +383,9 @@ std::size_t FLabel::getAlignOffset (std::size_t length)
|
||||
//----------------------------------------------------------------------
|
||||
void FLabel::draw()
|
||||
{
|
||||
if ( text.isEmpty() )
|
||||
return;
|
||||
|
||||
if ( isMonochron() )
|
||||
{
|
||||
setReverse(true);
|
||||
@ -451,16 +417,17 @@ void FLabel::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void FLabel::drawMultiLine()
|
||||
{
|
||||
std::size_t y = 0;
|
||||
std::size_t y{0};
|
||||
std::size_t text_lines = multiline_text.size();
|
||||
bool hotkey_printed = false;
|
||||
bool hotkey_printed{false};
|
||||
|
||||
while ( y < text_lines && y < std::size_t(getHeight()) )
|
||||
{
|
||||
wchar_t* label_text;
|
||||
std::size_t hotkeypos = NOT_SET;
|
||||
std::size_t align_offset;
|
||||
std::size_t length = multiline_text[y].getLength();
|
||||
wchar_t* label_text{};
|
||||
std::size_t hotkeypos{NOT_SET};
|
||||
std::size_t align_offset{};
|
||||
auto length = multiline_text[y].getLength();
|
||||
auto column_width = getColumnWidth(multiline_text[y]);
|
||||
|
||||
try
|
||||
{
|
||||
@ -476,7 +443,7 @@ void FLabel::drawMultiLine()
|
||||
auto dest = const_cast<wchar_t*>(label_text);
|
||||
|
||||
if ( ! hotkey_printed )
|
||||
hotkeypos = getHotkeyPos(src, dest, length);
|
||||
hotkeypos = finalcut::getHotkeyPos(src, dest, length);
|
||||
else
|
||||
std::wcsncpy(dest, src, length);
|
||||
|
||||
@ -485,13 +452,13 @@ void FLabel::drawMultiLine()
|
||||
if ( hotkeypos != NOT_SET )
|
||||
{
|
||||
align_offset = getAlignOffset(length - 1);
|
||||
printLine (label_text, length - 1, hotkeypos, align_offset);
|
||||
printLine (label_text, length - 1, column_width, hotkeypos, align_offset);
|
||||
hotkey_printed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
align_offset = getAlignOffset(length);
|
||||
printLine (label_text, length, NOT_SET, align_offset);
|
||||
printLine (label_text, length, column_width, NOT_SET, align_offset);
|
||||
}
|
||||
|
||||
y++;
|
||||
@ -502,10 +469,10 @@ void FLabel::drawMultiLine()
|
||||
//----------------------------------------------------------------------
|
||||
void FLabel::drawSingleLine()
|
||||
{
|
||||
wchar_t* label_text;
|
||||
std::size_t hotkeypos = NOT_SET;
|
||||
std::size_t align_offset;
|
||||
std::size_t length = text.getLength();
|
||||
wchar_t* label_text{};
|
||||
std::size_t hotkeypos{NOT_SET};
|
||||
auto length = text.getLength();
|
||||
auto column_width = getColumnWidth(text);
|
||||
|
||||
try
|
||||
{
|
||||
@ -517,40 +484,51 @@ void FLabel::drawSingleLine()
|
||||
return;
|
||||
}
|
||||
|
||||
hotkeypos = getHotkeyPos (text.wc_str(), label_text, length);
|
||||
hotkeypos = finalcut::getHotkeyPos (text.wc_str(), label_text, length);
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
{
|
||||
length--;
|
||||
column_width--;
|
||||
}
|
||||
|
||||
print() << FPoint(1, 1);
|
||||
align_offset = getAlignOffset(length);
|
||||
printLine (label_text, length, hotkeypos, align_offset);
|
||||
auto align_offset = getAlignOffset(column_width);
|
||||
printLine (label_text, length, column_width, hotkeypos, align_offset);
|
||||
delete[] label_text;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLabel::printLine ( wchar_t line[]
|
||||
, std::size_t length
|
||||
, std::size_t column_width
|
||||
, std::size_t hotkeypos
|
||||
, std::size_t align_offset )
|
||||
{
|
||||
std::size_t to_char;
|
||||
std::size_t width = std::size_t(getWidth());
|
||||
std::size_t to_char{};
|
||||
std::size_t to_column{};
|
||||
std::size_t width(getWidth());
|
||||
|
||||
if ( align_offset > 0 )
|
||||
print (FString(align_offset, ' ')); // leading spaces
|
||||
|
||||
if ( length <= width )
|
||||
if ( column_width <= width )
|
||||
{
|
||||
to_char = length;
|
||||
to_column = column_width;
|
||||
}
|
||||
else
|
||||
to_char = width - 2;
|
||||
{
|
||||
to_column = width - 2;
|
||||
to_char = getColumnWidthToLength(line, to_column);
|
||||
}
|
||||
|
||||
if ( hasReverseMode() )
|
||||
setReverse(true);
|
||||
|
||||
for (std::size_t z = 0; z < to_char; z++)
|
||||
for (std::size_t z{0}; z < to_char; z++)
|
||||
{
|
||||
if ( ! std::iswprint(wint_t(line[z])) )
|
||||
if ( ! std::iswprint(std::wint_t(line[z])) )
|
||||
{
|
||||
if ( ! isNewFont() && ( int(line[z]) < fc::NF_rev_left_arrow2
|
||||
|| int(line[z]) > fc::NF_check_mark ) )
|
||||
@ -559,16 +537,17 @@ void FLabel::printLine ( wchar_t line[]
|
||||
}
|
||||
}
|
||||
|
||||
if ( z == hotkeypos && flags.active )
|
||||
if ( z == hotkeypos && getFlags().active )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.label_hotkey_fg, wc.label_hotkey_bg);
|
||||
|
||||
if ( ! flags.no_underline )
|
||||
if ( ! getFlags().no_underline )
|
||||
setUnderline();
|
||||
|
||||
print (line[z]);
|
||||
|
||||
if ( ! flags.no_underline )
|
||||
if ( ! getFlags().no_underline )
|
||||
unsetUnderline();
|
||||
|
||||
if ( hasEmphasis() )
|
||||
@ -580,16 +559,16 @@ void FLabel::printLine ( wchar_t line[]
|
||||
print (line[z]);
|
||||
}
|
||||
|
||||
if ( length > width )
|
||||
if ( column_width > width )
|
||||
{
|
||||
// Print ellipsis
|
||||
print() << FColorPair(ellipsis_color, getBackgroundColor()) << "..";
|
||||
setColor();
|
||||
}
|
||||
else if ( align_offset + to_char < width )
|
||||
else if ( align_offset + to_column < width )
|
||||
{
|
||||
// Print trailing spaces
|
||||
std::size_t len = width - align_offset - to_char;
|
||||
std::size_t len = width - align_offset - to_column;
|
||||
print (FString(len, ' '));
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,16 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <regex>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/flabel.h"
|
||||
#include "final/flineedit.h"
|
||||
#include "final/fpoint.h"
|
||||
#include "final/fsize.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -161,6 +168,7 @@ const FLineEdit& FLineEdit::operator >> (FString& s)
|
||||
//----------------------------------------------------------------------
|
||||
bool FLineEdit::setEnable (bool enable)
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
FWidget::setEnable(enable);
|
||||
|
||||
if ( enable )
|
||||
@ -188,6 +196,7 @@ bool FLineEdit::setEnable (bool enable)
|
||||
//----------------------------------------------------------------------
|
||||
bool FLineEdit::setFocus (bool enable)
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
FWidget::setFocus(enable);
|
||||
|
||||
if ( enable )
|
||||
@ -229,45 +238,93 @@ bool FLineEdit::setShadow (bool enable)
|
||||
&& getEncoding() != fc::VT100
|
||||
&& getEncoding() != fc::ASCII )
|
||||
{
|
||||
flags.shadow = true;
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize(1, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
flags.shadow = false;
|
||||
setFlags().shadow = false;
|
||||
setShadowSize(FSize(0, 0));
|
||||
}
|
||||
|
||||
return flags.shadow;
|
||||
return getFlags().shadow;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::setText (const FString& txt)
|
||||
{
|
||||
text_offset = 0;
|
||||
cursor_pos = 0;
|
||||
|
||||
if ( txt )
|
||||
text = txt;
|
||||
{
|
||||
if ( txt.getLength() > max_length )
|
||||
text.setString(txt.left(max_length));
|
||||
else
|
||||
text.setString(txt);
|
||||
}
|
||||
else
|
||||
text = "";
|
||||
text.setString("");
|
||||
|
||||
if ( isShown() )
|
||||
{
|
||||
cursorEnd();
|
||||
adjustTextOffset();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::setMaxLength (std::size_t max)
|
||||
{
|
||||
max_length = max;
|
||||
|
||||
if ( text.getLength() > max_length )
|
||||
text.setString(text.left(max_length));
|
||||
|
||||
if ( isShown() )
|
||||
{
|
||||
cursorEnd();
|
||||
adjustTextOffset();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::setCursorPosition (std::size_t pos)
|
||||
{
|
||||
if ( pos == 0 )
|
||||
cursor_pos = 1;
|
||||
else
|
||||
cursor_pos = pos - 1;
|
||||
|
||||
if ( cursor_pos > text.getLength() )
|
||||
cursor_pos = text.getLength();
|
||||
|
||||
if ( isShown() )
|
||||
adjustTextOffset();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::setLabelText (const FString& ltxt)
|
||||
{
|
||||
label_text = ltxt;
|
||||
label_text.setString(ltxt);
|
||||
label->setText(label_text);
|
||||
adjustLabel();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::setLabelOrientation(const label_o o)
|
||||
void FLineEdit::setLabelOrientation (const label_o o)
|
||||
{
|
||||
label_orientation = o;
|
||||
adjustLabel();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::setGeometry ( const FPoint& pos, const FSize& size
|
||||
, bool adjust )
|
||||
{
|
||||
FWidget::setGeometry(pos, size, adjust);
|
||||
|
||||
if ( isShown() )
|
||||
adjustTextOffset();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::hide()
|
||||
{
|
||||
@ -276,14 +333,15 @@ void FLineEdit::hide()
|
||||
|
||||
FWidget::hide();
|
||||
FSize shadow = hasShadow() ? FSize(1, 1) : FSize(0, 0);
|
||||
hideSize (getSize() + shadow);
|
||||
hideArea (getSize() + shadow);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::clear()
|
||||
{
|
||||
text_offset = 0;
|
||||
cursor_pos = 0;
|
||||
text_offset = 0;
|
||||
char_width_offset = 0;
|
||||
text.clear();
|
||||
}
|
||||
|
||||
@ -295,44 +353,44 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
|
||||
switch ( key )
|
||||
{
|
||||
case fc::Fkey_left:
|
||||
keyLeft();
|
||||
cursorLeft();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
keyRight();
|
||||
cursorRight();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_home:
|
||||
keyHome();
|
||||
cursorHome();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_end:
|
||||
keyEnd();
|
||||
cursorEnd();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_dc: // del key
|
||||
keyDel();
|
||||
deleteCurrentCharacter();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_erase:
|
||||
case fc::Fkey_backspace:
|
||||
keyBackspace();
|
||||
deletePreviousCharacter();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_ic: // insert key
|
||||
keyInsert();
|
||||
switchInsertMode();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_return:
|
||||
case fc::Fkey_enter:
|
||||
keyEnter();
|
||||
acceptInput();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
@ -358,8 +416,6 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
return;
|
||||
|
||||
@ -377,17 +433,21 @@ void FLineEdit::onMouseDown (FMouseEvent* ev)
|
||||
getStatusBar()->drawMessage();
|
||||
}
|
||||
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
int xmin = 2 + int(char_width_offset);
|
||||
|
||||
if ( mouse_x >= 2 && mouse_x <= int(getWidth()) && mouse_y == 1 )
|
||||
if ( mouse_x >= xmin && mouse_x <= int(getWidth()) && mouse_y == 1 )
|
||||
{
|
||||
std::size_t len = text.getLength();
|
||||
cursor_pos = text_offset + std::size_t(mouse_x) - 2;
|
||||
cursor_pos = clickPosToCursorPos (std::size_t(mouse_x) - 2);
|
||||
|
||||
if ( cursor_pos >= len )
|
||||
cursor_pos = len;
|
||||
|
||||
if ( mouse_x == int(getWidth()) )
|
||||
adjustTextOffset();
|
||||
|
||||
drawInputField();
|
||||
updateTerminal();
|
||||
}
|
||||
@ -407,23 +467,21 @@ void FLineEdit::onMouseUp (FMouseEvent*)
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
std::size_t len;
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
return;
|
||||
|
||||
len = text.getLength();
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
std::size_t len = text.getLength();
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
if ( mouse_x >= 2 && mouse_x <= int(getWidth()) && mouse_y == 1 )
|
||||
{
|
||||
cursor_pos = text_offset + std::size_t(mouse_x) - 2;
|
||||
cursor_pos = clickPosToCursorPos (std::size_t(mouse_x) - 2);
|
||||
|
||||
if ( cursor_pos >= len )
|
||||
cursor_pos = len;
|
||||
|
||||
adjustTextOffset();
|
||||
drawInputField();
|
||||
updateTerminal();
|
||||
}
|
||||
@ -448,14 +506,14 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
|
||||
else if ( mouse_x >= int(getWidth()) )
|
||||
{
|
||||
// drag right
|
||||
if ( ! scroll_timer && text_offset <= len - getWidth() + 1 )
|
||||
if ( ! scroll_timer && cursor_pos < len )
|
||||
{
|
||||
scroll_timer = true;
|
||||
addTimer(scroll_repeat);
|
||||
drag_scroll = FLineEdit::scrollRight;
|
||||
}
|
||||
|
||||
if ( text_offset == len - getWidth() + 2 )
|
||||
if ( cursor_pos == len )
|
||||
{
|
||||
delOwnTimer();
|
||||
drag_scroll = FLineEdit::noScroll;
|
||||
@ -473,7 +531,7 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::onTimer (FTimerEvent*)
|
||||
{
|
||||
std::size_t len = text.getLength();
|
||||
auto len = text.getLength();
|
||||
|
||||
switch ( int(drag_scroll) )
|
||||
{
|
||||
@ -495,14 +553,13 @@ void FLineEdit::onTimer (FTimerEvent*)
|
||||
break;
|
||||
|
||||
case FLineEdit::scrollRight:
|
||||
if ( len < getWidth() - 2
|
||||
|| text_offset == len - getWidth() + 2 )
|
||||
if ( text_offset == endPosToOffset(len).first )
|
||||
{
|
||||
drag_scroll = FLineEdit::noScroll;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( text_offset <= len - getWidth() + 1 )
|
||||
if ( text_offset < endPosToOffset(len).first )
|
||||
text_offset++;
|
||||
|
||||
if ( cursor_pos < len )
|
||||
@ -514,6 +571,7 @@ void FLineEdit::onTimer (FTimerEvent*)
|
||||
break;
|
||||
}
|
||||
|
||||
adjustTextOffset();
|
||||
drawInputField();
|
||||
updateTerminal();
|
||||
}
|
||||
@ -587,10 +645,10 @@ void FLineEdit::onFocusOut (FFocusEvent*)
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::adjustLabel()
|
||||
{
|
||||
std::size_t label_length = label_text.getLength();
|
||||
auto label_width = getColumnWidth(label_text);
|
||||
|
||||
if ( hasHotkey() )
|
||||
label_length--;
|
||||
label_width--;
|
||||
|
||||
assert ( label_orientation == label_above
|
||||
|| label_orientation == label_left );
|
||||
@ -599,12 +657,12 @@ void FLineEdit::adjustLabel()
|
||||
{
|
||||
case label_above:
|
||||
label->setGeometry ( FPoint(getX(), getY() - 1)
|
||||
, FSize(label_length, 1) );
|
||||
, FSize(label_width, 1) );
|
||||
break;
|
||||
|
||||
case label_left:
|
||||
label->setGeometry ( FPoint(getX() - int(label_length) - 1, getY())
|
||||
, FSize(label_length, 1) );
|
||||
label->setGeometry ( FPoint(getX() - int(label_width) - 1, getY())
|
||||
, FSize(label_width, 1) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -614,6 +672,9 @@ void FLineEdit::adjustSize()
|
||||
{
|
||||
FWidget::adjustSize();
|
||||
adjustLabel();
|
||||
|
||||
if ( isShown() )
|
||||
adjustTextOffset();
|
||||
}
|
||||
|
||||
|
||||
@ -621,6 +682,7 @@ void FLineEdit::adjustSize()
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::init()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
label->setAccelWidget(this);
|
||||
setVisibleCursor();
|
||||
setShadow();
|
||||
@ -657,9 +719,15 @@ bool FLineEdit::hasHotkey()
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::draw()
|
||||
{
|
||||
if ( cursor_pos == NOT_SET )
|
||||
cursorEnd();
|
||||
|
||||
if ( ! isShown() )
|
||||
adjustTextOffset();
|
||||
|
||||
drawInputField();
|
||||
|
||||
if ( flags.focus && getStatusBar() )
|
||||
if ( getFlags().focus && getStatusBar() )
|
||||
{
|
||||
const auto& msg = getStatusbarMessage();
|
||||
const auto& curMsg = getStatusBar()->getMessage();
|
||||
@ -675,9 +743,7 @@ void FLineEdit::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::drawInputField()
|
||||
{
|
||||
std::size_t x;
|
||||
FString show_text;
|
||||
bool isActiveFocus = flags.active && flags.focus;
|
||||
bool isActiveFocus = getFlags().active && getFlags().focus;
|
||||
print() << FPoint(1, 1);
|
||||
|
||||
if ( isMonochron() )
|
||||
@ -699,14 +765,17 @@ void FLineEdit::drawInputField()
|
||||
if ( isActiveFocus && getMaxColor() < 16 )
|
||||
setBold();
|
||||
|
||||
show_text = text.mid(1 + text_offset, getWidth() - 2);
|
||||
auto text_offset_column = getColumnWidth (text, text_offset);
|
||||
std::size_t start_column = text_offset_column - char_width_offset + 1;
|
||||
const FString& show_text = \
|
||||
getColumnSubString(text, start_column, getWidth() - 2);
|
||||
|
||||
if ( show_text )
|
||||
print (show_text);
|
||||
|
||||
x = show_text.getLength();
|
||||
std::size_t x = getColumnWidth(show_text);
|
||||
|
||||
while ( x < getWidth() - 1 )
|
||||
while ( x + 1 < getWidth() )
|
||||
{
|
||||
print (' ');
|
||||
x++;
|
||||
@ -721,57 +790,177 @@ void FLineEdit::drawInputField()
|
||||
setUnderline(false);
|
||||
}
|
||||
|
||||
if ( flags.shadow )
|
||||
if ( getFlags().shadow )
|
||||
drawShadow ();
|
||||
|
||||
// set the cursor to the first pos.
|
||||
setCursorPos (FPoint(int(2 + cursor_pos - text_offset), 1));
|
||||
// set the cursor to the insert pos.
|
||||
auto cursor_pos_column = getColumnWidth (text, cursor_pos);
|
||||
int xpos = int(2 + cursor_pos_column
|
||||
- text_offset_column
|
||||
+ char_width_offset);
|
||||
setCursorPos (FPoint(xpos, 1));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::keyLeft()
|
||||
inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
|
||||
{
|
||||
std::size_t input_width = getWidth() - 2;
|
||||
std::size_t fullwidth_char_offset{0};
|
||||
std::size_t len = text.getLength();
|
||||
|
||||
if ( pos >= len )
|
||||
pos = len - 1;
|
||||
|
||||
while ( pos > 0 && input_width > 0 )
|
||||
{
|
||||
std::size_t char_width = getColumnWidth(text[pos]);
|
||||
|
||||
if ( input_width >= char_width )
|
||||
input_width -= char_width;
|
||||
|
||||
if ( input_width == 0 )
|
||||
break;
|
||||
|
||||
if ( input_width == 1)
|
||||
{
|
||||
if ( char_width == 1 )
|
||||
{
|
||||
if ( pos > 0 && getColumnWidth(text[pos - 1]) == 2 )
|
||||
{
|
||||
fullwidth_char_offset = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( char_width == 2 )
|
||||
{
|
||||
fullwidth_char_offset = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pos--;
|
||||
}
|
||||
|
||||
return offsetPair(pos, fullwidth_char_offset);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t FLineEdit::clickPosToCursorPos (std::size_t pos)
|
||||
{
|
||||
std::size_t click_width{0};
|
||||
std::size_t idx = text_offset;
|
||||
std::size_t len = text.getLength();
|
||||
pos -= char_width_offset;
|
||||
|
||||
while ( click_width < pos && idx < len )
|
||||
{
|
||||
std::size_t char_width = getColumnWidth(text[idx]);
|
||||
idx++;
|
||||
click_width += char_width;
|
||||
|
||||
if ( char_width == 2 && click_width == pos + 1)
|
||||
idx--;
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::adjustTextOffset()
|
||||
{
|
||||
std::size_t input_width = getWidth() - 2;
|
||||
std::size_t len = text.getLength();
|
||||
std::size_t len_column = getColumnWidth (text);
|
||||
std::size_t text_offset_column = getColumnWidth (text, text_offset);
|
||||
std::size_t cursor_pos_column = getColumnWidth (text, cursor_pos);
|
||||
std::size_t first_char_width{0};
|
||||
std::size_t cursor_char_width{1};
|
||||
char_width_offset = 0;
|
||||
|
||||
if ( cursor_pos < len )
|
||||
cursor_char_width = getColumnWidth(text[cursor_pos]);
|
||||
|
||||
if ( len > 0 )
|
||||
first_char_width = getColumnWidth(text[0]);
|
||||
|
||||
// Text alignment right for long lines
|
||||
while ( text_offset > 0 && len_column - text_offset_column < input_width )
|
||||
{
|
||||
text_offset--;
|
||||
text_offset_column = getColumnWidth (text, text_offset);
|
||||
}
|
||||
|
||||
// Right cursor overflow
|
||||
if ( cursor_pos_column + 1 > text_offset_column + input_width )
|
||||
{
|
||||
offsetPair offset_pair = endPosToOffset(cursor_pos);
|
||||
text_offset = offset_pair.first;
|
||||
char_width_offset = offset_pair.second;
|
||||
text_offset_column = getColumnWidth (text, text_offset);
|
||||
}
|
||||
|
||||
// Right full-width cursor overflow
|
||||
if ( cursor_pos_column + 2 > text_offset_column + input_width
|
||||
&& cursor_char_width == 2 )
|
||||
{
|
||||
text_offset++;
|
||||
|
||||
if ( first_char_width == 2 )
|
||||
char_width_offset = 1; // Deletes a half character at the beginning
|
||||
}
|
||||
|
||||
// Left cursor underflow
|
||||
if ( text_offset > cursor_pos )
|
||||
text_offset = cursor_pos;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::cursorLeft()
|
||||
{
|
||||
if ( cursor_pos > 0 )
|
||||
cursor_pos--;
|
||||
|
||||
if ( cursor_pos < text_offset )
|
||||
text_offset--;
|
||||
adjustTextOffset();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::keyRight()
|
||||
inline void FLineEdit::cursorRight()
|
||||
{
|
||||
std::size_t len = text.getLength();
|
||||
auto len = text.getLength();
|
||||
|
||||
if ( cursor_pos < len )
|
||||
cursor_pos++;
|
||||
|
||||
if ( cursor_pos - text_offset >= getWidth() - 2
|
||||
&& text_offset <= len - getWidth() + 1 )
|
||||
text_offset++;
|
||||
adjustTextOffset();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::keyHome()
|
||||
inline void FLineEdit::cursorHome()
|
||||
{
|
||||
cursor_pos = 0;
|
||||
text_offset = 0;
|
||||
char_width_offset = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::keyEnd()
|
||||
inline void FLineEdit::cursorEnd()
|
||||
{
|
||||
std::size_t len = text.getLength();
|
||||
auto len = text.getLength();
|
||||
|
||||
if ( cursor_pos == len )
|
||||
return;
|
||||
|
||||
cursor_pos = len;
|
||||
|
||||
if ( cursor_pos >= getWidth() - 1 )
|
||||
text_offset = len - getWidth() + 2;
|
||||
adjustTextOffset();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::keyDel()
|
||||
inline void FLineEdit::deleteCurrentCharacter()
|
||||
{
|
||||
std::size_t len = text.getLength();
|
||||
// Delete key functionality
|
||||
|
||||
auto len = text.getLength();
|
||||
|
||||
if ( len > 0 && cursor_pos < len )
|
||||
{
|
||||
@ -782,37 +971,34 @@ inline void FLineEdit::keyDel()
|
||||
if ( cursor_pos >= len )
|
||||
cursor_pos = len;
|
||||
|
||||
if ( text_offset > 0 && len - text_offset < getWidth() - 1 )
|
||||
text_offset--;
|
||||
adjustTextOffset();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::keyBackspace()
|
||||
inline void FLineEdit::deletePreviousCharacter()
|
||||
{
|
||||
if ( text.getLength() > 0 && cursor_pos > 0 )
|
||||
{
|
||||
text.remove(cursor_pos - 1, 1);
|
||||
processChanged();
|
||||
cursor_pos--;
|
||||
// Backspace functionality
|
||||
|
||||
if ( text_offset > 0 )
|
||||
text_offset--;
|
||||
}
|
||||
if ( text.getLength() == 0 || cursor_pos == 0 )
|
||||
return;
|
||||
|
||||
cursorLeft();
|
||||
deleteCurrentCharacter();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::keyInsert()
|
||||
inline void FLineEdit::switchInsertMode()
|
||||
{
|
||||
insert_mode = ! insert_mode;
|
||||
|
||||
if ( insert_mode )
|
||||
setInsertCursor();
|
||||
setInsertCursor(); // Insert mode
|
||||
else
|
||||
unsetInsertCursor();
|
||||
unsetInsertCursor(); // Overtype mode
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::keyEnter()
|
||||
inline void FLineEdit::acceptInput()
|
||||
{
|
||||
processActivate();
|
||||
}
|
||||
@ -820,41 +1006,57 @@ inline void FLineEdit::keyEnter()
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FLineEdit::keyInput (FKey key)
|
||||
{
|
||||
if ( text.getLength() >= max_length )
|
||||
{
|
||||
beep();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( key >= 0x20 && key <= 0x10fff )
|
||||
{
|
||||
std::size_t len = text.getLength();
|
||||
auto len = text.getLength();
|
||||
auto ch = characterFilter(wchar_t(key));
|
||||
|
||||
if ( cursor_pos == len )
|
||||
{
|
||||
text += wchar_t(key);
|
||||
processChanged();
|
||||
}
|
||||
if ( ch == L'\0' )
|
||||
return false;
|
||||
else if ( cursor_pos == len )
|
||||
text += ch;
|
||||
else if ( len > 0 )
|
||||
{
|
||||
if ( insert_mode )
|
||||
text.insert(wchar_t(key), cursor_pos);
|
||||
{
|
||||
text.insert(ch, cursor_pos);
|
||||
len++;
|
||||
}
|
||||
else
|
||||
text.overwrite(wchar_t(key), cursor_pos);
|
||||
|
||||
processChanged();
|
||||
text.overwrite(ch, cursor_pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
text = wchar_t(key);
|
||||
processChanged();
|
||||
}
|
||||
text.setString(ch);
|
||||
|
||||
cursor_pos++;
|
||||
|
||||
if ( cursor_pos >= getWidth() - 1 )
|
||||
text_offset++;
|
||||
|
||||
adjustTextOffset();
|
||||
processChanged();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline wchar_t FLineEdit::characterFilter (const wchar_t c)
|
||||
{
|
||||
if ( input_filter.empty() )
|
||||
return c;
|
||||
|
||||
wchar_t character[2]{c, L'\0'};
|
||||
|
||||
if ( regex_match(character, std::wregex(input_filter)) )
|
||||
return c;
|
||||
else
|
||||
return L'\0';
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::processActivate()
|
||||
{
|
||||
|
376
src/flistbox.cpp
376
src/flistbox.cpp
@ -24,9 +24,13 @@
|
||||
#include <memory>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fcolorpair.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/flistbox.h"
|
||||
#include "final/fscrollbar.h"
|
||||
#include "final/fstring.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -100,12 +104,10 @@ FListBox::~FListBox() // destructor
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::setCurrentItem (std::size_t index)
|
||||
{
|
||||
std::size_t element_count;
|
||||
|
||||
if ( index == current )
|
||||
return;
|
||||
|
||||
element_count = getCount();
|
||||
std::size_t element_count = getCount();
|
||||
|
||||
if ( index > element_count )
|
||||
current = element_count;
|
||||
@ -138,13 +140,13 @@ void FListBox::showInsideBrackets ( std::size_t index
|
||||
if ( b == fc::NoBrackets )
|
||||
return;
|
||||
|
||||
std::size_t len = iter->getText().getLength() + 2;
|
||||
std::size_t column_width = getColumnWidth(iter->getText()) + 2;
|
||||
|
||||
if ( len > max_line_width )
|
||||
if ( column_width > max_line_width )
|
||||
{
|
||||
max_line_width = len;
|
||||
max_line_width = column_width;
|
||||
|
||||
if ( len >= getWidth() - nf_offset - 3 )
|
||||
if ( column_width >= getWidth() - nf_offset - 3 )
|
||||
{
|
||||
int hmax = ( max_line_width > getWidth() - nf_offset - 4 )
|
||||
? int(max_line_width - getWidth() + nf_offset + 4)
|
||||
@ -161,7 +163,7 @@ void FListBox::showInsideBrackets ( std::size_t index
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::setGeometry ( const FPoint& pos, const FSize& size
|
||||
, bool adjust)
|
||||
, bool adjust )
|
||||
{
|
||||
// Set the widget geometry
|
||||
|
||||
@ -207,22 +209,22 @@ bool FListBox::setFocus (bool enable)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::setText (const FString& txt)
|
||||
{
|
||||
text = txt;
|
||||
text.setString(txt);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::hide()
|
||||
{
|
||||
FWidget::hide();
|
||||
hideSize (getSize());
|
||||
hideArea (getSize());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::insert (FListBoxItem listItem)
|
||||
{
|
||||
std::size_t len = listItem.text.getLength();
|
||||
bool has_brackets = bool(listItem.brackets);
|
||||
recalculateHorizontalBar (len, has_brackets);
|
||||
std::size_t column_width = getColumnWidth(listItem.text);
|
||||
bool has_brackets(listItem.brackets);
|
||||
recalculateHorizontalBar (column_width, has_brackets);
|
||||
|
||||
itemlist.push_back (listItem);
|
||||
|
||||
@ -233,21 +235,19 @@ void FListBox::insert (FListBoxItem listItem)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::remove (std::size_t item)
|
||||
{
|
||||
std::size_t element_count;
|
||||
|
||||
if ( item > getCount() )
|
||||
return;
|
||||
|
||||
itemlist.erase (itemlist.begin() + int(item) - 1);
|
||||
element_count = getCount();
|
||||
std::size_t element_count = getCount();
|
||||
max_line_width = 0;
|
||||
|
||||
for (auto&& listbox_item : itemlist)
|
||||
{
|
||||
std::size_t len = listbox_item.getText().getLength();
|
||||
std::size_t column_width = getColumnWidth(listbox_item.getText());
|
||||
|
||||
if ( len > max_line_width )
|
||||
max_line_width = len;
|
||||
if ( column_width > max_line_width )
|
||||
max_line_width = column_width;
|
||||
}
|
||||
|
||||
int hmax = ( max_line_width > getWidth() - nf_offset - 4 )
|
||||
@ -259,7 +259,7 @@ void FListBox::remove (std::size_t item)
|
||||
if ( hbar->isShown() && isHorizontallyScrollable() )
|
||||
hbar->hide();
|
||||
|
||||
int vmax = ( element_count > getHeight() - 2 )
|
||||
int vmax = ( element_count + 2 > getHeight() )
|
||||
? int(element_count - getHeight()) + 2
|
||||
: 0;
|
||||
vbar->setMaximum (vmax);
|
||||
@ -284,8 +284,8 @@ void FListBox::remove (std::size_t item)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::clear()
|
||||
{
|
||||
std::size_t size;
|
||||
itemlist.clear();
|
||||
itemlist.shrink_to_fit();
|
||||
current = 0;
|
||||
xoffset = 0;
|
||||
yoffset = 0;
|
||||
@ -302,18 +302,19 @@ void FListBox::clear()
|
||||
hbar->hide();
|
||||
|
||||
// clear list from screen
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.list_fg, wc.list_bg);
|
||||
size = getWidth() - 2;
|
||||
std::size_t size = getWidth() - 2;
|
||||
|
||||
if ( size == 0 )
|
||||
return;
|
||||
|
||||
auto blank = createBlankArray(size + 1);
|
||||
char* blank = createBlankArray(size + 1);
|
||||
|
||||
std::memset (blank, ' ', size);
|
||||
blank[size] = '\0';
|
||||
|
||||
for (int y = 0; y < int(getHeight()) - 2; y++)
|
||||
for (int y{0}; y < int(getHeight()) - 2; y++)
|
||||
{
|
||||
print() << FPoint(2, 2 + y) << blank;
|
||||
}
|
||||
@ -333,69 +334,69 @@ void FListBox::onKeyPress (FKeyEvent* ev)
|
||||
{
|
||||
case fc::Fkey_return:
|
||||
case fc::Fkey_enter:
|
||||
keyEnter();
|
||||
acceptSelection();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_up:
|
||||
keyUp();
|
||||
onePosUp();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_down:
|
||||
keyDown();
|
||||
onePosDown();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_left:
|
||||
keyLeft();
|
||||
scrollLeft();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
keyRight();
|
||||
scrollRight();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_ppage:
|
||||
keyPgUp();
|
||||
onePageUp();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_npage:
|
||||
keyPgDn();
|
||||
onePageDown();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_home:
|
||||
keyHome();
|
||||
firstPos();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_end:
|
||||
keyEnd();
|
||||
lastPos();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_ic: // insert key
|
||||
if ( keyInsert() )
|
||||
if ( changeSelectionAndPosition() )
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_space:
|
||||
if ( keySpace() )
|
||||
if ( spacebarProcessing() )
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_erase:
|
||||
case fc::Fkey_backspace:
|
||||
if ( keyBackspace() )
|
||||
if ( deletePreviousCharacter() )
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_escape:
|
||||
case fc::Fkey_escape_mintty:
|
||||
if ( keyEsc() )
|
||||
if ( skipIncrementalSearch() )
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
@ -414,8 +415,8 @@ void FListBox::onKeyPress (FKeyEvent* ev)
|
||||
|
||||
if ( ev->isAccepted() )
|
||||
{
|
||||
bool draw_vbar = yoffset_before != yoffset;
|
||||
bool draw_hbar = xoffset_before != xoffset;
|
||||
bool draw_vbar( yoffset_before != yoffset );
|
||||
bool draw_hbar( xoffset_before != xoffset );
|
||||
updateDrawing (draw_vbar, draw_hbar);
|
||||
}
|
||||
}
|
||||
@ -423,10 +424,6 @@ void FListBox::onKeyPress (FKeyEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
int yoffset_before
|
||||
, mouse_x
|
||||
, mouse_y;
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::RightButton )
|
||||
{
|
||||
@ -438,9 +435,9 @@ void FListBox::onMouseDown (FMouseEvent* ev)
|
||||
|
||||
getWidgetFocus();
|
||||
|
||||
yoffset_before = yoffset;
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
int yoffset_before = yoffset;
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
if ( mouse_x > 1 && mouse_x < int(getWidth())
|
||||
&& mouse_y > 1 && mouse_y < int(getHeight()) )
|
||||
@ -548,13 +545,11 @@ void FListBox::onMouseMove (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::onMouseDoubleClick (FMouseEvent* ev)
|
||||
{
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
return;
|
||||
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
if ( mouse_x > 1 && mouse_x < int(getWidth())
|
||||
&& mouse_y > 1 && mouse_y < int(getHeight()) )
|
||||
@ -619,11 +614,9 @@ void FListBox::onTimer (FTimerEvent*)
|
||||
void FListBox::onWheel (FWheelEvent* ev)
|
||||
{
|
||||
std::size_t current_before = current;
|
||||
int wheel
|
||||
, yoffset_before = yoffset
|
||||
, pagesize = 4;
|
||||
|
||||
wheel = ev->getWheel();
|
||||
int yoffset_before = yoffset;
|
||||
int pagesize{4};
|
||||
int wheel = ev->getWheel();
|
||||
|
||||
if ( drag_scroll != fc::noScroll )
|
||||
stopDragScroll();
|
||||
@ -727,7 +720,7 @@ void FListBox::adjustSize()
|
||||
vbar->setHeight (height, false);
|
||||
vbar->resize();
|
||||
|
||||
int hmax = ( max_line_width > width - 2 )
|
||||
int hmax = ( max_line_width + 2 > width )
|
||||
? int(max_line_width - width + 2)
|
||||
: 0;
|
||||
hbar->setMaximum (hmax);
|
||||
@ -736,15 +729,18 @@ void FListBox::adjustSize()
|
||||
hbar->setWidth (width + nf_offset, false);
|
||||
hbar->resize();
|
||||
|
||||
if ( isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
else
|
||||
hbar->hide();
|
||||
if ( isShown() )
|
||||
{
|
||||
if ( isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
else
|
||||
hbar->hide();
|
||||
|
||||
if ( isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
else
|
||||
vbar->hide();
|
||||
if ( isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
else
|
||||
vbar->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -761,6 +757,7 @@ void FListBox::init()
|
||||
initScrollbar (vbar, fc::vertical, &FListBox::cb_VBarChange);
|
||||
initScrollbar (hbar, fc::horizontal, &FListBox::cb_HBarChange);
|
||||
setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
nf_offset = isNewFont() ? 1 : 0;
|
||||
@ -807,16 +804,13 @@ void FListBox::draw()
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( isNewFont() )
|
||||
drawBorder (1, 1, int(getWidth()) - 1, int(getHeight()));
|
||||
else
|
||||
drawBorder();
|
||||
drawBorder();
|
||||
|
||||
if ( isNewFont() && ! vbar->isShown() )
|
||||
{
|
||||
setColor();
|
||||
|
||||
for (int y = 2; y < int(getHeight()); y++)
|
||||
for (int y{2}; y < int(getHeight()); y++)
|
||||
{
|
||||
print() << FPoint(int(getWidth()), y)
|
||||
<< ' '; // clear right side of the scrollbar
|
||||
@ -828,11 +822,10 @@ void FListBox::draw()
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
vbar->redraw();
|
||||
hbar->redraw();
|
||||
drawScrollbars();
|
||||
drawList();
|
||||
|
||||
if ( flags.focus && getStatusBar() )
|
||||
if ( getFlags().focus && getStatusBar() )
|
||||
{
|
||||
const auto& msg = getStatusbarMessage();
|
||||
const auto& curMsg = getStatusBar()->getMessage();
|
||||
@ -845,27 +838,56 @@ void FListBox::draw()
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::drawBorder()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
{
|
||||
FRect box(FPoint(1, 1), getSize());
|
||||
box.scaleBy(-1, 0);
|
||||
finalcut::drawBorder (this, box);
|
||||
}
|
||||
else
|
||||
FWidget::drawBorder();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::drawScrollbars()
|
||||
{
|
||||
if ( ! hbar->isShown() && isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
else
|
||||
vbar->redraw();
|
||||
|
||||
if ( ! vbar->isShown() && isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
else
|
||||
hbar->redraw();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::drawHeadline()
|
||||
{
|
||||
if ( text.isNull() || text.isEmpty() )
|
||||
return;
|
||||
|
||||
FString txt = " " + text + " ";
|
||||
std::size_t length = txt.getLength();
|
||||
FString txt(" " + text + " ");
|
||||
auto column_width = getColumnWidth(txt);
|
||||
print() << FPoint(2, 1);
|
||||
const auto& wc = getFWidgetColors();
|
||||
|
||||
if ( isEnabled() )
|
||||
setColor(wc.label_emphasis_fg, wc.label_bg);
|
||||
else
|
||||
setColor(wc.label_inactive_fg, wc.label_inactive_bg);
|
||||
|
||||
if ( length <= uInt(getClientWidth()) )
|
||||
if ( column_width <= getClientWidth() )
|
||||
print (txt);
|
||||
else
|
||||
{
|
||||
// Print ellipsis
|
||||
print() << text.left(uInt(getClientWidth() - 2))
|
||||
print() << getColumnSubString (text, 1, getClientWidth() - 2)
|
||||
<< FColorPair (wc.label_ellipsis_fg, wc.label_bg) << "..";
|
||||
}
|
||||
}
|
||||
@ -876,8 +898,8 @@ void FListBox::drawList()
|
||||
if ( itemlist.empty() || getHeight() <= 2 || getWidth() <= 4 )
|
||||
return;
|
||||
|
||||
std::size_t start = 0;
|
||||
std::size_t num = uInt(getHeight() - 2);
|
||||
std::size_t start{};
|
||||
std::size_t num(getHeight() - 2);
|
||||
|
||||
if ( num > getCount() )
|
||||
num = getCount();
|
||||
@ -897,7 +919,7 @@ void FListBox::drawList()
|
||||
|
||||
for (std::size_t y = start; y < num && iter != itemlist.end() ; y++)
|
||||
{
|
||||
bool serach_mark = false;
|
||||
bool serach_mark{false};
|
||||
bool lineHasBrackets = hasBrackets(iter);
|
||||
|
||||
// Import data via lazy conversion
|
||||
@ -930,16 +952,15 @@ inline void FListBox::drawListLine ( int y
|
||||
, listBoxItems::iterator iter
|
||||
, bool serach_mark )
|
||||
{
|
||||
std::size_t i, len;
|
||||
std::size_t inc_len = inc_search.getLength();
|
||||
bool isCurrentLine = bool(y + yoffset + 1 == int(current));
|
||||
FString element;
|
||||
element = getString(iter).mid ( std::size_t(1 + xoffset)
|
||||
, getWidth() - nf_offset - 4 );
|
||||
const wchar_t* const& element_str = element.wc_str();
|
||||
len = element.getLength();
|
||||
const auto& wc = getFWidgetColors();
|
||||
bool isCurrentLine( y + yoffset + 1 == int(current) );
|
||||
std::size_t first = std::size_t(xoffset) + 1;
|
||||
std::size_t max_width = getWidth() - nf_offset - 4;
|
||||
FString element(getColumnSubString (getString(iter), first, max_width));
|
||||
std::size_t column_width = getColumnWidth(element);
|
||||
|
||||
if ( isMonochron() && isCurrentLine && flags.focus )
|
||||
if ( isMonochron() && isCurrentLine && getFlags().focus )
|
||||
print (fc::BlackRightPointingPointer); // ►
|
||||
else
|
||||
print (' ');
|
||||
@ -948,22 +969,22 @@ inline void FListBox::drawListLine ( int y
|
||||
setColor ( wc.current_inc_search_element_fg
|
||||
, wc.current_element_focus_bg );
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
for (std::size_t i{0}; i < element.getLength(); i++)
|
||||
{
|
||||
if ( serach_mark && i == inc_len && flags.focus )
|
||||
if ( serach_mark && i == inc_len && getFlags().focus )
|
||||
setColor ( wc.current_element_focus_fg
|
||||
, wc.current_element_focus_bg );
|
||||
|
||||
print (element_str[i]);
|
||||
print (element[i]);
|
||||
}
|
||||
|
||||
if ( isMonochron() && isCurrentLine && flags.focus )
|
||||
if ( isMonochron() && isCurrentLine && getFlags().focus )
|
||||
{
|
||||
print (fc::BlackLeftPointingPointer); // ◄
|
||||
i++;
|
||||
column_width++;
|
||||
}
|
||||
|
||||
for (; i < getWidth() - nf_offset - 3; i++)
|
||||
for (; column_width < getWidth() - nf_offset - 3; column_width++)
|
||||
print (' ');
|
||||
}
|
||||
|
||||
@ -986,35 +1007,30 @@ inline void FListBox::drawListBracketsLine ( int y
|
||||
, listBoxItems::iterator iter
|
||||
, bool serach_mark )
|
||||
{
|
||||
FString element;
|
||||
std::size_t len
|
||||
, full_length
|
||||
, inc_len = inc_search.getLength()
|
||||
, i = 0
|
||||
, b = 0;
|
||||
bool isCurrentLine = bool(y + yoffset + 1 == int(current));
|
||||
std::size_t inc_len = inc_search.getLength()
|
||||
, b{0};
|
||||
bool isCurrentLine( y + yoffset + 1 == int(current) );
|
||||
|
||||
if ( isMonochron() && isCurrentLine && flags.focus )
|
||||
if ( isMonochron() && isCurrentLine && getFlags().focus )
|
||||
print (fc::BlackRightPointingPointer); // ►
|
||||
else
|
||||
print (' ');
|
||||
|
||||
if ( xoffset == 0 )
|
||||
{
|
||||
b = 1;
|
||||
b = 1; // Required bracket space
|
||||
printLeftBracket (iter->brackets);
|
||||
|
||||
element = getString(iter).mid ( std::size_t(xoffset) + 1
|
||||
, getWidth() - nf_offset - 5 );
|
||||
}
|
||||
else
|
||||
element = getString(iter).mid ( std::size_t(xoffset)
|
||||
, getWidth() - nf_offset - 4 );
|
||||
|
||||
const wchar_t* const& element_str = element.wc_str();
|
||||
len = element.getLength();
|
||||
std::size_t first = std::size_t(xoffset);
|
||||
std::size_t max_width = getWidth() - nf_offset - 4 - b;
|
||||
FString element(getColumnSubString (getString(iter), first, max_width));
|
||||
std::size_t column_width = getColumnWidth(element);
|
||||
std::size_t text_width = getColumnWidth(getString(iter));
|
||||
std::size_t i{0};
|
||||
const auto& wc = getFWidgetColors();
|
||||
|
||||
for (; i < len; i++)
|
||||
for (; i < element.getLength(); i++)
|
||||
{
|
||||
if ( serach_mark && i == 0 )
|
||||
setColor ( wc.current_inc_search_element_fg
|
||||
@ -1024,29 +1040,27 @@ inline void FListBox::drawListBracketsLine ( int y
|
||||
setColor ( wc.current_element_focus_fg
|
||||
, wc.current_element_focus_bg );
|
||||
|
||||
print (element_str[i]);
|
||||
print (element[i]);
|
||||
}
|
||||
|
||||
full_length = getString(iter).getLength();
|
||||
|
||||
if ( b + i < getWidth() - nf_offset - 4
|
||||
&& std::size_t(xoffset) <= full_length + 1 )
|
||||
if ( b + column_width < getWidth() - nf_offset - 4
|
||||
&& std::size_t(xoffset) <= text_width )
|
||||
{
|
||||
if ( serach_mark && i == inc_len )
|
||||
setColor ( wc.current_element_focus_fg
|
||||
, wc.current_element_focus_bg );
|
||||
|
||||
printRightBracket (iter->brackets);
|
||||
i++;
|
||||
column_width++;
|
||||
}
|
||||
|
||||
if ( isMonochron() && isCurrentLine && flags.focus )
|
||||
if ( isMonochron() && isCurrentLine && getFlags().focus )
|
||||
{
|
||||
print (fc::BlackLeftPointingPointer); // ◄
|
||||
i++;
|
||||
column_width++;
|
||||
}
|
||||
|
||||
for (; b + i < getWidth() - nf_offset - 3; i++)
|
||||
for (; b + column_width < getWidth() - nf_offset - 3; column_width++)
|
||||
print (' ');
|
||||
}
|
||||
|
||||
@ -1056,8 +1070,10 @@ inline void FListBox::setLineAttributes ( int y
|
||||
, bool lineHasBrackets
|
||||
, bool& serach_mark )
|
||||
{
|
||||
bool isCurrentLine = bool(y + yoffset + 1 == int(current));
|
||||
bool isCurrentLine( y + yoffset + 1 == int(current) );
|
||||
std::size_t inc_len = inc_search.getLength();
|
||||
std::size_t inc_width = getColumnWidth(inc_search);
|
||||
const auto& wc = getFWidgetColors();
|
||||
print() << FPoint(2, 2 + int(y));
|
||||
|
||||
if ( isLineSelected )
|
||||
@ -1077,14 +1093,14 @@ inline void FListBox::setLineAttributes ( int y
|
||||
|
||||
if ( isCurrentLine )
|
||||
{
|
||||
if ( flags.focus && getMaxColor() < 16 )
|
||||
if ( getFlags().focus && getMaxColor() < 16 )
|
||||
setBold();
|
||||
|
||||
if ( isLineSelected )
|
||||
{
|
||||
if ( isMonochron() )
|
||||
setBold();
|
||||
else if ( flags.focus )
|
||||
else if ( getFlags().focus )
|
||||
setColor ( wc.selected_current_element_focus_fg
|
||||
, wc.selected_current_element_focus_bg );
|
||||
else
|
||||
@ -1098,7 +1114,7 @@ inline void FListBox::setLineAttributes ( int y
|
||||
if ( isMonochron() )
|
||||
unsetBold();
|
||||
|
||||
if ( flags.focus )
|
||||
if ( getFlags().focus )
|
||||
{
|
||||
setColor ( wc.current_element_focus_fg
|
||||
, wc.current_element_focus_bg );
|
||||
@ -1108,7 +1124,7 @@ inline void FListBox::setLineAttributes ( int y
|
||||
{
|
||||
serach_mark = true;
|
||||
// Place the cursor on the last found character
|
||||
setCursorPos (FPoint(2 + b + int(inc_len), 2 + int(y)));
|
||||
setCursorPos (FPoint(2 + b + int(inc_width), 2 + int(y)));
|
||||
}
|
||||
else // only highlighted
|
||||
setCursorPos (FPoint(3 + b, 2 + int(y))); // first character
|
||||
@ -1125,7 +1141,7 @@ inline void FListBox::setLineAttributes ( int y
|
||||
{
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
else if ( flags.focus && getMaxColor() < 16 )
|
||||
else if ( getFlags().focus && getMaxColor() < 16 )
|
||||
unsetBold();
|
||||
}
|
||||
}
|
||||
@ -1179,27 +1195,33 @@ void FListBox::recalculateHorizontalBar (std::size_t len, bool has_brackets)
|
||||
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4));
|
||||
hbar->calculateSliderValues();
|
||||
|
||||
if ( isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
else
|
||||
hbar->hide();
|
||||
if ( isShown() )
|
||||
{
|
||||
if ( isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
else
|
||||
hbar->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::recalculateVerticalBar (std::size_t element_count)
|
||||
{
|
||||
int vmax = ( element_count > getHeight() - 2 )
|
||||
int vmax = ( element_count + 2 > getHeight() )
|
||||
? int(element_count - getHeight() + 2)
|
||||
: 0;
|
||||
vbar->setMaximum (vmax);
|
||||
vbar->setPageSize (int(element_count), int(getHeight()) - 2);
|
||||
vbar->calculateSliderValues();
|
||||
|
||||
if ( isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
else
|
||||
vbar->hide();
|
||||
if ( isShown() )
|
||||
{
|
||||
if ( isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
else
|
||||
vbar->hide();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1242,7 +1264,7 @@ void FListBox::multiSelection (std::size_t pos)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::multiSelectionUpTo (std::size_t pos)
|
||||
{
|
||||
std::size_t from, to;
|
||||
std::size_t from{}, to{};
|
||||
|
||||
if ( ! isMultiSelection() )
|
||||
return;
|
||||
@ -1285,7 +1307,7 @@ void FListBox::wheelUp (int pagesize)
|
||||
|
||||
if ( yoffset < 0 )
|
||||
{
|
||||
current -= std::size_t(pagesize + yoffset);
|
||||
current -= std::size_t(pagesize) + std::size_t(yoffset);
|
||||
yoffset = 0;
|
||||
}
|
||||
else
|
||||
@ -1486,7 +1508,7 @@ void FListBox::scrollToY (int val)
|
||||
if ( yoffset < 0 )
|
||||
yoffset = 0;
|
||||
|
||||
current = std::size_t(yoffset + c);
|
||||
current = std::size_t(yoffset) + std::size_t(c);
|
||||
|
||||
if ( current < std::size_t(yoffset) )
|
||||
current = std::size_t(yoffset);
|
||||
@ -1525,35 +1547,35 @@ void FListBox::scrollRight (int distance)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::keyUp()
|
||||
{
|
||||
prevListItem (1);
|
||||
inc_search.clear();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::keyDown()
|
||||
{
|
||||
nextListItem (1);
|
||||
inc_search.clear();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::keyLeft()
|
||||
inline void FListBox::scrollLeft()
|
||||
{
|
||||
scrollLeft(1);
|
||||
inc_search.clear();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::keyRight()
|
||||
inline void FListBox::scrollRight()
|
||||
{
|
||||
scrollRight(1);
|
||||
inc_search.clear();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::keyPgUp()
|
||||
inline void FListBox::onePosUp()
|
||||
{
|
||||
prevListItem (1);
|
||||
inc_search.clear();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::onePosDown()
|
||||
{
|
||||
nextListItem (1);
|
||||
inc_search.clear();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::onePageUp()
|
||||
{
|
||||
int pagesize = int(getClientHeight()) - 1;
|
||||
prevListItem (pagesize);
|
||||
@ -1561,7 +1583,7 @@ inline void FListBox::keyPgUp()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::keyPgDn()
|
||||
inline void FListBox::onePageDown()
|
||||
{
|
||||
int pagesize = int(getClientHeight()) - 1;
|
||||
nextListItem (pagesize);
|
||||
@ -1569,7 +1591,7 @@ inline void FListBox::keyPgDn()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::keyHome()
|
||||
inline void FListBox::firstPos()
|
||||
{
|
||||
current = 1;
|
||||
yoffset = 0;
|
||||
@ -1577,7 +1599,7 @@ inline void FListBox::keyHome()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::keyEnd()
|
||||
inline void FListBox::lastPos()
|
||||
{
|
||||
std::size_t element_count = getCount();
|
||||
int yoffset_end = int(element_count - getClientHeight());
|
||||
@ -1590,7 +1612,7 @@ inline void FListBox::keyEnd()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FListBox::keyEsc()
|
||||
inline bool FListBox::skipIncrementalSearch()
|
||||
{
|
||||
if ( inc_search.getLength() > 0 )
|
||||
{
|
||||
@ -1602,21 +1624,21 @@ inline bool FListBox::keyEsc()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::keyEnter()
|
||||
inline void FListBox::acceptSelection()
|
||||
{
|
||||
processClick();
|
||||
inc_search.clear();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FListBox::keySpace()
|
||||
inline bool FListBox::spacebarProcessing()
|
||||
{
|
||||
std::size_t inc_len = inc_search.getLength();
|
||||
|
||||
if ( inc_len > 0 )
|
||||
if ( inc_len > 0 ) // Enter a spacebar for incremental search
|
||||
{
|
||||
inc_search += L' ';
|
||||
bool inc_found = false;
|
||||
bool inc_found{false};
|
||||
auto iter = itemlist.begin();
|
||||
|
||||
while ( iter != itemlist.end() )
|
||||
@ -1639,7 +1661,7 @@ inline bool FListBox::keySpace()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( isMultiSelection() )
|
||||
else if ( isMultiSelection() ) // Change selection
|
||||
{
|
||||
if ( isSelected(current) )
|
||||
unselectItem(current);
|
||||
@ -1654,7 +1676,7 @@ inline bool FListBox::keySpace()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FListBox::keyInsert()
|
||||
inline bool FListBox::changeSelectionAndPosition()
|
||||
{
|
||||
if ( isMultiSelection() )
|
||||
{
|
||||
@ -1671,7 +1693,7 @@ inline bool FListBox::keyInsert()
|
||||
if ( current > element_count )
|
||||
current = element_count;
|
||||
|
||||
if ( current - std::size_t(yoffset) >= getHeight() - 1 )
|
||||
if ( current - std::size_t(yoffset) + 1 >= getHeight() )
|
||||
yoffset++;
|
||||
|
||||
return true;
|
||||
@ -1682,7 +1704,7 @@ inline bool FListBox::keyInsert()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FListBox::keyBackspace()
|
||||
inline bool FListBox::deletePreviousCharacter()
|
||||
{
|
||||
std::size_t inc_len = inc_search.getLength();
|
||||
|
||||
@ -1726,7 +1748,7 @@ inline bool FListBox::keyIncSearchInput (FKey key)
|
||||
inc_search += wchar_t(key);
|
||||
|
||||
std::size_t inc_len = inc_search.getLength();
|
||||
bool inc_found = false;
|
||||
bool inc_found{false};
|
||||
auto iter = itemlist.begin();
|
||||
|
||||
while ( iter != itemlist.end() )
|
||||
@ -1781,8 +1803,8 @@ void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
|
||||
return;
|
||||
|
||||
convertToItem (*iter, source_container, y + yoffset);
|
||||
std::size_t len = iter->text.getLength();
|
||||
recalculateHorizontalBar (len, hasBrackets(iter));
|
||||
std::size_t column_width = getColumnWidth(iter->text);
|
||||
recalculateHorizontalBar (column_width, hasBrackets(iter));
|
||||
|
||||
if ( hbar->isShown() )
|
||||
hbar->redraw();
|
||||
@ -1793,8 +1815,8 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
|
||||
{
|
||||
FScrollbar::sType scrollType;
|
||||
std::size_t current_before = current;
|
||||
int distance = 1
|
||||
, pagesize = 4
|
||||
int distance{1}
|
||||
, pagesize{4}
|
||||
, yoffset_before = yoffset;
|
||||
scrollType = vbar->getScrollType();
|
||||
|
||||
@ -1842,8 +1864,7 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
|
||||
if ( isShown() )
|
||||
drawList();
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward
|
||||
&& scrollType <= FScrollbar::scrollWheelDown )
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward )
|
||||
{
|
||||
vbar->setValue (yoffset);
|
||||
|
||||
@ -1860,8 +1881,8 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
|
||||
{
|
||||
static constexpr int padding_space = 2; // 1 leading space + 1 trailing space
|
||||
FScrollbar::sType scrollType;
|
||||
int distance = 1
|
||||
, pagesize = 4
|
||||
int distance{1}
|
||||
, pagesize{4}
|
||||
, xoffset_before = xoffset;
|
||||
scrollType = hbar->getScrollType();
|
||||
|
||||
@ -1907,8 +1928,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
|
||||
flush_out();
|
||||
}
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward
|
||||
&& scrollType <= FScrollbar::scrollWheelDown )
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward )
|
||||
{
|
||||
hbar->setValue (xoffset);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
360
src/fmenu.cpp
360
src/fmenu.cpp
@ -24,9 +24,14 @@
|
||||
#include <vector>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fcolorpair.h"
|
||||
#include "final/fdialog.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/fmenu.h"
|
||||
#include "final/fmenubar.h"
|
||||
#include "final/fmenuitem.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -46,7 +51,7 @@ FMenu::FMenu(FWidget* parent)
|
||||
//----------------------------------------------------------------------
|
||||
FMenu::FMenu (const FString& txt, FWidget* parent)
|
||||
: FWindow(parent)
|
||||
, item(txt, parent)
|
||||
, menuitem(txt, parent)
|
||||
{
|
||||
init(parent);
|
||||
}
|
||||
@ -68,14 +73,14 @@ bool FMenu::setMenuWidget (bool enable)
|
||||
if ( isMenuWidget() == enable )
|
||||
return true;
|
||||
|
||||
return (flags.menu_widget = enable);
|
||||
return (setFlags().menu_widget = enable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::setStatusbarMessage (const FString& msg)
|
||||
{
|
||||
FWidget::setStatusbarMessage(msg);
|
||||
item.setStatusbarMessage(msg);
|
||||
menuitem.setStatusbarMessage(msg);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -106,7 +111,7 @@ void FMenu::hide()
|
||||
if ( openmenu && openmenu != this )
|
||||
openmenu->hide();
|
||||
|
||||
setOpenMenu(0);
|
||||
setOpenMenu(nullptr);
|
||||
}
|
||||
|
||||
mouse_down = false;
|
||||
@ -133,29 +138,29 @@ void FMenu::onKeyPress (FKeyEvent* ev)
|
||||
switch ( ev->key() )
|
||||
{
|
||||
case fc::Fkey_up:
|
||||
keyUp();
|
||||
selectPrevItem();
|
||||
break;
|
||||
|
||||
case fc::Fkey_down:
|
||||
keyDown();
|
||||
selectNextItem();
|
||||
break;
|
||||
|
||||
case fc::Fkey_left:
|
||||
keyLeft(ev);
|
||||
selectPrevMenu(ev);
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
keyRight(ev);
|
||||
selectNextMenu(ev);
|
||||
break;
|
||||
|
||||
case fc::Fkey_return:
|
||||
case fc::Fkey_enter:
|
||||
keyEnter();
|
||||
acceptSelection();
|
||||
break;
|
||||
|
||||
case fc::Fkey_escape:
|
||||
case fc::Fkey_escape_mintty:
|
||||
keyEscape();
|
||||
closeMenu();
|
||||
break;
|
||||
|
||||
case fc::Fmkey_1:
|
||||
@ -213,7 +218,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
|
||||
|
||||
mouse_down = true;
|
||||
|
||||
if ( item_list.empty() )
|
||||
if ( getItemList().empty() )
|
||||
return;
|
||||
|
||||
// Mouse pointer over menu list changed focus
|
||||
@ -234,7 +239,7 @@ void FMenu::onMouseUp (FMouseEvent* ev)
|
||||
{
|
||||
mouse_down = false;
|
||||
|
||||
if ( item_list.empty() )
|
||||
if ( getItemList().empty() )
|
||||
return;
|
||||
|
||||
// Mouse pointer over an entry in the menu list
|
||||
@ -255,7 +260,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||
if ( ! isWindowActive() )
|
||||
setActiveWindow(this);
|
||||
|
||||
if ( ! mouse_down || item_list.empty() )
|
||||
if ( ! mouse_down || getItemList().empty() )
|
||||
return;
|
||||
|
||||
mouseStates ms =
|
||||
@ -315,55 +320,52 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::cb_menuitem_toggled (FWidget* widget, FDataPtr)
|
||||
{
|
||||
auto menuitem = static_cast<FMenuItem*>(widget);
|
||||
auto m_item = static_cast<FMenuItem*>(widget);
|
||||
|
||||
if ( ! has_checkable_items )
|
||||
return;
|
||||
|
||||
if ( ! menuitem->isChecked() )
|
||||
if ( ! m_item->isChecked() )
|
||||
return;
|
||||
|
||||
if ( item_list.empty() )
|
||||
auto list = getItemList();
|
||||
|
||||
if ( list.empty() )
|
||||
return;
|
||||
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : list)
|
||||
{
|
||||
if ( (*iter) != menuitem
|
||||
&& (*iter)->isChecked()
|
||||
&& isRadioMenuItem(*iter) )
|
||||
if ( item != m_item
|
||||
&& item->isChecked()
|
||||
&& isRadioMenuItem(item) )
|
||||
{
|
||||
(*iter)->unsetChecked();
|
||||
item->unsetChecked();
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// private methods of FMenu
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenu::isWindowsMenu (FWidget* w) const
|
||||
bool FMenu::isWindowsMenu (const FWidget* w) const
|
||||
{
|
||||
return w->isDialogWidget();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenu::isMenuBar (FWidget* w) const
|
||||
bool FMenu::isMenuBar (const FWidget* w) const
|
||||
{
|
||||
return w->isInstanceOf("FMenuBar");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenu::isMenu (FWidget* w) const
|
||||
bool FMenu::isMenu (const FWidget* w) const
|
||||
{
|
||||
return w->isInstanceOf("FMenu");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenu::isRadioMenuItem (FWidget* w) const
|
||||
bool FMenu::isRadioMenuItem (const FWidget* w) const
|
||||
{
|
||||
return w->isInstanceOf("FRadioMenuItem");
|
||||
}
|
||||
@ -438,9 +440,10 @@ void FMenu::init(FWidget* parent)
|
||||
setMenuWidget();
|
||||
hide();
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.menu_active_fg);
|
||||
setBackgroundColor (wc.menu_active_bg);
|
||||
item.setMenu(this);
|
||||
menuitem.setMenu(this);
|
||||
|
||||
if ( parent )
|
||||
{
|
||||
@ -464,17 +467,14 @@ void FMenu::init(FWidget* parent)
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::calculateDimensions()
|
||||
{
|
||||
int item_X, item_Y, adjust_X;
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
max_item_width = 10; // minimum width
|
||||
|
||||
// find the maximum item width
|
||||
while ( iter != last )
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
std::size_t item_width = (*iter)->getTextLength() + 2;
|
||||
FKey accel_key = (*iter)->accel_key;
|
||||
bool has_menu = (*iter)->hasMenu();
|
||||
std::size_t item_width = item->getTextWidth() + 2;
|
||||
FKey accel_key = item->accel_key;
|
||||
bool has_menu = item->hasMenu();
|
||||
|
||||
if ( has_menu )
|
||||
{
|
||||
@ -491,54 +491,45 @@ void FMenu::calculateDimensions()
|
||||
|
||||
if ( item_width > max_item_width )
|
||||
max_item_width = item_width;
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
adjust_X = adjustX(getX());
|
||||
int adjust_X = adjustX(getX());
|
||||
|
||||
// set widget geometry
|
||||
setGeometry ( FPoint(adjust_X, getY())
|
||||
, FSize(max_item_width + 2, getCount() + 2) );
|
||||
|
||||
// set geometry of all items
|
||||
iter = item_list.begin();
|
||||
item_X = 1;
|
||||
item_Y = 1;
|
||||
int item_X = 1;
|
||||
int item_Y = 1;
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
(*iter)->setGeometry (FPoint(item_X, item_Y), FSize(max_item_width, 1));
|
||||
item->setGeometry (FPoint(item_X, item_Y), FSize(max_item_width, 1));
|
||||
|
||||
if ( (*iter)->hasMenu() )
|
||||
if ( item->hasMenu() )
|
||||
{
|
||||
int menu_X = getTermX() + int(max_item_width) + 1;
|
||||
int menu_Y = (*iter)->getTermY() - 2;
|
||||
int menu_Y = item->getTermY() - 2;
|
||||
// set sub-menu position
|
||||
(*iter)->getMenu()->setPos (FPoint(menu_X, menu_Y), false);
|
||||
item->getMenu()->setPos (FPoint(menu_X, menu_Y), false);
|
||||
}
|
||||
|
||||
item_Y++;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::adjustItems()
|
||||
{
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
if ( (*iter)->hasMenu() )
|
||||
if ( item->hasMenu() )
|
||||
{
|
||||
int menu_X, menu_Y;
|
||||
auto menu = (*iter)->getMenu();
|
||||
|
||||
menu_X = getTermX() + int(max_item_width) + 1;
|
||||
auto menu = item->getMenu();
|
||||
int menu_X = getTermX() + int(max_item_width) + 1;
|
||||
menu_X = menu->adjustX(menu_X);
|
||||
menu_Y = (*iter)->getTermY() - 2;
|
||||
int menu_Y = item->getTermY() - 2;
|
||||
|
||||
// set sub-menu position
|
||||
menu->setPos (FPoint(menu_X, menu_Y));
|
||||
@ -547,8 +538,6 @@ void FMenu::adjustItems()
|
||||
if ( menu->getCount() > 0 )
|
||||
menu->adjustItems();
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -558,7 +547,7 @@ int FMenu::adjustX (int x_pos)
|
||||
// Is menu outside on the right of the screen?
|
||||
if ( x_pos + int(max_item_width) >= int(getDesktopWidth() - 1) )
|
||||
{
|
||||
x_pos = int(getDesktopWidth() - max_item_width + 1);
|
||||
x_pos = int(getDesktopWidth() - max_item_width - 1);
|
||||
// Menu to large for the screen
|
||||
if ( x_pos < 1 )
|
||||
x_pos = 1;
|
||||
@ -656,16 +645,14 @@ void FMenu::hideSuperMenus()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenu::mouseDownOverList (FPoint mouse_pos)
|
||||
{
|
||||
bool focus_changed = false;
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
bool focus_changed{false};
|
||||
mouse_pos -= FPoint(getRightPadding(), getTopPadding());
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
int x1 = (*iter)->getX()
|
||||
, x2 = (*iter)->getX() + int((*iter)->getWidth())
|
||||
, y = (*iter)->getY()
|
||||
int x1 = item->getX()
|
||||
, x2 = item->getX() + int(item->getWidth())
|
||||
, y = item->getY()
|
||||
, mouse_x = mouse_pos.getX()
|
||||
, mouse_y = mouse_pos.getY();
|
||||
|
||||
@ -674,11 +661,9 @@ bool FMenu::mouseDownOverList (FPoint mouse_pos)
|
||||
&& mouse_y == y )
|
||||
{
|
||||
// Mouse pointer over item
|
||||
mouseDownSubmenu (*iter);
|
||||
mouseDownSelection (*iter, focus_changed);
|
||||
mouseDownSubmenu (item);
|
||||
mouseDownSelection (item, focus_changed);
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
return focus_changed;
|
||||
@ -745,27 +730,25 @@ void FMenu::mouseDownSelection (FMenuItem* m_item, bool& focus_changed)
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenu::mouseUpOverList (FPoint mouse_pos)
|
||||
{
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
mouse_pos -= FPoint(getRightPadding(), getTopPadding());
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
int x1 = (*iter)->getX()
|
||||
, x2 = (*iter)->getX() + int((*iter)->getWidth())
|
||||
, y = (*iter)->getY()
|
||||
int x1 = item->getX()
|
||||
, x2 = item->getX() + int(item->getWidth())
|
||||
, y = item->getY()
|
||||
, mouse_x = mouse_pos.getX()
|
||||
, mouse_y = mouse_pos.getY();
|
||||
|
||||
if ( (*iter)->isSelected()
|
||||
if ( item->isSelected()
|
||||
&& mouse_x >= x1
|
||||
&& mouse_x < x2
|
||||
&& mouse_y == y )
|
||||
{
|
||||
// Mouse pointer over item
|
||||
if ( (*iter)->hasMenu() )
|
||||
if ( item->hasMenu() )
|
||||
{
|
||||
auto sub_menu = (*iter)->getMenu();
|
||||
auto sub_menu = item->getMenu();
|
||||
if ( ! sub_menu->isShown() )
|
||||
openSubMenu (sub_menu, SELECT_ITEM);
|
||||
else if ( opened_sub_menu )
|
||||
@ -791,11 +774,9 @@ bool FMenu::mouseUpOverList (FPoint mouse_pos)
|
||||
unselectItem();
|
||||
hide();
|
||||
hideSuperMenus();
|
||||
(*iter)->processClicked();
|
||||
item->processClicked();
|
||||
}
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -804,24 +785,20 @@ bool FMenu::mouseUpOverList (FPoint mouse_pos)
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::mouseMoveOverList (FPoint mouse_pos, mouseStates& ms)
|
||||
{
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
mouse_pos -= FPoint(getRightPadding(), getTopPadding());
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
int x1 = (*iter)->getX()
|
||||
, x2 = (*iter)->getX() + int((*iter)->getWidth())
|
||||
, y = (*iter)->getY()
|
||||
int x1 = item->getX()
|
||||
, x2 = item->getX() + int(item->getWidth())
|
||||
, y = item->getY()
|
||||
, mouse_x = mouse_pos.getX()
|
||||
, mouse_y = mouse_pos.getY();
|
||||
|
||||
if ( mouse_x >= x1 && mouse_x < x2 && mouse_y == y )
|
||||
mouseMoveSelection (*iter, ms);
|
||||
mouseMoveSelection (item, ms);
|
||||
else
|
||||
mouseMoveDeselection (*iter, ms);
|
||||
|
||||
++iter;
|
||||
mouseMoveDeselection (item, ms);
|
||||
}
|
||||
}
|
||||
|
||||
@ -872,7 +849,7 @@ void FMenu::mouseMoveDeselection (FMenuItem* m_item, mouseStates& ms)
|
||||
m_item->unsetFocus();
|
||||
|
||||
if ( getSelectedItem() == m_item )
|
||||
setSelectedItem(0);
|
||||
setSelectedItem(nullptr);
|
||||
|
||||
ms.focus_changed = true;
|
||||
}
|
||||
@ -991,7 +968,7 @@ bool FMenu::containsMenuStructure (int x, int y)
|
||||
return true;
|
||||
else if ( si && si->hasMenu() && opened_sub_menu )
|
||||
return si->getMenu()->containsMenuStructure(x, y);
|
||||
else if ( item.getTermGeometry().contains(x, y) )
|
||||
else if ( menuitem.getTermGeometry().contains(x, y) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@ -1026,21 +1003,21 @@ FMenu* FMenu::superMenuAt (int x, int y)
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenu::selectNextItem()
|
||||
{
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
auto list = getItemList();
|
||||
auto iter = list.begin();
|
||||
|
||||
while ( iter != last )
|
||||
while ( iter != list.end() )
|
||||
{
|
||||
if ( (*iter)->isSelected() )
|
||||
{
|
||||
FMenuItem* next;
|
||||
FMenuItem* next{};
|
||||
auto next_element = iter;
|
||||
|
||||
do
|
||||
{
|
||||
++next_element;
|
||||
if ( next_element == item_list.end() )
|
||||
next_element = item_list.begin();
|
||||
if ( next_element == list.end() )
|
||||
next_element = list.begin();
|
||||
next = static_cast<FMenuItem*>(*next_element);
|
||||
}
|
||||
while ( ! next->isEnabled()
|
||||
@ -1074,8 +1051,8 @@ bool FMenu::selectNextItem()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenu::selectPrevItem()
|
||||
{
|
||||
auto iter = item_list.end();
|
||||
auto first = item_list.begin();
|
||||
auto list = getItemList();
|
||||
auto iter = list.end();
|
||||
|
||||
do
|
||||
{
|
||||
@ -1088,8 +1065,8 @@ bool FMenu::selectPrevItem()
|
||||
|
||||
do
|
||||
{
|
||||
if ( prev_element == item_list.begin() )
|
||||
prev_element = item_list.end();
|
||||
if ( prev_element == list.begin() )
|
||||
prev_element = list.end();
|
||||
--prev_element;
|
||||
prev = static_cast<FMenuItem*>(*prev_element);
|
||||
}
|
||||
@ -1115,7 +1092,7 @@ bool FMenu::selectPrevItem()
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ( iter != first );
|
||||
while ( iter != list.begin() );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1132,21 +1109,21 @@ void FMenu::keypressMenuBar (FKeyEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenu::hotkeyMenu (FKeyEvent* ev)
|
||||
{
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
if ( (*iter)->hasHotkey() )
|
||||
if ( item->hasHotkey() )
|
||||
{
|
||||
bool found = false;
|
||||
uChar hotkey = (*iter)->getHotkey();
|
||||
bool found{false};
|
||||
FKey hotkey = item->getHotkey();
|
||||
FKey key = ev->key();
|
||||
|
||||
if ( std::isalpha(hotkey) || std::isdigit(hotkey) )
|
||||
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
|
||||
hotkey -= 0xfee0;
|
||||
|
||||
if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
|
||||
{
|
||||
if ( FKey(std::tolower(hotkey)) == key
|
||||
|| FKey(std::toupper(hotkey)) == key )
|
||||
if ( FKey(std::tolower(int(hotkey))) == key
|
||||
|| FKey(std::toupper(int(hotkey))) == key )
|
||||
found = true;
|
||||
}
|
||||
else if ( hotkey == key )
|
||||
@ -1154,14 +1131,17 @@ bool FMenu::hotkeyMenu (FKeyEvent* ev)
|
||||
|
||||
if ( found )
|
||||
{
|
||||
if ( (*iter)->hasMenu() )
|
||||
if ( item->hasMenu() )
|
||||
{
|
||||
auto sub_menu = (*iter)->getMenu();
|
||||
auto sub_menu = item->getMenu();
|
||||
unselectItem();
|
||||
(*iter)->setSelected();
|
||||
setSelectedItem (*iter);
|
||||
item->setSelected();
|
||||
setSelectedItem (item);
|
||||
redraw();
|
||||
openSubMenu (sub_menu, SELECT_ITEM);
|
||||
|
||||
if ( ! sub_menu->isShown() )
|
||||
openSubMenu (sub_menu, SELECT_ITEM);
|
||||
|
||||
sub_menu->redraw();
|
||||
}
|
||||
else
|
||||
@ -1173,48 +1153,23 @@ bool FMenu::hotkeyMenu (FKeyEvent* ev)
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
ev->accept();
|
||||
(*iter)->processClicked();
|
||||
item->processClicked();
|
||||
}
|
||||
|
||||
ev->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t FMenu::getHotkeyPos ( wchar_t src[]
|
||||
, wchar_t dest[]
|
||||
, std::size_t length )
|
||||
{
|
||||
// Find hotkey position in string
|
||||
// + generate a new string without the '&'-sign
|
||||
std::size_t pos = NOT_SET;
|
||||
wchar_t* txt = src;
|
||||
|
||||
for (std::size_t i = 0; i < length; i++)
|
||||
{
|
||||
if ( i < length && txt[i] == L'&' && pos == NOT_SET )
|
||||
{
|
||||
pos = i;
|
||||
i++;
|
||||
src++;
|
||||
}
|
||||
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::draw()
|
||||
{
|
||||
// Fill the background
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.menu_active_fg, wc.menu_active_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
@ -1233,17 +1188,14 @@ void FMenu::draw()
|
||||
void FMenu::drawItems()
|
||||
{
|
||||
int y = 0;
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
if ( (*iter)->isSeparator() )
|
||||
if ( item->isSeparator() )
|
||||
drawSeparator (y);
|
||||
else
|
||||
drawMenuLine (*iter, y);
|
||||
drawMenuLine (item, y);
|
||||
|
||||
++iter;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
@ -1251,6 +1203,7 @@ void FMenu::drawItems()
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::drawSeparator (int y)
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
print() << FPoint(1, 2 + y)
|
||||
<< FColorPair(wc.menu_active_fg, wc.menu_active_bg);
|
||||
|
||||
@ -1279,21 +1232,22 @@ inline void FMenu::drawSeparator (int y)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::drawMenuLine (FMenuItem* menuitem, int y)
|
||||
inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
|
||||
{
|
||||
FString txt = menuitem->getText();
|
||||
menuText txtdata;
|
||||
FString txt(m_item->getText());
|
||||
menuText txtdata{};
|
||||
std::size_t txt_length = txt.getLength();
|
||||
std::size_t to_char = txt_length;
|
||||
FKey accel_key = menuitem->accel_key;
|
||||
bool is_enabled = menuitem->isEnabled();
|
||||
bool is_selected = menuitem->isSelected();
|
||||
std::size_t column_width = getColumnWidth(txt);
|
||||
FKey accel_key = m_item->accel_key;
|
||||
bool is_enabled = m_item->isEnabled();
|
||||
bool is_selected = m_item->isSelected();
|
||||
|
||||
// Set screen position and attributes
|
||||
setLineAttributes (menuitem, y);
|
||||
setLineAttributes (m_item, y);
|
||||
|
||||
// Draw check mark prefix for checkable items
|
||||
drawCheckMarkPrefix (menuitem);
|
||||
drawCheckMarkPrefix (m_item);
|
||||
|
||||
// Print leading blank space
|
||||
print (' ');
|
||||
@ -1308,14 +1262,17 @@ inline void FMenu::drawMenuLine (FMenuItem* menuitem, int y)
|
||||
return;
|
||||
}
|
||||
|
||||
hotkeypos = getHotkeyPos(txt.wc_str(), txtdata.text, txt_length);
|
||||
hotkeypos = finalcut::getHotkeyPos(txt.wc_str(), txtdata.text, txt_length);
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
{
|
||||
to_char--;
|
||||
column_width--;
|
||||
}
|
||||
|
||||
txtdata.length = to_char;
|
||||
txtdata.no_underline = menuitem->getFlags().no_underline;
|
||||
setCursorToHotkeyPosition (menuitem);
|
||||
txtdata.no_underline = m_item->getFlags().no_underline;
|
||||
setCursorToHotkeyPosition (m_item);
|
||||
|
||||
if ( ! is_enabled || is_selected )
|
||||
txtdata.hotkeypos = NOT_SET;
|
||||
@ -1324,14 +1281,14 @@ inline void FMenu::drawMenuLine (FMenuItem* menuitem, int y)
|
||||
|
||||
drawMenuText (txtdata);
|
||||
|
||||
if ( menuitem->hasMenu() )
|
||||
drawSubMenuIndicator (to_char);
|
||||
if ( m_item->hasMenu() )
|
||||
drawSubMenuIndicator (column_width);
|
||||
else if ( accel_key )
|
||||
drawAcceleratorKey (to_char, accel_key);
|
||||
drawAcceleratorKey (column_width, accel_key);
|
||||
|
||||
// Draw the trailing spaces of the selected line
|
||||
if ( is_selected )
|
||||
drawTrailingSpaces (to_char);
|
||||
drawTrailingSpaces (column_width);
|
||||
|
||||
if ( isMonochron() && is_enabled && is_selected )
|
||||
setReverse(true);
|
||||
@ -1340,11 +1297,11 @@ inline void FMenu::drawMenuLine (FMenuItem* menuitem, int y)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::drawCheckMarkPrefix (FMenuItem* menuitem)
|
||||
inline void FMenu::drawCheckMarkPrefix (FMenuItem* m_item)
|
||||
{
|
||||
bool is_checked = menuitem->isChecked();
|
||||
bool is_checkable = menuitem->checkable;
|
||||
bool is_radio_btn = menuitem->radio_button;
|
||||
bool is_checked = m_item->isChecked();
|
||||
bool is_checkable = m_item->checkable;
|
||||
bool is_radio_btn = m_item->radio_button;
|
||||
|
||||
if ( ! has_checkable_items )
|
||||
return;
|
||||
@ -1370,6 +1327,7 @@ inline void FMenu::drawCheckMarkPrefix (FMenuItem* menuitem)
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.menu_inactive_fg, getBackgroundColor());
|
||||
|
||||
if ( getEncoding() == fc::ASCII )
|
||||
@ -1389,9 +1347,9 @@ inline void FMenu::drawMenuText (menuText& data)
|
||||
{
|
||||
// Print menu text
|
||||
|
||||
for (std::size_t z = 0; z < data.length; z++)
|
||||
for (std::size_t z{0}; z < data.length; z++)
|
||||
{
|
||||
if ( ! std::iswprint(wint_t(data.text[z])) )
|
||||
if ( ! std::iswprint(std::wint_t(data.text[z])) )
|
||||
{
|
||||
if ( ! isNewFont()
|
||||
&& ( int(data.text[z]) < fc::NF_rev_left_arrow2
|
||||
@ -1404,6 +1362,7 @@ inline void FMenu::drawMenuText (menuText& data)
|
||||
|
||||
if ( z == data.hotkeypos )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg);
|
||||
|
||||
if ( ! data.no_underline )
|
||||
@ -1465,10 +1424,11 @@ inline void FMenu::drawTrailingSpaces (std::size_t startpos)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::setLineAttributes (FMenuItem* menuitem, int y)
|
||||
inline void FMenu::setLineAttributes (FMenuItem* m_item, int y)
|
||||
{
|
||||
bool is_enabled = menuitem->isEnabled();
|
||||
bool is_selected = menuitem->isSelected();
|
||||
bool is_enabled = m_item->isEnabled();
|
||||
bool is_selected = m_item->isSelected();
|
||||
const auto& wc = getFWidgetColors();
|
||||
|
||||
if ( is_enabled )
|
||||
{
|
||||
@ -1503,10 +1463,10 @@ inline void FMenu::setLineAttributes (FMenuItem* menuitem, int y)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::setCursorToHotkeyPosition (FMenuItem* menuitem)
|
||||
inline void FMenu::setCursorToHotkeyPosition (FMenuItem* m_item)
|
||||
{
|
||||
bool is_checkable = menuitem->checkable;
|
||||
bool is_selected = menuitem->isSelected();
|
||||
bool is_checkable = m_item->checkable;
|
||||
bool is_selected = m_item->isSelected();
|
||||
|
||||
if ( hotkeypos == NOT_SET )
|
||||
{
|
||||
@ -1514,9 +1474,9 @@ inline void FMenu::setCursorToHotkeyPosition (FMenuItem* menuitem)
|
||||
if ( is_selected )
|
||||
{
|
||||
if ( is_checkable )
|
||||
menuitem->setCursorPos (FPoint(3, 1));
|
||||
m_item->setCursorPos (FPoint(3, 1));
|
||||
else
|
||||
menuitem->setCursorPos (FPoint(2, 1));
|
||||
m_item->setCursorPos (FPoint(2, 1));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1524,28 +1484,18 @@ inline void FMenu::setCursorToHotkeyPosition (FMenuItem* menuitem)
|
||||
if ( is_selected )
|
||||
{
|
||||
// set cursor to the hotkey position
|
||||
auto x = getColumnWidth (m_item->getText(), hotkeypos);
|
||||
|
||||
if ( is_checkable )
|
||||
menuitem->setCursorPos (FPoint(3 + int(hotkeypos), 1));
|
||||
m_item->setCursorPos (FPoint(3 + int(x), 1));
|
||||
else
|
||||
menuitem->setCursorPos (FPoint(2 + int(hotkeypos), 1));
|
||||
m_item->setCursorPos (FPoint(2 + int(x), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::keyUp()
|
||||
{
|
||||
selectPrevItem();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::keyDown()
|
||||
{
|
||||
selectNextItem();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::keyLeft (FKeyEvent* ev)
|
||||
inline void FMenu::selectPrevMenu (FKeyEvent* ev)
|
||||
{
|
||||
if ( isSubMenu() )
|
||||
{
|
||||
@ -1569,7 +1519,7 @@ inline void FMenu::keyLeft (FKeyEvent* ev)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::keyRight (FKeyEvent* ev)
|
||||
inline void FMenu::selectNextMenu (FKeyEvent* ev)
|
||||
{
|
||||
if ( hasSelectedItem() && getSelectedItem()->hasMenu() )
|
||||
{
|
||||
@ -1585,7 +1535,7 @@ inline void FMenu::keyRight (FKeyEvent* ev)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::keyEnter()
|
||||
inline void FMenu::acceptSelection()
|
||||
{
|
||||
if ( ! hasSelectedItem() )
|
||||
return;
|
||||
@ -1604,7 +1554,7 @@ inline void FMenu::keyEnter()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::keyEscape()
|
||||
inline void FMenu::closeMenu()
|
||||
{
|
||||
unselectItem();
|
||||
hideSubMenus();
|
||||
|
251
src/fmenubar.cpp
251
src/fmenubar.cpp
@ -24,8 +24,12 @@
|
||||
#include <vector>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/fmenu.h"
|
||||
#include "final/fmenubar.h"
|
||||
#include "final/fmenuitem.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -45,7 +49,7 @@ FMenuBar::FMenuBar(FWidget* parent)
|
||||
//----------------------------------------------------------------------
|
||||
FMenuBar::~FMenuBar() // destructor
|
||||
{
|
||||
setMenuBar(0);
|
||||
setMenuBar(nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -61,11 +65,12 @@ void FMenuBar::resetMenu()
|
||||
void FMenuBar::hide()
|
||||
{
|
||||
FWindow::hide();
|
||||
const auto& wc = getFWidgetColors();
|
||||
FColor fg = wc.term_fg;
|
||||
FColor bg = wc.term_bg;
|
||||
setColor (fg, bg);
|
||||
screenWidth = getDesktopWidth();
|
||||
auto blank = createBlankArray (screenWidth + 1);
|
||||
char* blank = createBlankArray (screenWidth + 1);
|
||||
print() << FPoint(1, 1) << blank;
|
||||
destroyBlankArray (blank);
|
||||
}
|
||||
@ -148,7 +153,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
mouse_down = false;
|
||||
|
||||
if ( ! item_list.empty() && hasSelectedItem() )
|
||||
if ( ! getItemList().empty() && hasSelectedItem() )
|
||||
leaveMenuBar();
|
||||
else
|
||||
return;
|
||||
@ -245,6 +250,7 @@ void FMenuBar::init()
|
||||
|
||||
addAccelerator (fc::Fkey_f10);
|
||||
addAccelerator (fc::Fckey_space);
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.menu_active_fg);
|
||||
setBackgroundColor (wc.menu_active_bg);
|
||||
unsetFocusable();
|
||||
@ -254,35 +260,31 @@ void FMenuBar::init()
|
||||
void FMenuBar::calculateDimensions()
|
||||
{
|
||||
FPoint item_pos (1, 1);
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
|
||||
// find the maximum item width
|
||||
while ( iter != last )
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
std::size_t len = (*iter)->getTextLength();
|
||||
int item_width = int(len) + 2;
|
||||
int len = int(item->getTextWidth());
|
||||
int item_width = len + 2;
|
||||
|
||||
// set item geometry
|
||||
(*iter)->setGeometry (item_pos, FSize(std::size_t(item_width), 1), false);
|
||||
item->setGeometry (item_pos, FSize(std::size_t(item_width), 1), false);
|
||||
|
||||
// set menu position
|
||||
if ( (*iter)->hasMenu() )
|
||||
(*iter)->getMenu()->setPos (item_pos, false);
|
||||
if ( item->hasMenu() )
|
||||
item->getMenu()->setPos (item_pos, false);
|
||||
|
||||
item_pos.x_ref() += item_width;
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenuBar::selectNextItem()
|
||||
{
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
auto list = getItemList();
|
||||
auto iter = list.begin();
|
||||
|
||||
while ( iter != last )
|
||||
while ( iter != list.end() )
|
||||
{
|
||||
if ( (*iter)->isSelected() )
|
||||
{
|
||||
@ -293,8 +295,8 @@ bool FMenuBar::selectNextItem()
|
||||
{
|
||||
++next_element;
|
||||
|
||||
if ( next_element == item_list.end() )
|
||||
next_element = item_list.begin();
|
||||
if ( next_element == list.end() )
|
||||
next_element = list.begin();
|
||||
|
||||
next = static_cast<FMenuItem*>(*next_element);
|
||||
} while ( ! next->isEnabled()
|
||||
@ -341,8 +343,8 @@ bool FMenuBar::selectNextItem()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenuBar::selectPrevItem()
|
||||
{
|
||||
auto iter = item_list.end();
|
||||
auto first = item_list.begin();
|
||||
auto list = getItemList();
|
||||
auto iter = list.end();
|
||||
|
||||
do
|
||||
{
|
||||
@ -355,8 +357,8 @@ bool FMenuBar::selectPrevItem()
|
||||
|
||||
do
|
||||
{
|
||||
if ( prev_element == item_list.begin() )
|
||||
prev_element = item_list.end();
|
||||
if ( prev_element == list.begin() )
|
||||
prev_element = list.end();
|
||||
|
||||
--prev_element;
|
||||
prev = static_cast<FMenuItem*>(*prev_element);
|
||||
@ -396,7 +398,7 @@ bool FMenuBar::selectPrevItem()
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ( iter != first );
|
||||
while ( iter != list.begin() );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -404,17 +406,17 @@ bool FMenuBar::selectPrevItem()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
|
||||
{
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
if ( (*iter)->isEnabled() )
|
||||
if ( item->isEnabled() )
|
||||
{
|
||||
uChar hotkey = (*iter)->getHotkey();
|
||||
FKey hotkey = item->getHotkey();
|
||||
FKey key = ev->key();
|
||||
|
||||
if ( fc::Fmkey_meta + FKey(std::tolower(hotkey)) == key )
|
||||
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
|
||||
hotkey -= 0xfee0;
|
||||
|
||||
if ( fc::Fmkey_meta + FKey(std::tolower(int(hotkey))) == key )
|
||||
{
|
||||
auto sel_item = getSelectedItem();
|
||||
|
||||
@ -423,13 +425,13 @@ bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
|
||||
|
||||
unselectItem();
|
||||
|
||||
if ( (*iter)->hasMenu() )
|
||||
if ( item->hasMenu() )
|
||||
{
|
||||
auto menu = (*iter)->getMenu();
|
||||
(*iter)->setSelected();
|
||||
setSelectedItem(*iter);
|
||||
(*iter)->setFocus();
|
||||
(*iter)->openMenu();
|
||||
auto menu = item->getMenu();
|
||||
item->setSelected();
|
||||
setSelectedItem(item);
|
||||
item->setFocus();
|
||||
item->openMenu();
|
||||
menu->selectFirstItem();
|
||||
auto first_item = menu->getSelectedItem();
|
||||
|
||||
@ -446,48 +448,21 @@ bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
|
||||
}
|
||||
else
|
||||
{
|
||||
setSelectedItem(0);
|
||||
setSelectedItem(nullptr);
|
||||
redraw();
|
||||
drop_down = false;
|
||||
(*iter)->processClicked();
|
||||
item->processClicked();
|
||||
}
|
||||
|
||||
ev->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t FMenuBar::getHotkeyPos ( wchar_t src[]
|
||||
, wchar_t dest[]
|
||||
, std::size_t length )
|
||||
{
|
||||
// find hotkey position in string
|
||||
// + generate a new string without the '&'-sign
|
||||
std::size_t hotkeypos = NOT_SET;
|
||||
wchar_t* txt = src;
|
||||
|
||||
for (std::size_t i = 0; i < length; i++)
|
||||
{
|
||||
if ( i < length && txt[i] == L'&' && hotkeypos == NOT_SET )
|
||||
{
|
||||
hotkeypos = i;
|
||||
i++;
|
||||
src++;
|
||||
}
|
||||
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
return hotkeypos;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::draw()
|
||||
{
|
||||
@ -497,7 +472,9 @@ void FMenuBar::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::drawItems()
|
||||
{
|
||||
if ( item_list.empty() )
|
||||
auto list = getItemList();
|
||||
|
||||
if ( list.empty() )
|
||||
return;
|
||||
|
||||
print() << FPoint(1, 1);
|
||||
@ -506,15 +483,10 @@ void FMenuBar::drawItems()
|
||||
setReverse(true);
|
||||
|
||||
screenWidth = getDesktopWidth();
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
std::size_t x = 1;
|
||||
std::size_t x{1};
|
||||
|
||||
while ( iter != last )
|
||||
{
|
||||
drawItem (*iter, x);
|
||||
++iter;
|
||||
}
|
||||
for (auto&& item : list)
|
||||
drawItem (item, x);
|
||||
|
||||
// Print spaces to end of line
|
||||
for (; x <= screenWidth; x++)
|
||||
@ -527,16 +499,15 @@ void FMenuBar::drawItems()
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
|
||||
{
|
||||
FString txt = menuitem->getText();
|
||||
menuText txtdata;
|
||||
std::size_t txt_length = txt.getLength();
|
||||
std::size_t to_char;
|
||||
std::size_t hotkeypos;
|
||||
bool is_enabled = menuitem->isEnabled();
|
||||
bool is_selected = menuitem->isSelected();
|
||||
|
||||
menuText txtdata{};
|
||||
txtdata.startpos = x + 1;
|
||||
txtdata.no_underline = menuitem->getFlags().no_underline;
|
||||
FString txt(menuitem->getText());
|
||||
std::size_t to_char{};
|
||||
std::size_t txt_length = txt.getLength();
|
||||
std::size_t column_width = getColumnWidth(txt);
|
||||
bool is_enabled = menuitem->isEnabled();
|
||||
bool is_selected = menuitem->isSelected();
|
||||
|
||||
// Set screen attributes
|
||||
setLineAttributes (menuitem);
|
||||
@ -557,26 +528,31 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
|
||||
else
|
||||
to_char = txt_length - screenWidth - x - 1;
|
||||
|
||||
hotkeypos = getHotkeyPos (txt.wc_str(), txtdata.text, txt_length);
|
||||
std::size_t hotkeypos = finalcut::getHotkeyPos ( txt.wc_str()
|
||||
, txtdata.text
|
||||
, txt_length );
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
{
|
||||
txt_length--;
|
||||
column_width--;
|
||||
to_char--;
|
||||
}
|
||||
|
||||
txtdata.length = to_char;
|
||||
x += txt_length;
|
||||
x += column_width;
|
||||
|
||||
if ( ! is_enabled || is_selected )
|
||||
txtdata.hotkeypos = NOT_SET;
|
||||
else
|
||||
txtdata.hotkeypos = hotkeypos;
|
||||
|
||||
setCursorToHotkeyPosition (menuitem, hotkeypos);
|
||||
drawMenuText (txtdata);
|
||||
drawEllipsis (txtdata, x);
|
||||
drawTrailingSpace (x);
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.menu_active_fg, wc.menu_active_bg);
|
||||
|
||||
if ( isMonochron() && is_enabled && is_selected )
|
||||
@ -590,6 +566,7 @@ inline void FMenuBar::setLineAttributes (FMenuItem* menuitem)
|
||||
{
|
||||
bool is_enabled = menuitem->isEnabled();
|
||||
bool is_selected = menuitem->isSelected();
|
||||
const auto& wc = getFWidgetColors();
|
||||
|
||||
if ( is_enabled )
|
||||
{
|
||||
@ -616,17 +593,36 @@ inline void FMenuBar::setLineAttributes (FMenuItem* menuitem)
|
||||
setColor();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenuBar::setCursorToHotkeyPosition ( FMenuItem* menuitem
|
||||
, std::size_t hotkeypos )
|
||||
{
|
||||
if ( ! menuitem->isSelected() )
|
||||
return;
|
||||
|
||||
if ( hotkeypos == NOT_SET )
|
||||
{
|
||||
// set cursor to the first character
|
||||
menuitem->setCursorPos (FPoint(2, 1));
|
||||
return;
|
||||
}
|
||||
|
||||
// set cursor to the hotkey position
|
||||
std::size_t x = getColumnWidth (menuitem->getText(), hotkeypos);
|
||||
menuitem->setCursorPos (FPoint(2 + int(x), 1));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenuBar::drawMenuText (menuText& data)
|
||||
{
|
||||
// Print menu text
|
||||
|
||||
for (std::size_t z = 0; z < data.length; z++)
|
||||
for (std::size_t z{0}; z < data.length; z++)
|
||||
{
|
||||
if ( data.startpos > screenWidth - z )
|
||||
break;
|
||||
|
||||
if ( ! std::iswprint(wint_t(data.text[z])) )
|
||||
if ( ! std::iswprint(std::wint_t(data.text[z])) )
|
||||
{
|
||||
if ( ! isNewFont()
|
||||
&& ( int(data.text[z]) < fc::NF_rev_left_arrow2
|
||||
@ -638,6 +634,7 @@ inline void FMenuBar::drawMenuText (menuText& data)
|
||||
|
||||
if ( z == data.hotkeypos )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg);
|
||||
|
||||
if ( ! data.no_underline )
|
||||
@ -702,17 +699,15 @@ void FMenuBar::adjustItems()
|
||||
{
|
||||
int item_X = 1;
|
||||
int item_Y = 1;
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
// get item width
|
||||
int item_width = int((*iter)->getWidth());
|
||||
int item_width = int(item->getWidth());
|
||||
|
||||
if ( (*iter)->hasMenu() )
|
||||
if ( item->hasMenu() )
|
||||
{
|
||||
auto menu = (*iter)->getMenu();
|
||||
auto menu = item->getMenu();
|
||||
|
||||
// set menu position
|
||||
menu->setPos (FPoint(menu->adjustX(item_X), item_Y));
|
||||
@ -722,7 +717,6 @@ void FMenuBar::adjustItems()
|
||||
}
|
||||
|
||||
item_X += item_width;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -794,7 +788,7 @@ bool FMenuBar::clickItem (FMenuItem* item)
|
||||
|
||||
if ( getSelectedItem() == item )
|
||||
{
|
||||
setSelectedItem(0);
|
||||
setSelectedItem(nullptr);
|
||||
leaveMenuBar();
|
||||
drop_down = false;
|
||||
item->processClicked();
|
||||
@ -814,40 +808,33 @@ void FMenuBar::unselectMenuItem (FMenuItem* item)
|
||||
drop_down = false;
|
||||
|
||||
if ( getSelectedItem() == item )
|
||||
setSelectedItem(0);
|
||||
setSelectedItem(nullptr);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::mouseDownOverList (const FMouseEvent* ev)
|
||||
{
|
||||
if ( item_list.empty() )
|
||||
auto list = getItemList();
|
||||
|
||||
if ( list.empty() )
|
||||
return;
|
||||
|
||||
focus_changed = false;
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : list)
|
||||
{
|
||||
int x1 = (*iter)->getX();
|
||||
int x2 = (*iter)->getX() + int((*iter)->getWidth());
|
||||
int x1 = item->getX();
|
||||
int x2 = item->getX() + int(item->getWidth());
|
||||
|
||||
if ( mouse_y == 1 )
|
||||
{
|
||||
if ( mouse_x >= x1 && mouse_x < x2 )
|
||||
{
|
||||
// Mouse pointer over item
|
||||
selectMenuItem (*iter);
|
||||
}
|
||||
selectMenuItem (item); // Mouse pointer over item
|
||||
else
|
||||
{
|
||||
unselectMenuItem (*iter);
|
||||
}
|
||||
unselectMenuItem (item);
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
if ( getStatusBar() )
|
||||
@ -868,39 +855,37 @@ void FMenuBar::mouseDownOverList (const FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::mouseUpOverList (const FMouseEvent* ev)
|
||||
{
|
||||
if ( item_list.empty() )
|
||||
auto list = getItemList();
|
||||
|
||||
if ( list.empty() )
|
||||
return;
|
||||
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : list)
|
||||
{
|
||||
int x1 = (*iter)->getX();
|
||||
int x2 = (*iter)->getX() + int((*iter)->getWidth());
|
||||
int x1 = item->getX();
|
||||
int x2 = item->getX() + int(item->getWidth());
|
||||
|
||||
if ( mouse_y == 1
|
||||
&& mouse_x >= x1
|
||||
&& mouse_x < x2
|
||||
&& (*iter)->isEnabled()
|
||||
&& (*iter)->isSelected() )
|
||||
&& item->isEnabled()
|
||||
&& item->isSelected() )
|
||||
{
|
||||
// Mouse pointer over item
|
||||
if ( ! activateMenu(*iter) )
|
||||
if ( ! activateMenu(item) )
|
||||
{
|
||||
if ( clickItem(*iter) )
|
||||
if ( clickItem(item) )
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unselectMenuItem(*iter);
|
||||
unselectMenuItem(item);
|
||||
redraw();
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
if ( ! hasSelectedItem() )
|
||||
@ -910,37 +895,37 @@ void FMenuBar::mouseUpOverList (const FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::mouseMoveOverList (const FMouseEvent* ev)
|
||||
{
|
||||
if ( item_list.empty() )
|
||||
auto list = getItemList();
|
||||
|
||||
if ( list.empty() )
|
||||
return;
|
||||
|
||||
focus_changed = false;
|
||||
bool mouse_over_menubar = false;
|
||||
auto iter = item_list.begin();
|
||||
auto last = item_list.end();
|
||||
bool mouse_over_menubar{false};
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
if ( getTermGeometry().contains(ev->getTermPos()) )
|
||||
mouse_over_menubar = true;
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& item : list)
|
||||
{
|
||||
int x1 = (*iter)->getX();
|
||||
int x2 = (*iter)->getX() + int((*iter)->getWidth());
|
||||
int x1 = item->getX();
|
||||
int x2 = item->getX() + int(item->getWidth());
|
||||
|
||||
if ( mouse_x >= x1
|
||||
&& mouse_x < x2
|
||||
&& mouse_y == 1 )
|
||||
{
|
||||
// Mouse pointer over item
|
||||
selectMenuItem(*iter);
|
||||
selectMenuItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mouse_over_menubar )
|
||||
{
|
||||
// Unselect selected item without mouse focus
|
||||
unselectMenuItem(*iter);
|
||||
unselectMenuItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -948,8 +933,6 @@ void FMenuBar::mouseMoveOverList (const FMouseEvent* ev)
|
||||
passEventToMenu(ev);
|
||||
}
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
if ( getStatusBar() )
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fdialog.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/fmenu.h"
|
||||
#include "final/fmenubar.h"
|
||||
#include "final/fmenulist.h"
|
||||
@ -93,7 +94,7 @@ bool FMenuItem::setEnable (bool enable)
|
||||
if ( super && isMenuBar(super) )
|
||||
{
|
||||
// Meta + hotkey
|
||||
super->addAccelerator ( fc::Fmkey_meta + FKey(std::tolower(hotkey))
|
||||
super->addAccelerator ( fc::Fmkey_meta + FKey(std::tolower(int(hotkey)))
|
||||
, this );
|
||||
}
|
||||
}
|
||||
@ -187,12 +188,16 @@ void FMenuItem::unsetSelected()
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::setText (const FString& txt)
|
||||
{
|
||||
text = txt;
|
||||
text.setString(txt);
|
||||
text_length = text.getLength();
|
||||
hotkey = hotKey();
|
||||
text_width = getColumnWidth(txt);
|
||||
hotkey = finalcut::getHotkey(text);
|
||||
|
||||
if ( hotkey )
|
||||
{
|
||||
text_length--;
|
||||
text_width--;
|
||||
}
|
||||
|
||||
updateSuperMenuDimensions();
|
||||
}
|
||||
@ -203,10 +208,10 @@ void FMenuItem::addAccelerator (FKey key, FWidget* obj)
|
||||
auto root = getRootWidget();
|
||||
accelerator accel = { key, obj };
|
||||
|
||||
if ( root && root->accelerator_list )
|
||||
if ( root && root->getAcceleratorList() )
|
||||
{
|
||||
accel_key = key;
|
||||
root->accelerator_list->push_back(accel);
|
||||
root->getAcceleratorList()->push_back(accel);
|
||||
}
|
||||
|
||||
updateSuperMenuDimensions();
|
||||
@ -218,17 +223,17 @@ void FMenuItem::delAccelerator (FWidget* obj)
|
||||
auto root = getRootWidget();
|
||||
|
||||
if ( root
|
||||
&& root->accelerator_list
|
||||
&& ! root->accelerator_list->empty() )
|
||||
&& root->getAcceleratorList()
|
||||
&& ! root->getAcceleratorList()->empty() )
|
||||
{
|
||||
auto iter = root->accelerator_list->begin();
|
||||
auto iter = root->getAcceleratorList()->begin();
|
||||
|
||||
while ( iter != root->accelerator_list->end() )
|
||||
while ( iter != root->getAcceleratorList()->end() )
|
||||
{
|
||||
if ( iter->object == obj )
|
||||
{
|
||||
accel_key = 0;
|
||||
iter = root->accelerator_list->erase(iter);
|
||||
iter = root->getAcceleratorList()->erase(iter);
|
||||
}
|
||||
else
|
||||
++iter;
|
||||
@ -414,7 +419,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
|
||||
mbar->getSelectedItem()->unsetSelected();
|
||||
|
||||
setSelected();
|
||||
mbar->selected_item = this;
|
||||
mbar->setSelectedItem(this);
|
||||
openMenu();
|
||||
auto focused_widget = static_cast<FWidget*>(ev->focusedWidget());
|
||||
menu->unselectItem();
|
||||
@ -437,7 +442,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
|
||||
else
|
||||
{
|
||||
unsetSelected();
|
||||
mbar->selected_item = nullptr;
|
||||
mbar->unsetSelectedItem();
|
||||
mbar->redraw();
|
||||
processClicked();
|
||||
mbar->drop_down = false;
|
||||
@ -501,7 +506,7 @@ bool FMenuItem::isMenu (FWidget* w) const
|
||||
//----------------------------------------------------------------------
|
||||
FMenuList* FMenuItem::getFMenuList (FWidget& widget)
|
||||
{
|
||||
FMenuList* menu_list;
|
||||
FMenuList* menu_list{};
|
||||
|
||||
if ( isMenu(&widget) )
|
||||
{
|
||||
@ -523,12 +528,19 @@ FMenuList* FMenuItem::getFMenuList (FWidget& widget)
|
||||
void FMenuItem::init (FWidget* parent)
|
||||
{
|
||||
text_length = text.getLength();
|
||||
hotkey = hotKey();
|
||||
text_width = getColumnWidth(text);
|
||||
hotkey = finalcut::getHotkey(text);
|
||||
|
||||
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
|
||||
hotkey -= 0xfee0;
|
||||
|
||||
if ( hotkey )
|
||||
{
|
||||
text_length--;
|
||||
text_width--;
|
||||
}
|
||||
|
||||
setGeometry (FPoint(1, 1), FSize(text_length + 2, 1), false);
|
||||
setGeometry (FPoint(1, 1), FSize(text_width + 2, 1), false);
|
||||
|
||||
if ( ! parent )
|
||||
return;
|
||||
@ -549,7 +561,7 @@ void FMenuItem::init (FWidget* parent)
|
||||
menubar_ptr->calculateDimensions();
|
||||
|
||||
if ( hotkey ) // Meta + hotkey
|
||||
menubar_ptr->addAccelerator ( fc::Fmkey_meta + FKey(std::tolower(hotkey))
|
||||
menubar_ptr->addAccelerator ( fc::Fmkey_meta + FKey(std::tolower(int(hotkey)))
|
||||
, this );
|
||||
|
||||
addCallback // for this element
|
||||
@ -565,32 +577,6 @@ void FMenuItem::init (FWidget* parent)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
uChar FMenuItem::hotKey()
|
||||
{
|
||||
std::size_t length;
|
||||
|
||||
if ( text.isEmpty() )
|
||||
return 0;
|
||||
|
||||
length = text.getLength();
|
||||
|
||||
for (std::size_t i = 0; i < length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( i + 1 < length && text[i] == '&' )
|
||||
return uChar(text[++i]);
|
||||
}
|
||||
catch (const std::out_of_range&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::updateSuperMenuDimensions()
|
||||
{
|
||||
@ -598,9 +584,7 @@ void FMenuItem::updateSuperMenuDimensions()
|
||||
return;
|
||||
|
||||
auto menu_ptr = static_cast<FMenu*>(super_menu);
|
||||
|
||||
if ( menu_ptr )
|
||||
menu_ptr->calculateDimensions();
|
||||
menu_ptr->calculateDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -620,18 +604,18 @@ void FMenuItem::createDialogList (FMenu* winmenu)
|
||||
{
|
||||
winmenu->clear();
|
||||
|
||||
if ( dialog_list && ! dialog_list->empty() )
|
||||
if ( getDialogList() && ! getDialogList()->empty() )
|
||||
{
|
||||
auto first = dialog_list->begin();
|
||||
auto first = getDialogList()->begin();
|
||||
auto iter = first;
|
||||
|
||||
while ( iter != dialog_list->end() && *iter )
|
||||
while ( iter != getDialogList()->end() && *iter )
|
||||
{
|
||||
auto win = static_cast<FDialog*>(*iter);
|
||||
|
||||
if ( win )
|
||||
{
|
||||
FMenuItem* win_item;
|
||||
FMenuItem* win_item{};
|
||||
uInt32 n = uInt32(std::distance(first, iter));
|
||||
// get the dialog title
|
||||
const auto& name = win->getText();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2018 Markus Gans *
|
||||
* Copyright 2015-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -22,7 +22,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fmenulist.h"
|
||||
#include "final/fmenuitem.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -44,7 +46,7 @@ FMenuList::~FMenuList() // destructor
|
||||
|
||||
while ( iter != item_list.end() )
|
||||
{
|
||||
(*iter)->setSuperMenu(0);
|
||||
(*iter)->setSuperMenu(nullptr);
|
||||
iter = item_list.erase(iter);
|
||||
}
|
||||
}
|
||||
@ -72,7 +74,7 @@ void FMenuList::remove (FMenuItem* i)
|
||||
if ( (*iter) == i )
|
||||
{
|
||||
iter = item_list.erase(iter);
|
||||
i->setSuperMenu(0);
|
||||
i->setSuperMenu(nullptr);
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -93,6 +95,7 @@ void FMenuList::remove (int pos)
|
||||
void FMenuList::clear()
|
||||
{
|
||||
item_list.clear();
|
||||
item_list.shrink_to_fit();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -128,7 +131,7 @@ void FMenuList::unselectItem()
|
||||
if ( hasSelectedItem() )
|
||||
getSelectedItem()->unsetSelected();
|
||||
|
||||
setSelectedItem(0);
|
||||
setSelectedItem(nullptr);
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fbutton.h"
|
||||
#include "final/fmessagebox.h"
|
||||
|
||||
namespace finalcut
|
||||
@ -60,12 +61,11 @@ FMessageBox::FMessageBox (const FMessageBox& mbox)
|
||||
, headline_text(mbox.headline_text)
|
||||
, text(mbox.text)
|
||||
, text_components(mbox.text_components)
|
||||
, text_split(mbox.text_split)
|
||||
, max_line_width(mbox.max_line_width)
|
||||
, center_text(mbox.center_text)
|
||||
, emphasis_color(mbox.emphasis_color)
|
||||
, num_buttons(mbox.num_buttons)
|
||||
, text_num_lines(mbox.text_num_lines)
|
||||
, center_text(mbox.center_text)
|
||||
{
|
||||
setTitlebarText (mbox.getTitlebarText());
|
||||
init ( mbox.button_digit[0]
|
||||
@ -104,7 +104,7 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uInt n = 0; n < num_buttons; n++)
|
||||
for (uInt n{0}; n < num_buttons; n++)
|
||||
delete button[n];
|
||||
|
||||
if ( mbox.getParentWidget() )
|
||||
@ -113,7 +113,6 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
|
||||
headline_text = mbox.headline_text;
|
||||
text = mbox.text;
|
||||
text_components = mbox.text_components;
|
||||
text_split = mbox.text_split;
|
||||
max_line_width = mbox.max_line_width;
|
||||
center_text = mbox.center_text;
|
||||
emphasis_color = mbox.emphasis_color;
|
||||
@ -132,22 +131,22 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::setHeadline (const FString& headline)
|
||||
{
|
||||
headline_text = headline;
|
||||
headline_text.setString(headline);
|
||||
setHeight(getHeight() + 2, true);
|
||||
|
||||
for (uInt n = 0; n < num_buttons; n++)
|
||||
for (uInt n{0}; n < num_buttons; n++)
|
||||
button[n]->setY (int(getHeight()) - 4, false);
|
||||
|
||||
std::size_t len = headline_text.getLength();
|
||||
std::size_t column_width = getColumnWidth(headline_text);
|
||||
|
||||
if ( len > max_line_width )
|
||||
max_line_width = len;
|
||||
if ( column_width > max_line_width )
|
||||
max_line_width = column_width;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::setText (const FString& txt)
|
||||
{
|
||||
text = txt;
|
||||
text.setString(txt);
|
||||
calculateDimensions();
|
||||
button[0]->setY (int(getHeight()) - 4, false);
|
||||
|
||||
@ -165,8 +164,8 @@ void FMessageBox::setText (const FString& txt)
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::adjustSize()
|
||||
{
|
||||
std::size_t max_width;
|
||||
std::size_t max_height;
|
||||
std::size_t max_width{};
|
||||
std::size_t max_height{};
|
||||
auto root_widget = getRootWidget();
|
||||
|
||||
if ( root_widget )
|
||||
@ -267,7 +266,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMessageBox::deallocation()
|
||||
{
|
||||
for (uInt n = 0; n < num_buttons; n++)
|
||||
for (uInt n{0}; n < num_buttons; n++)
|
||||
delete button[n];
|
||||
}
|
||||
|
||||
@ -308,11 +307,11 @@ inline void FMessageBox::initCallbacks()
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::calculateDimensions()
|
||||
{
|
||||
FSize size;
|
||||
FSize size{};
|
||||
std::size_t headline_height{0};
|
||||
text_split = text.split("\n");
|
||||
text_components = text.split("\n");
|
||||
max_line_width = 0;
|
||||
text_num_lines = uInt(text_split.size());
|
||||
text_num_lines = std::size_t(text_components.size());
|
||||
|
||||
if ( text_num_lines == 0 )
|
||||
return;
|
||||
@ -320,13 +319,12 @@ void FMessageBox::calculateDimensions()
|
||||
if ( ! headline_text.isNull() )
|
||||
headline_height = 2;
|
||||
|
||||
for (uInt i = 0; i < text_num_lines; i++)
|
||||
for (auto&& line : text_components)
|
||||
{
|
||||
text_components = &text_split[0];
|
||||
std::size_t len = text_components[i].getLength();
|
||||
std::size_t column_width = getColumnWidth(line);
|
||||
|
||||
if ( len > max_line_width )
|
||||
max_line_width = len;
|
||||
if ( column_width > max_line_width )
|
||||
max_line_width = column_width;
|
||||
}
|
||||
|
||||
size.setHeight (text_num_lines + 8 + headline_height);
|
||||
@ -343,21 +341,22 @@ void FMessageBox::draw()
|
||||
{
|
||||
FDialog::draw();
|
||||
|
||||
int head_offset = 0;
|
||||
int center_x = 0;
|
||||
int y{0};
|
||||
int head_offset{0};
|
||||
int center_x{0};
|
||||
// center the whole block
|
||||
int msg_x = int((getWidth() - max_line_width) / 2);
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( ! headline_text.isNull() )
|
||||
if ( ! headline_text.isEmpty() )
|
||||
{
|
||||
setColor(emphasis_color, getBackgroundColor());
|
||||
std::size_t headline_length = headline_text.getLength();
|
||||
std::size_t headline_width = getColumnWidth(headline_text);
|
||||
|
||||
if ( center_text ) // center one line
|
||||
center_x = int((max_line_width - headline_length) / 2);
|
||||
center_x = int((max_line_width - headline_width) / 2);
|
||||
|
||||
print() << FPoint(1 + msg_x + center_x, 4) << headline_text;
|
||||
head_offset = 2;
|
||||
@ -365,15 +364,16 @@ void FMessageBox::draw()
|
||||
|
||||
setColor();
|
||||
|
||||
for (int i = 0; i < int(text_num_lines); i++)
|
||||
for (auto&& line : text_components)
|
||||
{
|
||||
std::size_t line_length = text_components[i].getLength();
|
||||
std::size_t line_width = getColumnWidth(line);
|
||||
|
||||
if ( center_text ) // center one line
|
||||
center_x = int((max_line_width - line_length) / 2);
|
||||
center_x = int((max_line_width - line_width) / 2);
|
||||
|
||||
print() << FPoint(1 + msg_x + center_x, 4 + head_offset + i)
|
||||
<< text_components[i];
|
||||
print() << FPoint(1 + msg_x + center_x, 4 + head_offset + y)
|
||||
<< line;
|
||||
y++;
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
@ -383,9 +383,9 @@ void FMessageBox::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::resizeButtons()
|
||||
{
|
||||
std::size_t len[3], max_size;
|
||||
std::size_t len[3]{}, max_size{};
|
||||
|
||||
for (std::size_t n = 0; n < num_buttons; n++)
|
||||
for (std::size_t n{0}; n < num_buttons; n++)
|
||||
{
|
||||
len[n] = button[n]->getText().getLength();
|
||||
|
||||
@ -407,7 +407,7 @@ void FMessageBox::resizeButtons()
|
||||
if ( max_size < 7 )
|
||||
max_size = 7;
|
||||
|
||||
for (std::size_t n = 0; n < num_buttons; n++)
|
||||
for (std::size_t n{0}; n < num_buttons; n++)
|
||||
button[n]->setWidth(max_size + 3, false);
|
||||
}
|
||||
|
||||
@ -415,9 +415,9 @@ void FMessageBox::resizeButtons()
|
||||
void FMessageBox::adjustButtons()
|
||||
{
|
||||
static constexpr std::size_t gap = 4;
|
||||
std::size_t btn_width = 0;
|
||||
std::size_t btn_width{0};
|
||||
|
||||
for (std::size_t n = 0; n < num_buttons; n++)
|
||||
for (std::size_t n{0}; n < num_buttons; n++)
|
||||
{
|
||||
if ( n == num_buttons - 1 )
|
||||
btn_width += button[n]->getWidth();
|
||||
@ -425,7 +425,7 @@ void FMessageBox::adjustButtons()
|
||||
btn_width += button[n]->getWidth() + gap;
|
||||
}
|
||||
|
||||
if ( btn_width >= getWidth() - 4 )
|
||||
if ( btn_width + 4 >= getWidth() )
|
||||
{
|
||||
std::size_t max_width;
|
||||
auto root_widget = getRootWidget();
|
||||
@ -436,7 +436,7 @@ void FMessageBox::adjustButtons()
|
||||
|
||||
int btn_x = int((getWidth() - btn_width) / 2);
|
||||
|
||||
for (std::size_t n = 0; n < num_buttons; n++)
|
||||
for (std::size_t n{0}; n < num_buttons; n++)
|
||||
{
|
||||
if ( n == 0 )
|
||||
button[n]->setX(btn_x);
|
||||
|
453
src/fmouse.cpp
453
src/fmouse.cpp
@ -27,9 +27,13 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "final/fconfig.h"
|
||||
#include "final/fkeyboard.h"
|
||||
#include "final/fmouse.h"
|
||||
#include "final/fobject.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermxterminal.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -42,11 +46,8 @@ namespace finalcut
|
||||
//----------------------------------------------------------------------
|
||||
FMouse::FMouse()
|
||||
{
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
|
||||
// init bit field with 0
|
||||
std::memset(&b_state, 0x00, sizeof(b_state));
|
||||
resetMousePressedTime();
|
||||
clearButtonState();
|
||||
}
|
||||
|
||||
|
||||
@ -96,78 +97,78 @@ inline bool FMouse::hasEvent()
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isLeftButtonPressed()
|
||||
{
|
||||
return bool(b_state.left_button == Pressed);
|
||||
return bool(getButtonState().left_button == Pressed);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isLeftButtonReleased()
|
||||
{
|
||||
return bool(b_state.left_button == Released);
|
||||
return bool(getButtonState().left_button == Released);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isLeftButtonDoubleClick()
|
||||
{
|
||||
return bool(b_state.left_button == DoubleClick);
|
||||
return bool(getButtonState().left_button == DoubleClick);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isRightButtonPressed()
|
||||
{
|
||||
return bool(b_state.right_button == Pressed);
|
||||
return bool(getButtonState().right_button == Pressed);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isRightButtonReleased()
|
||||
{
|
||||
return bool(b_state.right_button == Released);
|
||||
return bool(getButtonState().right_button == Released);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isMiddleButtonPressed()
|
||||
{
|
||||
return bool(b_state.middle_button == Pressed);
|
||||
return bool(getButtonState().middle_button == Pressed);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isMiddleButtonReleased()
|
||||
{
|
||||
return bool(b_state.middle_button == Released);
|
||||
return bool(getButtonState().middle_button == Released);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isShiftKeyPressed()
|
||||
{
|
||||
return bool(b_state.shift_button);
|
||||
return bool(getButtonState().shift_button);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isControlKeyPressed()
|
||||
{
|
||||
return bool(b_state.control_button);
|
||||
return bool(getButtonState().control_button);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isMetaKeyPressed()
|
||||
{
|
||||
return bool(b_state.meta_button);
|
||||
return bool(getButtonState().meta_button);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isWheelUp()
|
||||
{
|
||||
return bool(b_state.wheel_up);
|
||||
return bool(getButtonState().wheel_up);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isWheelDown()
|
||||
{
|
||||
return bool(b_state.wheel_down);
|
||||
return bool(getButtonState().wheel_down);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::isMoved()
|
||||
{
|
||||
return bool(b_state.mouse_moved);
|
||||
return bool(getButtonState().mouse_moved);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -204,14 +205,88 @@ inline FMouse* FMouse::createMouseObject (mouse_type mt)
|
||||
return new FMouseX11;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::clearButtonState()
|
||||
{
|
||||
// Fill bit field with 0
|
||||
std::memset(&b_state, 0x00, sizeof(b_state));
|
||||
}
|
||||
|
||||
|
||||
// protected methods of FMouse
|
||||
//----------------------------------------------------------------------
|
||||
inline FMouse::button& FMouse::getButtonState()
|
||||
{
|
||||
return b_state;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FPoint& FMouse::getNewPos()
|
||||
{
|
||||
return new_mouse_position;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
uInt16 FMouse::getMaxWidth()
|
||||
{
|
||||
return max_width;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
uInt16 FMouse::getMaxHeight()
|
||||
{
|
||||
return max_height;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
uInt64 FMouse::getDblclickInterval()
|
||||
{
|
||||
return dblclick_interval;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
timeval* FMouse::getMousePressedTime()
|
||||
{
|
||||
return &time_mousepressed;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::setPos (const FPoint& m)
|
||||
{
|
||||
mouse = m;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::setNewPos (int x, int y)
|
||||
{
|
||||
new_mouse_position.setPoint (x, y);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::setPending (bool is_pending)
|
||||
{
|
||||
input_data_pending = is_pending;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::setMousePressedTime (timeval* time)
|
||||
{
|
||||
time_mousepressed = *time;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::resetMousePressedTime()
|
||||
{
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::setEvent()
|
||||
{
|
||||
mouse_event_occurred = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouse::isDblclickTimeout (timeval* time)
|
||||
{
|
||||
@ -263,8 +338,7 @@ void FMouseGPM::setRawData (FKeyboard::keybuffer&)
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseGPM::processEvent (struct timeval*)
|
||||
{
|
||||
// Fill bit field with 0
|
||||
std::memset(&b_state, 0x00, sizeof(b_state));
|
||||
clearButtonState();
|
||||
|
||||
if ( Gpm_GetEvent(&gpm_ev) == 1 )
|
||||
{
|
||||
@ -274,17 +348,17 @@ void FMouseGPM::processEvent (struct timeval*)
|
||||
{
|
||||
GPM_DRAWPOINTER(&gpm_ev);
|
||||
has_gpm_mouse_data = false;
|
||||
mouse_event_occurred = false;
|
||||
clearEvent();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( gpm_ev.type & GPM_DRAG && gpm_ev.wdx == 0 && gpm_ev.wdy == 0 )
|
||||
b_state.mouse_moved = true;
|
||||
getButtonState().mouse_moved = true;
|
||||
|
||||
if ( gpm_ev.wdy > 0 )
|
||||
b_state.wheel_up = true;
|
||||
getButtonState().wheel_up = true;
|
||||
else if ( gpm_ev.wdy < 0 )
|
||||
b_state.wheel_down = true;
|
||||
getButtonState().wheel_down = true;
|
||||
|
||||
switch ( gpm_ev.type & 0x0f )
|
||||
{
|
||||
@ -305,20 +379,20 @@ void FMouseGPM::processEvent (struct timeval*)
|
||||
, std::max(gpm_ev.y, sInt16(1)) ));
|
||||
|
||||
if ( gpmEvent(false) == mouse_event )
|
||||
input_data_pending = true;
|
||||
setPending(true);
|
||||
else
|
||||
input_data_pending = false;
|
||||
setPending(false);
|
||||
|
||||
GPM_DRAWPOINTER(&gpm_ev);
|
||||
has_gpm_mouse_data = false;
|
||||
mouse_event_occurred = true;
|
||||
setEvent();
|
||||
return;
|
||||
}
|
||||
else
|
||||
gpm_fd = -1;
|
||||
|
||||
has_gpm_mouse_data = false;
|
||||
mouse_event_occurred = false;
|
||||
clearEvent();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -371,51 +445,51 @@ void FMouseGPM::interpretKeyDown()
|
||||
if ( gpm_ev.buttons & GPM_B_LEFT )
|
||||
{
|
||||
if ( gpm_ev.type & GPM_DOUBLE )
|
||||
b_state.left_button = DoubleClick;
|
||||
getButtonState().left_button = DoubleClick;
|
||||
else
|
||||
b_state.left_button = Pressed;
|
||||
getButtonState().left_button = Pressed;
|
||||
}
|
||||
|
||||
if ( gpm_ev.buttons & GPM_B_MIDDLE )
|
||||
b_state.middle_button = Pressed;
|
||||
getButtonState().middle_button = Pressed;
|
||||
|
||||
if ( gpm_ev.buttons & GPM_B_RIGHT )
|
||||
b_state.right_button = Pressed;
|
||||
getButtonState().right_button = Pressed;
|
||||
|
||||
if ( gpm_ev.buttons & GPM_B_UP )
|
||||
b_state.wheel_up = true;
|
||||
getButtonState().wheel_up = true;
|
||||
|
||||
if ( gpm_ev.buttons & GPM_B_DOWN )
|
||||
b_state.wheel_down = true;
|
||||
getButtonState().wheel_down = true;
|
||||
|
||||
// Keyboard modifiers
|
||||
if ( gpm_ev.modifiers & (1 << KG_SHIFT) )
|
||||
b_state.shift_button = true;
|
||||
getButtonState().shift_button = true;
|
||||
|
||||
if ( gpm_ev.modifiers & ((1 << KG_ALT) | (1 << KG_ALTGR)) )
|
||||
b_state.meta_button = true;
|
||||
getButtonState().meta_button = true;
|
||||
|
||||
if ( gpm_ev.modifiers & (1 << KG_CTRL) )
|
||||
b_state.control_button = true;
|
||||
getButtonState().control_button = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseGPM::interpretKeyUp()
|
||||
{
|
||||
if ( gpm_ev.buttons & GPM_B_LEFT )
|
||||
b_state.left_button = Released;
|
||||
getButtonState().left_button = Released;
|
||||
|
||||
if ( gpm_ev.buttons & GPM_B_MIDDLE )
|
||||
b_state.middle_button = Released;
|
||||
getButtonState().middle_button = Released;
|
||||
|
||||
if ( gpm_ev.buttons & GPM_B_RIGHT )
|
||||
b_state.right_button = Released;
|
||||
getButtonState().right_button = Released;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseGPM::getGpmKeyPressed (bool pending)
|
||||
bool FMouseGPM::getGpmKeyPressed (bool is_pending)
|
||||
{
|
||||
input_data_pending = pending;
|
||||
setPending(is_pending);
|
||||
has_gpm_mouse_data = false;
|
||||
int type = gpmEvent();
|
||||
|
||||
@ -445,17 +519,16 @@ void FMouseGPM::drawGpmPointer()
|
||||
//----------------------------------------------------------------------
|
||||
int FMouseGPM::gpmEvent (bool clear)
|
||||
{
|
||||
int result;
|
||||
int max = ( gpm_fd > stdin_no ) ? gpm_fd : stdin_no;
|
||||
fd_set ifds;
|
||||
struct timeval tv;
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
|
||||
FD_ZERO(&ifds);
|
||||
FD_SET(stdin_no, &ifds);
|
||||
FD_SET(gpm_fd, &ifds);
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 100000; // 100 ms
|
||||
result = select (max + 1, &ifds, 0, 0, &tv);
|
||||
int result = select (max + 1, &ifds, 0, 0, &tv);
|
||||
|
||||
if ( result > 0 && FD_ISSET(stdin_no, &ifds) )
|
||||
{
|
||||
@ -499,8 +572,8 @@ void FMouseX11::setRawData (FKeyboard::keybuffer& fifo_buf)
|
||||
// Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data
|
||||
|
||||
static constexpr std::size_t len = 6;
|
||||
std::size_t fifo_buf_size = sizeof(fifo_buf);
|
||||
std::size_t n;
|
||||
std::size_t fifo_buf_size{sizeof(fifo_buf)};
|
||||
std::size_t n{};
|
||||
x11_mouse[0] = fifo_buf[3];
|
||||
x11_mouse[1] = fifo_buf[4];
|
||||
x11_mouse[2] = fifo_buf[5];
|
||||
@ -516,7 +589,7 @@ void FMouseX11::setRawData (FKeyboard::keybuffer& fifo_buf)
|
||||
for (; n < fifo_buf_size; n++)
|
||||
fifo_buf[n] = '\0';
|
||||
|
||||
input_data_pending = bool(fifo_buf[0] != '\0');
|
||||
setPending(bool(fifo_buf[0] != '\0'));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -525,30 +598,26 @@ void FMouseX11::processEvent (struct timeval* time)
|
||||
// Parse and interpret the X11 xterm mouse string
|
||||
|
||||
const auto& mouse_position = getPos();
|
||||
uChar x, y;
|
||||
int btn;
|
||||
|
||||
x = uChar(x11_mouse[1] - 0x20);
|
||||
y = uChar(x11_mouse[2] - 0x20);
|
||||
btn = x11_mouse[0];
|
||||
new_mouse_position.setPoint (x, y);
|
||||
// Fill bit field with 0
|
||||
std::memset(&b_state, 0x00, sizeof(b_state));
|
||||
uChar x = uChar(x11_mouse[1] - 0x20);
|
||||
uChar y = uChar(x11_mouse[2] - 0x20);
|
||||
int btn = x11_mouse[0];
|
||||
setNewPos (x, y);
|
||||
clearButtonState();
|
||||
setKeyState (btn);
|
||||
setMoveState (mouse_position, btn);
|
||||
setButtonState (btn & button_mask, time);
|
||||
|
||||
if ( new_mouse_position == mouse_position
|
||||
if ( mouse_position == getNewPos()
|
||||
&& ! isWheelUp()
|
||||
&& ! isWheelDown()
|
||||
&& uChar(btn) == x11_button_state )
|
||||
{
|
||||
mouse_event_occurred = false;
|
||||
clearEvent();
|
||||
x11_mouse[0] = '\0'; // Delete already interpreted data
|
||||
return;
|
||||
}
|
||||
|
||||
mouse_event_occurred = true;
|
||||
setEvent();
|
||||
setPos (FPoint(x, y));
|
||||
// Get the button state from string
|
||||
x11_button_state = uChar(btn);
|
||||
@ -562,13 +631,13 @@ void FMouseX11::processEvent (struct timeval* time)
|
||||
void FMouseX11::setKeyState (int btn)
|
||||
{
|
||||
if ( (btn & key_shift) == key_shift )
|
||||
b_state.shift_button = Pressed;
|
||||
getButtonState().shift_button = Pressed;
|
||||
|
||||
if ( (btn & key_meta) == key_meta )
|
||||
b_state.meta_button = Pressed;
|
||||
getButtonState().meta_button = Pressed;
|
||||
|
||||
if ( (btn & key_ctrl) == key_ctrl )
|
||||
b_state.control_button = Pressed;
|
||||
getButtonState().control_button = Pressed;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -578,7 +647,7 @@ void FMouseX11::setMoveState (const FPoint& mouse_position, int btn)
|
||||
&& (btn & button_mask) <= button3_pressed_move
|
||||
&& ! mouse_position.isOrigin() )
|
||||
{
|
||||
b_state.mouse_moved = true;
|
||||
getButtonState().mouse_moved = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -593,33 +662,30 @@ void FMouseX11::setButtonState (int btn, struct timeval* time)
|
||||
{
|
||||
case button1_pressed:
|
||||
case button1_pressed_move:
|
||||
if ( mouse_position == new_mouse_position
|
||||
if ( mouse_position == getNewPos()
|
||||
&& x11_button_state == all_buttons_released
|
||||
&& ! isDblclickTimeout(&time_mousepressed) )
|
||||
&& ! isDblclickTimeout(getMousePressedTime()) )
|
||||
{
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.left_button = DoubleClick;
|
||||
resetMousePressedTime();
|
||||
getButtonState().left_button = DoubleClick;
|
||||
}
|
||||
else
|
||||
{
|
||||
time_mousepressed = *time; // save click time
|
||||
b_state.left_button = Pressed;
|
||||
setMousePressedTime (time); // save click time
|
||||
getButtonState().left_button = Pressed;
|
||||
}
|
||||
break;
|
||||
|
||||
case button2_pressed:
|
||||
case button2_pressed_move:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.middle_button = Pressed;
|
||||
resetMousePressedTime();
|
||||
getButtonState().middle_button = Pressed;
|
||||
break;
|
||||
|
||||
case button3_pressed:
|
||||
case button3_pressed_move:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.right_button = Pressed;
|
||||
resetMousePressedTime();
|
||||
getButtonState().right_button = Pressed;
|
||||
break;
|
||||
|
||||
case all_buttons_released:
|
||||
@ -627,17 +693,17 @@ void FMouseX11::setButtonState (int btn, struct timeval* time)
|
||||
{
|
||||
case button1_pressed:
|
||||
case button1_pressed_move:
|
||||
b_state.left_button = Released;
|
||||
getButtonState().left_button = Released;
|
||||
break;
|
||||
|
||||
case button2_pressed:
|
||||
case button2_pressed_move:
|
||||
b_state.middle_button = Released;
|
||||
getButtonState().middle_button = Released;
|
||||
break;
|
||||
|
||||
case button3_pressed:
|
||||
case button3_pressed_move:
|
||||
b_state.right_button = Released;
|
||||
getButtonState().right_button = Released;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -646,15 +712,13 @@ void FMouseX11::setButtonState (int btn, struct timeval* time)
|
||||
break;
|
||||
|
||||
case button_up:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.wheel_up = Pressed;
|
||||
resetMousePressedTime();
|
||||
getButtonState().wheel_up = Pressed;
|
||||
break;
|
||||
|
||||
case button_down:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.wheel_down = Pressed;
|
||||
resetMousePressedTime();
|
||||
getButtonState().wheel_down = Pressed;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -687,7 +751,7 @@ void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
|
||||
|
||||
std::size_t fifo_buf_size = sizeof(fifo_buf);
|
||||
std::size_t len = std::strlen(fifo_buf);
|
||||
std::size_t n = 3;
|
||||
std::size_t n{3};
|
||||
|
||||
while ( n < len && n <= MOUSE_BUF_SIZE + 1 )
|
||||
{
|
||||
@ -708,29 +772,25 @@ void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
|
||||
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
|
||||
fifo_buf[n] = '\0';
|
||||
|
||||
input_data_pending = bool(fifo_buf[0] != '\0');
|
||||
setPending(bool(fifo_buf[0] != '\0'));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseSGR::processEvent (struct timeval* time)
|
||||
{
|
||||
const auto& mouse_position = getPos();
|
||||
char* p;
|
||||
int btn;
|
||||
uInt16 x, y;
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
btn = 0;
|
||||
uInt16 x{0};
|
||||
uInt16 y{0};
|
||||
int btn{0};
|
||||
|
||||
// parse the SGR mouse string
|
||||
p = sgr_mouse;
|
||||
char* p = sgr_mouse;
|
||||
|
||||
while ( *p && *p != ';' )
|
||||
{
|
||||
if ( *p < '0' || *p > '9')
|
||||
{
|
||||
mouse_event_occurred = false;
|
||||
clearEvent();
|
||||
sgr_mouse[0] = '\0'; // Delete already interpreted data
|
||||
return;
|
||||
}
|
||||
@ -743,7 +803,7 @@ void FMouseSGR::processEvent (struct timeval* time)
|
||||
{
|
||||
if ( *p < '0' || *p > '9')
|
||||
{
|
||||
mouse_event_occurred = false;
|
||||
clearEvent();
|
||||
sgr_mouse[0] = '\0'; // Delete already interpreted data
|
||||
return;
|
||||
}
|
||||
@ -755,7 +815,7 @@ void FMouseSGR::processEvent (struct timeval* time)
|
||||
{
|
||||
if ( *p < '0' || *p > '9')
|
||||
{
|
||||
mouse_event_occurred = false;
|
||||
clearEvent();
|
||||
sgr_mouse[0] = '\0'; // Delete already interpreted data
|
||||
return;
|
||||
}
|
||||
@ -763,9 +823,8 @@ void FMouseSGR::processEvent (struct timeval* time)
|
||||
y = uInt16(10 * y + (*p - '0'));
|
||||
}
|
||||
|
||||
new_mouse_position.setPoint (x, y);
|
||||
// Fill bit field with 0
|
||||
std::memset(&b_state, 0x00, sizeof(b_state));
|
||||
setNewPos (x, y);
|
||||
clearButtonState();
|
||||
setKeyState (btn);
|
||||
setMoveState (mouse_position, btn);
|
||||
|
||||
@ -774,17 +833,17 @@ void FMouseSGR::processEvent (struct timeval* time)
|
||||
else // *p == released
|
||||
setReleasedButtonState (btn & button_mask);
|
||||
|
||||
if ( mouse_position == new_mouse_position
|
||||
if ( mouse_position == getNewPos()
|
||||
&& ! isWheelUp()
|
||||
&& ! isWheelDown()
|
||||
&& sgr_button_state == uChar(((*p & 0x20) << 2) + btn) )
|
||||
{
|
||||
mouse_event_occurred = false;
|
||||
clearEvent();
|
||||
sgr_mouse[0] = '\0'; // Delete already interpreted data
|
||||
return;
|
||||
}
|
||||
|
||||
mouse_event_occurred = true;
|
||||
setEvent();
|
||||
setPos (FPoint(x, y));
|
||||
// Get the button state from string
|
||||
sgr_button_state = uChar(((*p & 0x20) << 2) + btn);
|
||||
@ -797,13 +856,13 @@ void FMouseSGR::processEvent (struct timeval* time)
|
||||
void FMouseSGR::setKeyState (int btn)
|
||||
{
|
||||
if ( (btn & key_shift) == key_shift )
|
||||
b_state.shift_button = true;
|
||||
getButtonState().shift_button = true;
|
||||
|
||||
if ( (btn & key_meta) == key_meta )
|
||||
b_state.meta_button = true;
|
||||
getButtonState().meta_button = true;
|
||||
|
||||
if ( (btn & key_ctrl) == key_ctrl )
|
||||
b_state.control_button = true;
|
||||
getButtonState().control_button = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -813,7 +872,7 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn)
|
||||
&& (btn & button_mask) <= button3_move
|
||||
&& ! mouse_position.isOrigin() )
|
||||
{
|
||||
b_state.mouse_moved = true;
|
||||
getButtonState().mouse_moved = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -828,45 +887,40 @@ void FMouseSGR::setPressedButtonState (int btn, struct timeval* time)
|
||||
{
|
||||
case button1:
|
||||
case button1_move:
|
||||
if ( mouse_position == new_mouse_position
|
||||
if ( mouse_position == getNewPos()
|
||||
&& (((sgr_button_state & 0x80) >> 2) + 'M') == released
|
||||
&& ! isDblclickTimeout(&time_mousepressed) )
|
||||
&& ! isDblclickTimeout(getMousePressedTime()) )
|
||||
{
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.left_button = DoubleClick;
|
||||
resetMousePressedTime();
|
||||
getButtonState().left_button = DoubleClick;
|
||||
}
|
||||
else
|
||||
{
|
||||
time_mousepressed = *time; // save click time
|
||||
b_state.left_button = Pressed;
|
||||
setMousePressedTime (time); // save click time
|
||||
getButtonState().left_button = Pressed;
|
||||
}
|
||||
break;
|
||||
|
||||
case button2:
|
||||
case button2_move:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.middle_button = Pressed;
|
||||
resetMousePressedTime();
|
||||
getButtonState().middle_button = Pressed;
|
||||
break;
|
||||
|
||||
case button3:
|
||||
case button3_move:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.right_button = Pressed;
|
||||
resetMousePressedTime();
|
||||
getButtonState().right_button = Pressed;
|
||||
break;
|
||||
|
||||
case button_up:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.wheel_up = true;
|
||||
resetMousePressedTime();
|
||||
getButtonState().wheel_up = true;
|
||||
break;
|
||||
|
||||
case button_down:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.wheel_down = true;
|
||||
resetMousePressedTime();
|
||||
getButtonState().wheel_down = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -883,17 +937,17 @@ void FMouseSGR::setReleasedButtonState (int btn)
|
||||
{
|
||||
case button1:
|
||||
case button1_move:
|
||||
b_state.left_button = Released;
|
||||
getButtonState().left_button = Released;
|
||||
break;
|
||||
|
||||
case button2:
|
||||
case button2_move:
|
||||
b_state.middle_button = Released;
|
||||
getButtonState().middle_button = Released;
|
||||
break;
|
||||
|
||||
case button3:
|
||||
case button3_move:
|
||||
b_state.right_button = Released;
|
||||
getButtonState().right_button = Released;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -926,7 +980,7 @@ void FMouseUrxvt::setRawData (FKeyboard::keybuffer& fifo_buf)
|
||||
|
||||
std::size_t fifo_buf_size = sizeof(fifo_buf);
|
||||
std::size_t len = std::strlen(fifo_buf);
|
||||
std::size_t n = 2;
|
||||
std::size_t n{2};
|
||||
|
||||
while ( n < len && n <= MOUSE_BUF_SIZE )
|
||||
{
|
||||
@ -947,7 +1001,7 @@ void FMouseUrxvt::setRawData (FKeyboard::keybuffer& fifo_buf)
|
||||
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
|
||||
fifo_buf[n] = '\0';
|
||||
|
||||
input_data_pending = bool(fifo_buf[0] != '\0');
|
||||
setPending(bool(fifo_buf[0] != '\0'));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -956,26 +1010,20 @@ void FMouseUrxvt::processEvent (struct timeval* time)
|
||||
// Parse and interpret the X11 xterm mouse string (Urxvt-Mode)
|
||||
|
||||
const auto& mouse_position = getPos();
|
||||
char* p;
|
||||
bool x_neg;
|
||||
bool y_neg;
|
||||
int btn;
|
||||
uInt16 x, y;
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
btn = 0;
|
||||
uInt16 x{0};
|
||||
uInt16 y{0};
|
||||
int btn{0};
|
||||
|
||||
// Parse the Urxvt mouse string
|
||||
p = urxvt_mouse;
|
||||
x_neg = false;
|
||||
y_neg = false;
|
||||
char* p = urxvt_mouse;
|
||||
bool x_neg{false};
|
||||
bool y_neg{false};
|
||||
|
||||
while ( *p && *p != ';' )
|
||||
{
|
||||
if ( *p < '0' || *p > '9')
|
||||
{
|
||||
mouse_event_occurred = false;
|
||||
clearEvent();
|
||||
urxvt_mouse[0] = '\0'; // Delete already interpreted data
|
||||
return;
|
||||
}
|
||||
@ -994,7 +1042,7 @@ void FMouseUrxvt::processEvent (struct timeval* time)
|
||||
{
|
||||
if ( *p < '0' || *p > '9')
|
||||
{
|
||||
mouse_event_occurred = false;
|
||||
clearEvent();
|
||||
urxvt_mouse[0] = '\0'; // Delete already interpreted data
|
||||
return;
|
||||
}
|
||||
@ -1013,7 +1061,7 @@ void FMouseUrxvt::processEvent (struct timeval* time)
|
||||
{
|
||||
if ( *p < '0' || *p > '9')
|
||||
{
|
||||
mouse_event_occurred = false;
|
||||
clearEvent();
|
||||
urxvt_mouse[0] = '\0'; // Delete already interpreted data
|
||||
return;
|
||||
}
|
||||
@ -1028,30 +1076,29 @@ void FMouseUrxvt::processEvent (struct timeval* time)
|
||||
if ( y_neg || y == 0 )
|
||||
y = 1;
|
||||
|
||||
if ( x > max_width )
|
||||
x = max_width;
|
||||
if ( x > getMaxWidth() )
|
||||
x = getMaxWidth();
|
||||
|
||||
if ( y > max_height )
|
||||
y = max_height;
|
||||
if ( y > getMaxHeight() )
|
||||
y = getMaxHeight();
|
||||
|
||||
new_mouse_position.setPoint (x, y);
|
||||
// Fill bit field with 0
|
||||
std::memset(&b_state, 0x00, sizeof(b_state));
|
||||
setNewPos (x, y);
|
||||
clearButtonState();
|
||||
setKeyState (btn);
|
||||
setMoveState (mouse_position, btn);
|
||||
setButtonState (btn & button_mask, time);
|
||||
|
||||
if ( mouse_position == new_mouse_position
|
||||
if ( mouse_position == getNewPos()
|
||||
&& ! isWheelUp()
|
||||
&& ! isWheelDown()
|
||||
&& urxvt_button_state == uChar(btn) )
|
||||
{
|
||||
mouse_event_occurred = false;
|
||||
clearEvent();
|
||||
urxvt_mouse[0] = '\0'; // Delete already interpreted data
|
||||
return;
|
||||
}
|
||||
|
||||
mouse_event_occurred = true;
|
||||
setEvent();
|
||||
setPos (FPoint(x, y));
|
||||
urxvt_button_state = uChar(btn);
|
||||
// Delete already interpreted data
|
||||
@ -1064,13 +1111,13 @@ void FMouseUrxvt::processEvent (struct timeval* time)
|
||||
void FMouseUrxvt::setKeyState (int btn)
|
||||
{
|
||||
if ( (btn & key_shift) == key_shift )
|
||||
b_state.shift_button = Pressed;
|
||||
getButtonState().shift_button = Pressed;
|
||||
|
||||
if ( (btn & key_meta) == key_meta )
|
||||
b_state.meta_button = Pressed;
|
||||
getButtonState().meta_button = Pressed;
|
||||
|
||||
if ( (btn & key_ctrl) == key_ctrl )
|
||||
b_state.control_button = Pressed;
|
||||
getButtonState().control_button = Pressed;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1080,7 +1127,7 @@ void FMouseUrxvt::setMoveState (const FPoint& mouse_position, int btn)
|
||||
&& (btn & button_mask) <= button3_pressed_move
|
||||
&& ! mouse_position.isOrigin() )
|
||||
{
|
||||
b_state.mouse_moved = true;
|
||||
getButtonState().mouse_moved = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1095,33 +1142,30 @@ void FMouseUrxvt::setButtonState (int btn, struct timeval* time)
|
||||
{
|
||||
case button1_pressed:
|
||||
case button1_pressed_move:
|
||||
if ( mouse_position == new_mouse_position
|
||||
if ( mouse_position == getNewPos()
|
||||
&& urxvt_button_state == all_buttons_released
|
||||
&& ! isDblclickTimeout(&time_mousepressed) )
|
||||
&& ! isDblclickTimeout(getMousePressedTime()) )
|
||||
{
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.left_button = DoubleClick;
|
||||
resetMousePressedTime();
|
||||
getButtonState().left_button = DoubleClick;
|
||||
}
|
||||
else
|
||||
{
|
||||
time_mousepressed = *time; // save click time
|
||||
b_state.left_button = Pressed;
|
||||
setMousePressedTime (time); // save click time
|
||||
getButtonState().left_button = Pressed;
|
||||
}
|
||||
break;
|
||||
|
||||
case button2_pressed:
|
||||
case button2_pressed_move:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.middle_button = Pressed;
|
||||
resetMousePressedTime();
|
||||
getButtonState().middle_button = Pressed;
|
||||
break;
|
||||
|
||||
case button3_pressed:
|
||||
case button3_pressed_move:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.right_button = Pressed;
|
||||
resetMousePressedTime();
|
||||
getButtonState().right_button = Pressed;
|
||||
break;
|
||||
|
||||
case all_buttons_released:
|
||||
@ -1129,17 +1173,17 @@ void FMouseUrxvt::setButtonState (int btn, struct timeval* time)
|
||||
{
|
||||
case button1_pressed:
|
||||
case button1_pressed_move:
|
||||
b_state.left_button = Released;
|
||||
getButtonState().left_button = Released;
|
||||
break;
|
||||
|
||||
case button2_pressed:
|
||||
case button2_pressed_move:
|
||||
b_state.middle_button = Released;
|
||||
getButtonState().middle_button = Released;
|
||||
break;
|
||||
|
||||
case button3_pressed:
|
||||
case button3_pressed_move:
|
||||
b_state.right_button = Released;
|
||||
getButtonState().right_button = Released;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1148,15 +1192,13 @@ void FMouseUrxvt::setButtonState (int btn, struct timeval* time)
|
||||
break;
|
||||
|
||||
case button_up:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.wheel_up = Pressed;
|
||||
resetMousePressedTime();
|
||||
getButtonState().wheel_up = Pressed;
|
||||
break;
|
||||
|
||||
case button_down:
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
b_state.wheel_down = Pressed;
|
||||
resetMousePressedTime();
|
||||
getButtonState().wheel_down = Pressed;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1426,11 +1468,14 @@ bool FMouseControl::isMoved()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isInputDataPending()
|
||||
{
|
||||
for (auto&& m : mouse_protocol)
|
||||
if ( m.second && m.second->isInputDataPending() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return std::any_of ( std::begin(mouse_protocol)
|
||||
, std::end(mouse_protocol)
|
||||
, [] (FMouseProtocol::const_reference m)
|
||||
{
|
||||
return m.second
|
||||
&& m.second->isInputDataPending();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1557,21 +1602,33 @@ void FMouseControl::drawGpmPointer()
|
||||
//----------------------------------------------------------------------
|
||||
FMouse* FMouseControl::getMouseWithData()
|
||||
{
|
||||
for (auto&& m : mouse_protocol)
|
||||
if ( m.second && m.second->hasData() )
|
||||
return m.second;
|
||||
const auto& iter = \
|
||||
std::find_if ( std::begin(mouse_protocol)
|
||||
, std::end(mouse_protocol)
|
||||
, [] (FMouseProtocol::const_reference m)
|
||||
{
|
||||
return m.second
|
||||
&& m.second->hasData();
|
||||
}
|
||||
);
|
||||
|
||||
return 0;
|
||||
return ( iter != mouse_protocol.end() ) ? iter->second : 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMouse* FMouseControl::getMouseWithEvent()
|
||||
{
|
||||
for (auto&& m : mouse_protocol)
|
||||
if ( m.second && m.second->hasEvent() )
|
||||
return m.second;
|
||||
const auto& iter = \
|
||||
std::find_if ( std::begin(mouse_protocol)
|
||||
, std::end(mouse_protocol)
|
||||
, [] (FMouseProtocol::const_reference m)
|
||||
{
|
||||
return m.second
|
||||
&& m.second->hasEvent();
|
||||
}
|
||||
);
|
||||
|
||||
return 0;
|
||||
return ( iter != mouse_protocol.end() ) ? iter->second : 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2018 Markus Gans *
|
||||
* Copyright 2015-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -22,6 +22,9 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "final/emptyfstring.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/fc.h"
|
||||
#include "final/fobject.h"
|
||||
|
||||
namespace finalcut
|
||||
@ -29,8 +32,8 @@ namespace finalcut
|
||||
|
||||
// static class attributes
|
||||
bool FObject::timer_modify_lock;
|
||||
FObject::TimerList* FObject::timer_list = nullptr;
|
||||
const FString* fc::emptyFString::empty_string = nullptr;
|
||||
FObject::TimerList* FObject::timer_list{nullptr};
|
||||
const FString* fc::emptyFString::empty_string{nullptr};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -113,11 +116,11 @@ FObject* FObject::getChild (int index) const
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FObject::isChild (FObject* obj) const
|
||||
bool FObject::isChild (const FObject* obj) const
|
||||
{
|
||||
// Find out if obj is a child object of mine
|
||||
|
||||
FObject* p_obj = nullptr;
|
||||
FObject* p_obj{nullptr};
|
||||
|
||||
while ( obj && (p_obj = obj->getParent()) )
|
||||
{
|
||||
@ -225,9 +228,8 @@ bool FObject::isTimeout (timeval* time, uInt64 timeout)
|
||||
{
|
||||
// Checks whether the specified time span (timeout in µs) has elapse
|
||||
|
||||
uInt64 diff_usec;
|
||||
struct timeval now;
|
||||
struct timeval diff;
|
||||
struct timeval now{};
|
||||
struct timeval diff{};
|
||||
|
||||
FObject::getCurrentTime(&now);
|
||||
diff.tv_sec = now.tv_sec - time->tv_sec;
|
||||
@ -239,7 +241,7 @@ bool FObject::isTimeout (timeval* time, uInt64 timeout)
|
||||
diff.tv_usec += 1000000;
|
||||
}
|
||||
|
||||
diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec);
|
||||
uInt64 diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec);
|
||||
return ( diff_usec > timeout );
|
||||
}
|
||||
|
||||
@ -249,9 +251,9 @@ int FObject::addTimer (int interval)
|
||||
// Create a timer and returns the timer identifier number
|
||||
// (interval in ms)
|
||||
|
||||
timeval time_interval;
|
||||
timeval currentTime;
|
||||
int id = 1;
|
||||
timeval time_interval{};
|
||||
timeval currentTime{};
|
||||
int id{1};
|
||||
timer_modify_lock = true;
|
||||
|
||||
// find an unused timer id
|
||||
@ -279,7 +281,7 @@ int FObject::addTimer (int interval)
|
||||
time_interval.tv_usec = (interval % 1000) * 1000;
|
||||
getCurrentTime (¤tTime);
|
||||
timeval timeout = currentTime + time_interval;
|
||||
timer_data t = { id, time_interval, timeout, this };
|
||||
timer_data t{ id, time_interval, timeout, this };
|
||||
|
||||
// insert in list sorted by timeout
|
||||
auto iter = timer_list->begin();
|
||||
@ -359,6 +361,7 @@ bool FObject::delAllTimer()
|
||||
|
||||
timer_modify_lock = true;
|
||||
timer_list->clear();
|
||||
timer_list->shrink_to_fit();
|
||||
timer_modify_lock = false;
|
||||
return true;
|
||||
}
|
||||
@ -376,8 +379,8 @@ void FObject::onUserEvent (FUserEvent*)
|
||||
//----------------------------------------------------------------------
|
||||
uInt FObject::processTimerEvent()
|
||||
{
|
||||
timeval currentTime;
|
||||
uInt activated = 0;
|
||||
timeval currentTime{};
|
||||
uInt activated{0};
|
||||
|
||||
getCurrentTime (¤tTime);
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/foptiattr.h"
|
||||
|
||||
namespace finalcut
|
||||
@ -55,10 +56,6 @@ void FOptiAttr::setTermEnvironment (termEnv& term_env)
|
||||
// Set all required termcap values at once
|
||||
// and initialize the FOptiAttr environment
|
||||
|
||||
ansi_default_color = term_env.ansi_default_color;
|
||||
max_color = term_env.max_color;
|
||||
attr_without_color = term_env.attr_without_color;
|
||||
|
||||
set_enter_bold_mode (term_env.t_enter_bold_mode);
|
||||
set_exit_bold_mode (term_env.t_exit_bold_mode);
|
||||
set_enter_dim_mode (term_env.t_enter_dim_mode);
|
||||
@ -95,6 +92,10 @@ void FOptiAttr::setTermEnvironment (termEnv& term_env)
|
||||
set_orig_pair (term_env.t_orig_pair);
|
||||
set_orig_orig_colors (term_env.t_orig_colors);
|
||||
|
||||
max_color = term_env.max_color;
|
||||
attr_without_color = term_env.attr_without_color;
|
||||
ansi_default_color = term_env.ansi_default_color;
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
@ -1219,10 +1220,10 @@ inline bool FOptiAttr::hasColorChanged (charData*& term, charData*& next)
|
||||
{
|
||||
if ( term && next )
|
||||
{
|
||||
bool frev = ( on.attr.bit.reverse
|
||||
bool frev ( ( on.attr.bit.reverse
|
||||
|| on.attr.bit.standout
|
||||
|| off.attr.bit.reverse
|
||||
|| off.attr.bit.standout ) && fake_reverse;
|
||||
|| off.attr.bit.standout ) && fake_reverse );
|
||||
return bool ( frev
|
||||
|| term->fg_color != next->fg_color
|
||||
|| term->bg_color != next->bg_color );
|
||||
@ -1252,7 +1253,7 @@ inline void FOptiAttr::prevent_no_color_video_attributes ( charData*& attr
|
||||
|| attr_without_color <= 0 )
|
||||
return;
|
||||
|
||||
for (int bit = 1; bit < no_mode; bit <<= 1)
|
||||
for (int bit{1}; bit < no_mode; bit <<= 1)
|
||||
{
|
||||
switch ( bit & attr_without_color )
|
||||
{
|
||||
@ -1330,7 +1331,7 @@ inline void FOptiAttr::deactivateAttributes ( charData*& term
|
||||
inline void FOptiAttr::changeAttributeSGR ( charData*& term
|
||||
, charData*& next )
|
||||
{
|
||||
bool pc_charset_usable = true;
|
||||
bool pc_charset_usable{true};
|
||||
|
||||
if ( ! (term && next) )
|
||||
return;
|
||||
@ -1392,8 +1393,6 @@ inline void FOptiAttr::changeAttributeSeparately ( charData*& term
|
||||
//----------------------------------------------------------------------
|
||||
void FOptiAttr::change_color (charData*& term, charData*& next)
|
||||
{
|
||||
FColor fg, bg;
|
||||
|
||||
if ( ! (term && next) )
|
||||
return;
|
||||
|
||||
@ -1410,8 +1409,8 @@ void FOptiAttr::change_color (charData*& term, charData*& next)
|
||||
if ( next->bg_color != fc::Default )
|
||||
next->bg_color %= max_color;
|
||||
|
||||
fg = next->fg_color;
|
||||
bg = next->bg_color;
|
||||
FColor fg = next->fg_color;
|
||||
FColor bg = next->bg_color;
|
||||
|
||||
if ( fg == fc::Default || bg == fc::Default )
|
||||
change_to_default_color (term, next, fg, bg);
|
||||
@ -1448,7 +1447,7 @@ inline void FOptiAttr::change_to_default_color ( charData*& term
|
||||
}
|
||||
else if ( fg == fc::Default && term->fg_color != fc::Default )
|
||||
{
|
||||
char sgr_39[] = CSI "39m";
|
||||
char sgr_39[]{ CSI "39m" };
|
||||
append_sequence (sgr_39);
|
||||
term->fg_color = fc::Default;
|
||||
}
|
||||
@ -1478,16 +1477,16 @@ inline void FOptiAttr::change_to_default_color ( charData*& term
|
||||
inline void FOptiAttr::change_current_color ( charData*& term
|
||||
, FColor fg, FColor bg )
|
||||
{
|
||||
char* color_str;
|
||||
char* color_str{};
|
||||
auto& AF = F_set_a_foreground.cap;
|
||||
auto& AB = F_set_a_background.cap;
|
||||
auto& Sf = F_set_foreground.cap;
|
||||
auto& Sb = F_set_background.cap;
|
||||
auto& sp = F_set_color_pair.cap;
|
||||
bool frev = ( off.attr.bit.reverse
|
||||
bool frev ( ( off.attr.bit.reverse
|
||||
|| off.attr.bit.standout
|
||||
|| term->attr.bit.reverse
|
||||
|| term->attr.bit.standout ) && fake_reverse;
|
||||
|| term->attr.bit.standout ) && fake_reverse );
|
||||
|
||||
if ( AF && AB )
|
||||
{
|
||||
@ -1546,12 +1545,13 @@ inline void FOptiAttr::reset (charData*& attr)
|
||||
bool FOptiAttr::caused_reset_attributes (char cap[], uChar test)
|
||||
{
|
||||
// test if "cap" reset all attributes
|
||||
auto& ue = F_exit_underline_mode.cap;
|
||||
auto& se = F_exit_standout_mode.cap;
|
||||
auto& me = F_exit_attribute_mode.cap;
|
||||
|
||||
if ( cap )
|
||||
{
|
||||
auto& ue = F_exit_underline_mode.cap;
|
||||
auto& se = F_exit_standout_mode.cap;
|
||||
auto& me = F_exit_attribute_mode.cap;
|
||||
|
||||
if ( (test & test_ansi_reset) && std::strncmp (cap, CSI "m", 3) == 0 )
|
||||
return true;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2018 Markus Gans *
|
||||
* Copyright 2015-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -85,9 +85,6 @@ void FOptiMove::setTermEnvironment (termEnv& term_env)
|
||||
{
|
||||
// Set all required termcap values at once
|
||||
|
||||
set_auto_left_margin (term_env.automatic_left_margin);
|
||||
set_eat_newline_glitch (term_env.eat_nl_glitch);
|
||||
setTabStop (term_env.tabstop);
|
||||
set_cursor_home (term_env.t_cursor_home);
|
||||
set_cursor_to_ll (term_env.t_cursor_to_ll);
|
||||
set_carriage_return (term_env.t_carriage_return);
|
||||
@ -108,6 +105,9 @@ void FOptiMove::setTermEnvironment (termEnv& term_env)
|
||||
set_repeat_char (term_env.t_repeat_char);
|
||||
set_clr_bol (term_env.t_clr_bol);
|
||||
set_clr_eol (term_env.t_clr_eol);
|
||||
setTabStop (term_env.tabstop);
|
||||
set_auto_left_margin (term_env.automatic_left_margin);
|
||||
set_eat_newline_glitch (term_env.eat_nl_glitch);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -485,8 +485,8 @@ void FOptiMove::check_boundaries ( int& xold, int& yold
|
||||
//----------------------------------------------------------------------
|
||||
char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
|
||||
{
|
||||
int method = 0;
|
||||
int move_time = LONG_DURATION;
|
||||
int method{0};
|
||||
int move_time{LONG_DURATION};
|
||||
|
||||
check_boundaries (xold, yold, xnew, ynew);
|
||||
|
||||
@ -558,10 +558,9 @@ int FOptiMove::capDuration (char cap[], int affcnt)
|
||||
if ( ! cap )
|
||||
return LONG_DURATION;
|
||||
|
||||
const char* p;
|
||||
float ms = 0;
|
||||
float ms{0};
|
||||
|
||||
for (p = cap; *p; p++)
|
||||
for (const char* p = cap; *p; p++)
|
||||
{
|
||||
// check for delay with padding character
|
||||
if ( p[0] == '$' && p[1] == '<' && std::strchr(p, '>') )
|
||||
@ -601,13 +600,9 @@ int FOptiMove::repeatedAppend ( const capability& o
|
||||
, volatile int count
|
||||
, char* dst )
|
||||
{
|
||||
std::size_t src_len;
|
||||
std::size_t dst_len;
|
||||
int total;
|
||||
|
||||
src_len = std::strlen(o.cap);
|
||||
dst_len = ( dst != 0 ) ? std::strlen(dst) : 0;
|
||||
total = 0;
|
||||
std::size_t src_len = std::strlen(o.cap);
|
||||
std::size_t dst_len = ( dst != nullptr ) ? std::strlen(dst) : 0;
|
||||
int total{0};
|
||||
|
||||
if ( (dst_len + uInt(count) * src_len) < BUF_SIZE - 1 )
|
||||
{
|
||||
@ -616,7 +611,7 @@ int FOptiMove::repeatedAppend ( const capability& o
|
||||
if ( dst )
|
||||
{
|
||||
dst += dst_len;
|
||||
std::size_t free = BUF_SIZE - dst_len;
|
||||
std::size_t free = BUF_SIZE - dst_len - 2;
|
||||
|
||||
while ( count-- > 0 )
|
||||
{
|
||||
@ -637,8 +632,8 @@ int FOptiMove::relativeMove ( char move[]
|
||||
, int from_x, int from_y
|
||||
, int to_x, int to_y )
|
||||
{
|
||||
int vtime = 0;
|
||||
int htime = 0;
|
||||
int vtime{0};
|
||||
int htime{0};
|
||||
|
||||
if ( move )
|
||||
move[0] = '\0';
|
||||
@ -653,7 +648,7 @@ int FOptiMove::relativeMove ( char move[]
|
||||
|
||||
if ( to_x != from_x ) // horizontal move
|
||||
{
|
||||
char hmove[BUF_SIZE] = { };
|
||||
char hmove[BUF_SIZE]{};
|
||||
htime = horizontalMove (hmove, from_x, to_x);
|
||||
|
||||
if ( htime >= LONG_DURATION )
|
||||
@ -676,7 +671,7 @@ int FOptiMove::relativeMove ( char move[]
|
||||
//----------------------------------------------------------------------
|
||||
inline int FOptiMove::verticalMove (char move[], int from_y, int to_y)
|
||||
{
|
||||
int vtime = LONG_DURATION;
|
||||
int vtime{LONG_DURATION};
|
||||
|
||||
if ( F_row_address.cap )
|
||||
{
|
||||
@ -758,7 +753,7 @@ inline void FOptiMove::upMove ( char move[], int& vtime
|
||||
//----------------------------------------------------------------------
|
||||
inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
|
||||
{
|
||||
int htime = LONG_DURATION;
|
||||
int htime{LONG_DURATION};
|
||||
|
||||
if ( F_column_address.cap )
|
||||
{
|
||||
@ -795,8 +790,8 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
|
||||
|
||||
if ( F_cursor_right.cap )
|
||||
{
|
||||
char str[BUF_SIZE] = { };
|
||||
int htime_r = 0;
|
||||
char str[BUF_SIZE]{};
|
||||
int htime_r{0};
|
||||
str[0] = '\0';
|
||||
|
||||
// try to use tab
|
||||
@ -850,8 +845,8 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
|
||||
|
||||
if ( F_cursor_left.cap )
|
||||
{
|
||||
char str[BUF_SIZE] = { };
|
||||
int htime_l = 0;
|
||||
char str[BUF_SIZE]{};
|
||||
int htime_l{0};
|
||||
str[0] = '\0';
|
||||
|
||||
// try to use backward tab
|
||||
@ -926,9 +921,8 @@ inline bool FOptiMove::isMethod1Faster ( int& move_time
|
||||
|
||||
if ( xold >= 0 && yold >= 0 )
|
||||
{
|
||||
char null_result[BUF_SIZE];
|
||||
char* null_ptr = null_result;
|
||||
int new_time = relativeMove (null_ptr, xold, yold, xnew, ynew);
|
||||
char null_result[BUF_SIZE];
|
||||
int new_time = relativeMove (null_result, xold, yold, xnew, ynew);
|
||||
|
||||
if ( new_time < LONG_DURATION && new_time < move_time )
|
||||
{
|
||||
@ -949,9 +943,8 @@ inline bool FOptiMove::isMethod2Faster ( int& move_time
|
||||
|
||||
if ( yold >= 0 && F_carriage_return.cap )
|
||||
{
|
||||
char null_result[BUF_SIZE];
|
||||
char* null_ptr = null_result;
|
||||
int new_time = relativeMove (null_ptr, 0, yold, xnew, ynew);
|
||||
char null_result[BUF_SIZE];
|
||||
int new_time = relativeMove (null_result, 0, yold, xnew, ynew);
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_carriage_return.duration + new_time < move_time )
|
||||
@ -972,9 +965,8 @@ inline bool FOptiMove::isMethod3Faster ( int& move_time
|
||||
|
||||
if ( F_cursor_home.cap )
|
||||
{
|
||||
char null_result[BUF_SIZE];
|
||||
char* null_ptr = null_result;
|
||||
int new_time = relativeMove (null_ptr, 0, 0, xnew, ynew);
|
||||
char null_result[BUF_SIZE];
|
||||
int new_time = relativeMove (null_result, 0, 0, xnew, ynew);
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_cursor_home.duration + new_time < move_time )
|
||||
@ -994,11 +986,10 @@ inline bool FOptiMove::isMethod4Faster ( int& move_time
|
||||
// Test method 4: home-down + local movement
|
||||
if ( F_cursor_to_ll.cap )
|
||||
{
|
||||
char null_result[BUF_SIZE];
|
||||
char* null_ptr = null_result;
|
||||
int new_time = relativeMove ( null_ptr
|
||||
, 0, int(screen_height) - 1
|
||||
, xnew, ynew );
|
||||
char null_result[BUF_SIZE];
|
||||
int new_time = relativeMove ( null_result
|
||||
, 0, int(screen_height) - 1
|
||||
, xnew, ynew );
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_cursor_to_ll.duration + new_time < move_time )
|
||||
@ -1022,11 +1013,10 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
|
||||
&& yold > 0
|
||||
&& F_cursor_left.cap )
|
||||
{
|
||||
char null_result[BUF_SIZE];
|
||||
char* null_ptr = null_result;
|
||||
int new_time = relativeMove ( null_ptr
|
||||
, int(screen_width) - 1, yold - 1
|
||||
, xnew, ynew );
|
||||
char null_result[BUF_SIZE];
|
||||
int new_time = relativeMove ( null_result
|
||||
, int(screen_width) - 1, yold - 1
|
||||
, xnew, ynew );
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_carriage_return.cap
|
||||
@ -1035,6 +1025,7 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
|
||||
{
|
||||
move_time = F_carriage_return.duration
|
||||
+ F_cursor_left.duration + new_time;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1100,4 +1091,46 @@ void FOptiMove::moveByMethod ( int method
|
||||
}
|
||||
}
|
||||
|
||||
// FOptiMove non-member function
|
||||
//----------------------------------------------------------------------
|
||||
void printDurations (const FOptiMove& om)
|
||||
{
|
||||
std::cout << " speed: "
|
||||
<< om.baudrate << " baud\r\n";
|
||||
std::cout << " char_duration: "
|
||||
<< om.char_duration << " ms\r\n";
|
||||
std::cout << " cursor_home: "
|
||||
<< om.F_cursor_home.duration << " ms\r\n";
|
||||
std::cout << " cursor_to_ll: "
|
||||
<< om.F_cursor_to_ll.duration << " ms\r\n";
|
||||
std::cout << " carriage_return: "
|
||||
<< om.F_carriage_return.duration << " ms\r\n";
|
||||
std::cout << " tab: "
|
||||
<< om.F_tab.duration << " ms\r\n";
|
||||
std::cout << " back_tab: "
|
||||
<< om.F_back_tab.duration << " ms\r\n";
|
||||
std::cout << " cursor_up: "
|
||||
<< om.F_cursor_up.duration << " ms\r\n";
|
||||
std::cout << " cursor_down: "
|
||||
<< om.F_cursor_down.duration << " ms\r\n";
|
||||
std::cout << " cursor_left: "
|
||||
<< om.F_cursor_left.duration << " ms\r\n";
|
||||
std::cout << " cursor_right: "
|
||||
<< om.F_cursor_right.duration << " ms\r\n";
|
||||
std::cout << " cursor_address: "
|
||||
<< om.F_cursor_address.duration << " ms\r\n";
|
||||
std::cout << " column_address: "
|
||||
<< om.F_column_address.duration << " ms\r\n";
|
||||
std::cout << " row_address: "
|
||||
<< om.F_row_address.duration << " ms\r\n";
|
||||
std::cout << " parm_up_cursor: "
|
||||
<< om.F_parm_up_cursor.duration << " ms\r\n";
|
||||
std::cout << " parm_down_cursor: "
|
||||
<< om.F_parm_down_cursor.duration << " ms\r\n";
|
||||
std::cout << " parm_left_cursor: "
|
||||
<< om.F_parm_left_cursor.duration << " ms\r\n";
|
||||
std::cout << "parm_right_cursor: "
|
||||
<< om.F_parm_right_cursor.duration << " ms\r\n";
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -41,6 +41,15 @@ FPoint& FPoint::operator = (const FPoint& p)
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FPoint& FPoint::operator = (FPoint&& p)
|
||||
{
|
||||
xpos = p.xpos;
|
||||
ypos = p.ypos;
|
||||
p.xpos = p.ypos = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FPoint& FPoint::operator += (const FPoint& p)
|
||||
{
|
||||
|
@ -20,7 +20,11 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fevent.h"
|
||||
#include "final/fcolorpair.h"
|
||||
#include "final/fprogressbar.h"
|
||||
#include "final/fstring.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -82,12 +86,12 @@ bool FProgressbar::setShadow (bool enable)
|
||||
&& getEncoding() != fc::VT100
|
||||
&& getEncoding() != fc::ASCII )
|
||||
{
|
||||
flags.shadow = true;
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize(1, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
flags.shadow = false;
|
||||
setFlags().shadow = false;
|
||||
setShadowSize(FSize(0, 0));
|
||||
}
|
||||
|
||||
@ -99,7 +103,7 @@ void FProgressbar::hide()
|
||||
{
|
||||
FWidget::hide();
|
||||
FSize shadow = hasShadow() ? FSize(1, 1) : FSize(0, 0);
|
||||
hideSize (getSize() + shadow);
|
||||
hideArea (getSize() + shadow);
|
||||
print() << FPoint(int(getWidth()) - 4, 0)
|
||||
<< (" "); // hide percentage
|
||||
}
|
||||
@ -126,7 +130,7 @@ void FProgressbar::draw()
|
||||
drawProgressLabel();
|
||||
drawProgressBar();
|
||||
|
||||
if ( flags.shadow )
|
||||
if ( getFlags().shadow )
|
||||
drawShadow ();
|
||||
|
||||
flush_out();
|
||||
@ -141,7 +145,10 @@ void FProgressbar::drawProgressLabel()
|
||||
setColor ( parent_widget->getForegroundColor()
|
||||
, parent_widget->getBackgroundColor() );
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor ( wc.dialog_fg, wc.dialog_bg );
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
@ -160,9 +167,8 @@ void FProgressbar::drawProgressLabel()
|
||||
//----------------------------------------------------------------------
|
||||
void FProgressbar::drawProgressBar()
|
||||
{
|
||||
std::size_t len = 0;
|
||||
print() << FPoint(1, 1)
|
||||
<< FColorPair(wc.progressbar_bg, wc.progressbar_fg);
|
||||
std::size_t len{0};
|
||||
print() << FPoint(1, 1);
|
||||
|
||||
if ( percentage > 0 && percentage <= 100 )
|
||||
len = drawProgressIndicator();
|
||||
@ -182,14 +188,13 @@ std::size_t FProgressbar::drawProgressIndicator()
|
||||
// Draw the progress indicator
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
setReverse(true);
|
||||
|
||||
double length = double(bar_length * percentage) / 100;
|
||||
auto len = std::size_t(trunc(length));
|
||||
print() << FString (len, L' ');
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
const auto& wc = getFWidgetColors();
|
||||
print() << FColorPair (wc.progressbar_fg, wc.progressbar_fg)
|
||||
<< FString (len, fc::FullBlock); // █
|
||||
|
||||
if ( len >= bar_length )
|
||||
return len;
|
||||
@ -220,6 +225,7 @@ void FProgressbar::drawProgressBackground (std::size_t len)
|
||||
// Draw the progress background
|
||||
|
||||
std::size_t bg_len = bar_length - len;
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.progressbar_fg, wc.progressbar_bg);
|
||||
|
||||
if ( getMaxColor() < 16 )
|
||||
|
@ -54,14 +54,17 @@ FRadioButton::~FRadioButton() // destructor
|
||||
//----------------------------------------------------------------------
|
||||
void FRadioButton::init()
|
||||
{
|
||||
label_offset_pos = 4;
|
||||
button_width = 4;
|
||||
setLabelOffsetPos(4);
|
||||
setButtonWidth(4);
|
||||
setVisibleCursor();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FRadioButton::draw()
|
||||
{
|
||||
if ( ! isVisible() )
|
||||
return;
|
||||
|
||||
drawRadioButton();
|
||||
drawLabel();
|
||||
FToggleButton::draw();
|
||||
@ -70,9 +73,6 @@ void FRadioButton::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void FRadioButton::drawRadioButton()
|
||||
{
|
||||
if ( ! isVisible() )
|
||||
return;
|
||||
|
||||
print() << FPoint(1, 1);
|
||||
setColor();
|
||||
|
||||
@ -84,31 +84,39 @@ void FRadioButton::drawRadioButton()
|
||||
setReverse(true);
|
||||
}
|
||||
|
||||
if ( checked )
|
||||
{
|
||||
if ( isNewFont() )
|
||||
print (CHECKED_RADIO_BUTTON);
|
||||
else
|
||||
{
|
||||
print ('(');
|
||||
print (fc::Bullet); // Bullet ●
|
||||
print (')');
|
||||
}
|
||||
}
|
||||
if ( isChecked() )
|
||||
drawChecked();
|
||||
else
|
||||
{
|
||||
if ( isNewFont() )
|
||||
print (RADIO_BUTTON);
|
||||
else
|
||||
{
|
||||
print ('(');
|
||||
print (' ');
|
||||
print (')');
|
||||
}
|
||||
}
|
||||
drawUnchecked();
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FRadioButton::drawChecked()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
print (CHECKED_RADIO_BUTTON);
|
||||
else
|
||||
{
|
||||
print ('(');
|
||||
print (fc::Bullet); // Bullet ●
|
||||
print (')');
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FRadioButton::drawUnchecked()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
print (RADIO_BUTTON);
|
||||
else
|
||||
{
|
||||
print ('(');
|
||||
print (' ');
|
||||
print (')');
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2018 Markus Gans *
|
||||
* Copyright 2015-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -20,6 +20,7 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fradiomenuitem.h"
|
||||
#include "final/fmenu.h"
|
||||
|
||||
@ -54,8 +55,8 @@ FRadioMenuItem::~FRadioMenuItem() // destructor
|
||||
//----------------------------------------------------------------------
|
||||
void FRadioMenuItem::init (FWidget* parent)
|
||||
{
|
||||
checkable = true;
|
||||
radio_button = true;
|
||||
setCheckable();
|
||||
setRadioButton();
|
||||
|
||||
if ( ! parent )
|
||||
return;
|
||||
@ -82,9 +83,9 @@ void FRadioMenuItem::processToggle()
|
||||
//----------------------------------------------------------------------
|
||||
void FRadioMenuItem::processClicked()
|
||||
{
|
||||
if ( ! checked )
|
||||
if ( ! isChecked() )
|
||||
{
|
||||
checked = true;
|
||||
setChecked();
|
||||
processToggle();
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "final/fpoint.h"
|
||||
#include "final/frect.h"
|
||||
#include "final/fsize.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -60,6 +62,40 @@ bool FRect::isEmpty() const
|
||||
return X2 == X1 - 1 && Y2 == Y1 - 1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FPoint FRect::getPos() const
|
||||
{
|
||||
return FPoint(X1, Y1);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FPoint FRect::getUpperLeftPos() const
|
||||
{
|
||||
return FPoint(X1, Y1);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FPoint FRect::getUpperRightPos() const
|
||||
{
|
||||
return FPoint(X2, Y1);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FPoint FRect::getLowerLeftPos() const
|
||||
{ return FPoint(X1, Y2); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FPoint FRect::getLowerRightPos() const
|
||||
{
|
||||
return FPoint(X2, Y2);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FSize FRect::getSize() const
|
||||
{
|
||||
return FSize(getWidth(), getHeight());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FRect::setX1 (int n)
|
||||
{
|
||||
@ -135,10 +171,10 @@ void FRect::setHeight (std::size_t h)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FRect::setSize (std::size_t w, std::size_t h)
|
||||
void FRect::setSize (std::size_t width, std::size_t height)
|
||||
{
|
||||
X2 = X1 + int(w) - 1;
|
||||
Y2 = Y1 + int(h) - 1;
|
||||
X2 = X1 + int(width) - 1;
|
||||
Y2 = Y1 + int(height) - 1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -208,6 +244,20 @@ void FRect::move (const FPoint& d)
|
||||
Y2 = Y2 + d.getY();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FRect::scaleBy (int dx, int dy)
|
||||
{
|
||||
X2 += dx;
|
||||
Y2 += dy;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FRect::scaleBy (const FPoint& d)
|
||||
{
|
||||
X2 += d.getX();
|
||||
Y2 += d.getY();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FRect::contains (int x, int y) const
|
||||
{
|
||||
@ -240,7 +290,7 @@ bool FRect::overlap (const FRect &r) const
|
||||
FRect FRect::intersect (const FRect& r) const
|
||||
{
|
||||
// intersection: this ∩ r
|
||||
FRect new_rect;
|
||||
FRect new_rect{};
|
||||
new_rect.X1 = std::max(X1, r.X1);
|
||||
new_rect.Y1 = std::max(Y1, r.Y1);
|
||||
new_rect.X2 = std::min(X2, r.X2);
|
||||
@ -252,7 +302,7 @@ FRect FRect::intersect (const FRect& r) const
|
||||
FRect FRect::combined (const FRect& r) const
|
||||
{
|
||||
// Union: this ∪ r
|
||||
FRect new_rect;
|
||||
FRect new_rect{};
|
||||
new_rect.X1 = std::min(X1, r.X1);
|
||||
new_rect.Y1 = std::min(Y1, r.Y1);
|
||||
new_rect.X2 = std::max(X2, r.X2);
|
||||
@ -263,10 +313,22 @@ FRect FRect::combined (const FRect& r) const
|
||||
//----------------------------------------------------------------------
|
||||
FRect& FRect::operator = (const FRect& r)
|
||||
{
|
||||
X1 = r.getX1();
|
||||
Y1 = r.getY1();
|
||||
X2 = r.getX2();
|
||||
Y2 = r.getY2();
|
||||
X1 = r.X1;
|
||||
Y1 = r.Y1;
|
||||
X2 = r.X2;
|
||||
Y2 = r.Y2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FRect& FRect::operator = (FRect&& r)
|
||||
{
|
||||
X1 = r.X1;
|
||||
Y1 = r.Y1;
|
||||
X2 = r.X2;
|
||||
Y2 = r.Y2;
|
||||
r.X1 = r.Y1 = 0;
|
||||
r.X2 = r.Y2 = -1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -284,8 +346,8 @@ FRect operator - (const FRect& r, const FSize& s)
|
||||
{
|
||||
return FRect ( r.X1
|
||||
, r.Y1
|
||||
, std::size_t(r.X2 - r.X1 + 1) - s.getWidth()
|
||||
, std::size_t(r.Y2 - r.Y1 + 1) - s.getHeight() );
|
||||
, std::size_t(r.X2 - r.X1) + 1 - s.getWidth()
|
||||
, std::size_t(r.Y2 - r.Y1) + 1 - s.getHeight() );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -22,7 +22,10 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "final/fevent.h"
|
||||
#include "final/fscrollbar.h"
|
||||
#include "final/fsize.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -126,7 +129,7 @@ void FScrollbar::setPageSize (int document_size, int page_size)
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::setOrientation (fc::orientation o)
|
||||
{
|
||||
std::size_t nf = 0;
|
||||
std::size_t nf{0};
|
||||
length = ( getHeight() > getWidth() ) ? getHeight() : getWidth();
|
||||
|
||||
if ( o == fc::vertical && bar_orientation == fc::horizontal )
|
||||
@ -155,7 +158,7 @@ void FScrollbar::setGeometry ( const FPoint& pos, const FSize& size
|
||||
|
||||
FWidget::setGeometry (pos, size, adjust);
|
||||
|
||||
std::size_t nf = 0;
|
||||
std::size_t nf{0};
|
||||
std::size_t w = size.getWidth();
|
||||
std::size_t h = size.getHeight();
|
||||
length = ( h > w ) ? h : w;
|
||||
@ -232,120 +235,7 @@ void FScrollbar::calculateSliderValues()
|
||||
slider_pos = int(bar_length - slider_length);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::drawVerticalBar()
|
||||
{
|
||||
int z;
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
|
||||
for (z = 1; z <= slider_pos; z++)
|
||||
{
|
||||
print() << FPoint(1, 1 + z);
|
||||
|
||||
if ( isNewFont() )
|
||||
{
|
||||
if ( isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
else
|
||||
print (fc::NF_border_line_left); // ⎸
|
||||
}
|
||||
|
||||
if ( isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
|
||||
setColor (wc.scrollbar_bg, wc.scrollbar_fg);
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
for (z = 1; z <= int(slider_length); z++)
|
||||
{
|
||||
print() << FPoint(1, 1 + slider_pos + z);
|
||||
|
||||
if ( isNewFont() )
|
||||
print (' ');
|
||||
|
||||
print (' ');
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
|
||||
for (z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++)
|
||||
{
|
||||
print() << FPoint(1, 1 + z);
|
||||
|
||||
if ( isNewFont() )
|
||||
{
|
||||
if ( isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
else
|
||||
print (fc::NF_border_line_left); // ⎸
|
||||
}
|
||||
|
||||
if ( isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade);
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::drawHorizontalBar()
|
||||
{
|
||||
int z;
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
|
||||
if ( isNewFont() )
|
||||
print() << FPoint(3, 1);
|
||||
else
|
||||
print() << FPoint(2, 1);
|
||||
|
||||
for (z = 0; z < slider_pos; z++)
|
||||
{
|
||||
if ( isNewFont() && max_color > 8 )
|
||||
print (fc::NF_border_line_upper); // ¯
|
||||
else if ( isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
|
||||
setColor (wc.scrollbar_bg, wc.scrollbar_fg);
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
for (z = 0; z < int(slider_length); z++)
|
||||
print (' ');
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
z = slider_pos + int(slider_length) + 1;
|
||||
|
||||
for (; z <= int(bar_length); z++)
|
||||
{
|
||||
if ( isNewFont() && max_color > 8 )
|
||||
print (fc::NF_border_line_upper); // ¯
|
||||
else if ( isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::drawBar()
|
||||
@ -367,8 +257,6 @@ void FScrollbar::drawBar()
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::MiddleButton )
|
||||
return;
|
||||
@ -376,8 +264,8 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
|
||||
if ( min == max )
|
||||
return;
|
||||
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
if ( ev->getButton() == fc::MiddleButton )
|
||||
{
|
||||
@ -440,14 +328,12 @@ void FScrollbar::onMouseUp (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
int mouse_x, mouse_y, new_scroll_type;
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::MiddleButton )
|
||||
return;
|
||||
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
if ( ev->getButton() == fc::MiddleButton )
|
||||
{
|
||||
@ -456,7 +342,7 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
|
||||
}
|
||||
|
||||
// Process left button
|
||||
new_scroll_type = getClickedScrollType(mouse_x, mouse_y);
|
||||
int new_scroll_type = getClickedScrollType(mouse_x, mouse_y);
|
||||
|
||||
if ( scroll_type == FScrollbar::scrollJump )
|
||||
{
|
||||
@ -583,9 +469,115 @@ void FScrollbar::draw()
|
||||
drawBar();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::drawVerticalBar()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
|
||||
for (int z{1}; z <= slider_pos; z++)
|
||||
{
|
||||
print() << FPoint(1, 1 + z);
|
||||
drawVerticalBackgroundLine();
|
||||
}
|
||||
|
||||
setColor (wc.scrollbar_bg, wc.scrollbar_fg);
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
for (int z{1}; z <= int(slider_length); z++) // Draw slider
|
||||
{
|
||||
print() << FPoint(1, 1 + slider_pos + z);
|
||||
|
||||
if ( isNewFont() )
|
||||
print (' ');
|
||||
|
||||
print (' ');
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
|
||||
for (int z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++)
|
||||
{
|
||||
print() << FPoint(1, 1 + z);
|
||||
drawVerticalBackgroundLine();
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FScrollbar::drawVerticalBackgroundLine()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
{
|
||||
if ( isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
else
|
||||
print (fc::NF_border_line_left); // ⎸
|
||||
}
|
||||
|
||||
if ( isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::drawHorizontalBar()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
|
||||
if ( isNewFont() )
|
||||
print() << FPoint(3, 1);
|
||||
else
|
||||
print() << FPoint(2, 1);
|
||||
|
||||
for (int z{0}; z < slider_pos; z++)
|
||||
drawHorizontalBackgroundColumn();
|
||||
|
||||
setColor (wc.scrollbar_bg, wc.scrollbar_fg);
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
for (int z{0}; z < int(slider_length); z++) // Draw slider
|
||||
print (' ');
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
int z = slider_pos + int(slider_length) + 1;
|
||||
|
||||
for (; z <= int(bar_length); z++)
|
||||
drawHorizontalBackgroundColumn();
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FScrollbar::drawHorizontalBackgroundColumn()
|
||||
{
|
||||
if ( isNewFont() && max_color > 8 )
|
||||
print (fc::NF_border_line_upper); // ¯
|
||||
else if ( isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::drawButtons()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.scrollbar_button_fg, wc.scrollbar_button_bg);
|
||||
|
||||
if ( isNewFont() )
|
||||
@ -750,7 +742,7 @@ int FScrollbar::getSliderClickPos (int mouse_x, int mouse_y)
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::jumpToClickPos (int x, int y)
|
||||
{
|
||||
int new_val;
|
||||
int new_val{};
|
||||
|
||||
if ( bar_orientation == fc::vertical )
|
||||
{
|
||||
|
@ -23,8 +23,10 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "final/fevent.h"
|
||||
#include "final/fscrollview.h"
|
||||
#include "final/fwindow.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -45,7 +47,8 @@ FScrollView::FScrollView (FWidget* parent)
|
||||
FScrollView::~FScrollView() // destructor
|
||||
{
|
||||
removeArea (viewport);
|
||||
child_print_area = viewport = nullptr;
|
||||
viewport = nullptr;
|
||||
setChildPrintArea (viewport);
|
||||
}
|
||||
|
||||
|
||||
@ -69,13 +72,15 @@ void FScrollView::setScrollWidth (std::size_t width)
|
||||
(
|
||||
F_PREPROC_HANDLER (this, &FScrollView::copy2area)
|
||||
);
|
||||
child_print_area = viewport;
|
||||
setChildPrintArea (viewport);
|
||||
}
|
||||
|
||||
hbar->setMaximum (int(width - getViewportWidth()));
|
||||
hbar->setPageSize (int(width), int(getViewportWidth()));
|
||||
hbar->calculateSliderValues();
|
||||
setHorizontalScrollBarVisibility();
|
||||
|
||||
if ( isShown() )
|
||||
setHorizontalScrollBarVisibility();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -96,19 +101,20 @@ void FScrollView::setScrollHeight (std::size_t height)
|
||||
(
|
||||
F_PREPROC_HANDLER (this, &FScrollView::copy2area)
|
||||
);
|
||||
child_print_area = viewport;
|
||||
setChildPrintArea (viewport);
|
||||
}
|
||||
|
||||
vbar->setMaximum (int(height - getViewportHeight()));
|
||||
vbar->setPageSize (int(height), int(getViewportHeight()));
|
||||
vbar->calculateSliderValues();
|
||||
setVerticalScrollBarVisibility();
|
||||
|
||||
if ( isShown() )
|
||||
setVerticalScrollBarVisibility();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::setScrollSize (const FSize& size)
|
||||
{
|
||||
int xoffset_end, yoffset_end;
|
||||
std::size_t width = size.getWidth();
|
||||
std::size_t height = size.getHeight();
|
||||
|
||||
@ -130,11 +136,11 @@ void FScrollView::setScrollSize (const FSize& size)
|
||||
(
|
||||
F_PREPROC_HANDLER (this, &FScrollView::copy2area)
|
||||
);
|
||||
child_print_area = viewport;
|
||||
setChildPrintArea (viewport);
|
||||
}
|
||||
|
||||
xoffset_end = int(getScrollWidth() - getViewportWidth());
|
||||
yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||
int xoffset_end = int(getScrollWidth() - getViewportWidth());
|
||||
int yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||
setTopPadding (1 - getScrollY());
|
||||
setLeftPadding (1 - getScrollX());
|
||||
setBottomPadding (1 - (yoffset_end - getScrollY()));
|
||||
@ -143,12 +149,16 @@ void FScrollView::setScrollSize (const FSize& size)
|
||||
hbar->setMaximum (int(width - getViewportWidth()));
|
||||
hbar->setPageSize (int(width), int(getViewportWidth()));
|
||||
hbar->calculateSliderValues();
|
||||
setHorizontalScrollBarVisibility();
|
||||
|
||||
vbar->setMaximum (int(height - getViewportHeight()));
|
||||
vbar->setPageSize (int(height), int(getViewportHeight()));
|
||||
vbar->calculateSliderValues();
|
||||
setVerticalScrollBarVisibility();
|
||||
|
||||
if ( isShown() )
|
||||
{
|
||||
setHorizontalScrollBarVisibility();
|
||||
setVerticalScrollBarVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -296,14 +306,18 @@ bool FScrollView::setBorder (bool enable)
|
||||
void FScrollView::setHorizontalScrollBarMode (fc::scrollBarMode mode)
|
||||
{
|
||||
hMode = mode;
|
||||
setHorizontalScrollBarVisibility();
|
||||
|
||||
if ( isShown() )
|
||||
setHorizontalScrollBarVisibility();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::setVerticalScrollBarMode (fc::scrollBarMode mode)
|
||||
{
|
||||
vMode = mode;
|
||||
setVerticalScrollBarVisibility();
|
||||
|
||||
if ( isShown() )
|
||||
setVerticalScrollBarVisibility();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -336,8 +350,8 @@ void FScrollView::scrollTo (int x, int y)
|
||||
int yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||
std::size_t save_width = viewport_geometry.getWidth();
|
||||
std::size_t save_height = viewport_geometry.getHeight();
|
||||
bool changeX = false;
|
||||
bool changeY = false;
|
||||
bool changeX{false};
|
||||
bool changeY{false};
|
||||
x--;
|
||||
y--;
|
||||
|
||||
@ -359,8 +373,8 @@ void FScrollView::scrollTo (int x, int y)
|
||||
if ( xoffset > xoffset_end )
|
||||
xoffset = xoffset_end;
|
||||
|
||||
changeX = bool(xoffset_before != xoffset);
|
||||
changeY = bool(yoffset_before != yoffset);
|
||||
changeX = bool( xoffset_before != xoffset );
|
||||
changeY = bool( yoffset_before != yoffset );
|
||||
|
||||
if ( ! isShown() || ! viewport || ! (changeX || changeY) )
|
||||
return;
|
||||
@ -416,22 +430,37 @@ void FScrollView::draw()
|
||||
setColor();
|
||||
|
||||
if ( border )
|
||||
{
|
||||
if ( isNewFont() )
|
||||
drawBorder (1, 1, int(getWidth()) - 1, int(getHeight()));
|
||||
else
|
||||
drawBorder();
|
||||
}
|
||||
drawBorder();
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
setViewportPrint();
|
||||
copy2area();
|
||||
|
||||
if ( ! hbar->isShown() )
|
||||
setHorizontalScrollBarVisibility();
|
||||
|
||||
if ( ! vbar->isShown() )
|
||||
setVerticalScrollBarVisibility();
|
||||
|
||||
vbar->redraw();
|
||||
hbar->redraw();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::drawBorder()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
{
|
||||
FRect box(FPoint(1, 1), getSize());
|
||||
box.scaleBy(-1, 0);
|
||||
finalcut::drawBorder (this, box);
|
||||
}
|
||||
else
|
||||
FWidget::drawBorder();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::onKeyPress (FKeyEvent* ev)
|
||||
{
|
||||
@ -487,7 +516,7 @@ void FScrollView::onKeyPress (FKeyEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::onWheel (FWheelEvent* ev)
|
||||
{
|
||||
int distance = 4;
|
||||
int distance{4};
|
||||
|
||||
switch ( ev->getWheel() )
|
||||
{
|
||||
@ -547,8 +576,8 @@ void FScrollView::onChildFocusIn (FFocusEvent*)
|
||||
|
||||
if ( ! vp_geometry.contains(widget_geometry) )
|
||||
{
|
||||
int x
|
||||
, y
|
||||
int x{}
|
||||
, y{}
|
||||
, vx = vp_geometry.getX()
|
||||
, vy = vp_geometry.getY()
|
||||
, wx = widget_geometry.getX()
|
||||
@ -606,9 +635,9 @@ FVTerm::term_area* FScrollView::getPrintArea()
|
||||
|
||||
if ( use_own_print_area || ! viewport )
|
||||
{
|
||||
child_print_area = nullptr;
|
||||
setChildPrintArea (nullptr);
|
||||
auto area = FWidget::getPrintArea();
|
||||
child_print_area = viewport;
|
||||
setChildPrintArea (viewport);
|
||||
return area;
|
||||
}
|
||||
else
|
||||
@ -639,7 +668,6 @@ void FScrollView::adjustSize()
|
||||
hbar->setWidth (width - 2, false);
|
||||
hbar->setValue (xoffset);
|
||||
hbar->resize();
|
||||
setHorizontalScrollBarVisibility();
|
||||
|
||||
vbar->setMaximum (int(getScrollHeight() - getViewportHeight()));
|
||||
vbar->setPageSize (int(getScrollHeight()), int(getViewportHeight()));
|
||||
@ -647,7 +675,12 @@ void FScrollView::adjustSize()
|
||||
vbar->setHeight (height - 2, false);
|
||||
vbar->setValue (yoffset);
|
||||
vbar->resize();
|
||||
setVerticalScrollBarVisibility();
|
||||
|
||||
if ( isShown() )
|
||||
{
|
||||
setHorizontalScrollBarVisibility();
|
||||
setVerticalScrollBarVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -664,41 +697,42 @@ void FScrollView::copy2area()
|
||||
if ( ! viewport->has_changes )
|
||||
return;
|
||||
|
||||
int ax = getTermX() - print_area->offset_left
|
||||
, ay = getTermY() - print_area->offset_top
|
||||
auto printarea = getCurrentPrintArea();
|
||||
int ax = getTermX() - printarea->offset_left
|
||||
, ay = getTermY() - printarea->offset_top
|
||||
, dx = viewport_geometry.getX()
|
||||
, dy = viewport_geometry.getY()
|
||||
, y_end = int(getViewportHeight())
|
||||
, x_end = int(getViewportWidth());
|
||||
|
||||
// viewport width does not fit into the print_area
|
||||
if ( print_area->width <= ax + x_end )
|
||||
x_end = print_area->width - ax;
|
||||
// viewport width does not fit into the printarea
|
||||
if ( printarea->width <= ax + x_end )
|
||||
x_end = printarea->width - ax;
|
||||
|
||||
// viewport height does not fit into the print_area
|
||||
if ( print_area->height <= ay + y_end )
|
||||
y_end = print_area->height - ay;
|
||||
// viewport height does not fit into the printarea
|
||||
if ( printarea->height <= ay + y_end )
|
||||
y_end = printarea->height - ay;
|
||||
|
||||
for (int y = 0; y < y_end; y++) // line loop
|
||||
for (int y{0}; y < y_end; y++) // line loop
|
||||
{
|
||||
charData* vc; // viewport character
|
||||
charData* ac; // area character
|
||||
charData* vc{}; // viewport character
|
||||
charData* ac{}; // area character
|
||||
int v_line_len = viewport->width;
|
||||
int a_line_len = print_area->width + print_area->right_shadow;
|
||||
int a_line_len = printarea->width + printarea->right_shadow;
|
||||
vc = &viewport->text[(dy + y) * v_line_len + dx];
|
||||
ac = &print_area->text[(ay + y) * a_line_len + ax];
|
||||
ac = &printarea->text[(ay + y) * a_line_len + ax];
|
||||
std::memcpy (ac, vc, sizeof(charData) * unsigned(x_end));
|
||||
|
||||
if ( int(print_area->changes[ay + y].xmin) > ax )
|
||||
print_area->changes[ay + y].xmin = uInt(ax);
|
||||
if ( int(printarea->changes[ay + y].xmin) > ax )
|
||||
printarea->changes[ay + y].xmin = uInt(ax);
|
||||
|
||||
if ( int(print_area->changes[ay + y].xmax) < ax + x_end - 1 )
|
||||
print_area->changes[ay + y].xmax = uInt(ax + x_end - 1);
|
||||
if ( int(printarea->changes[ay + y].xmax) < ax + x_end - 1 )
|
||||
printarea->changes[ay + y].xmax = uInt(ax + x_end - 1);
|
||||
}
|
||||
|
||||
setViewportCursor();
|
||||
viewport->has_changes = false;
|
||||
print_area->has_changes = true;
|
||||
printarea->has_changes = true;
|
||||
}
|
||||
|
||||
|
||||
@ -730,6 +764,7 @@ void FScrollView::init (FWidget* parent)
|
||||
|
||||
initScrollbar (vbar, fc::vertical, &FScrollView::cb_VBarChange);
|
||||
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_HBarChange);
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
setGeometry (FPoint(1, 1), FSize(4, 4));
|
||||
@ -759,7 +794,7 @@ void FScrollView::init (FWidget* parent)
|
||||
);
|
||||
|
||||
if ( viewport )
|
||||
child_print_area = viewport;
|
||||
setChildPrintArea (viewport);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -863,26 +898,26 @@ void FScrollView::setViewportCursor()
|
||||
|
||||
FPoint cursor_pos ( viewport->input_cursor_x - 1
|
||||
, viewport->input_cursor_y - 1 );
|
||||
FPoint window_cursor_pos = getViewportCursorPos();
|
||||
print_area->input_cursor_x = window_cursor_pos.getX();
|
||||
print_area->input_cursor_y = window_cursor_pos.getY();
|
||||
FPoint window_cursor_pos(getViewportCursorPos());
|
||||
auto printarea = getCurrentPrintArea();
|
||||
printarea->input_cursor_x = window_cursor_pos.getX();
|
||||
printarea->input_cursor_y = window_cursor_pos.getY();
|
||||
|
||||
if ( viewport->input_cursor_visible
|
||||
&& viewport_geometry.contains(cursor_pos) )
|
||||
print_area->input_cursor_visible = true;
|
||||
printarea->input_cursor_visible = true;
|
||||
else
|
||||
print_area->input_cursor_visible = false;
|
||||
printarea->input_cursor_visible = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::cb_VBarChange (FWidget*, FDataPtr)
|
||||
{
|
||||
FScrollbar::sType scrollType = vbar->getScrollType();
|
||||
int distance = 1;
|
||||
int wheel_distance = 4;
|
||||
int distance{1};
|
||||
int wheel_distance{4};
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward
|
||||
&& scrollType <= FScrollbar::scrollWheelDown )
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward )
|
||||
{
|
||||
update_scrollbar = true;
|
||||
}
|
||||
@ -930,11 +965,10 @@ void FScrollView::cb_VBarChange (FWidget*, FDataPtr)
|
||||
void FScrollView::cb_HBarChange (FWidget*, FDataPtr)
|
||||
{
|
||||
FScrollbar::sType scrollType = hbar->getScrollType();
|
||||
int distance = 1;
|
||||
int wheel_distance = 4;
|
||||
int distance{1};
|
||||
int wheel_distance{4};
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward
|
||||
&& scrollType <= FScrollbar::scrollWheelDown )
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward )
|
||||
{
|
||||
update_scrollbar = true;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <limits>
|
||||
#include "final/fsize.h"
|
||||
|
||||
namespace finalcut
|
||||
@ -41,10 +42,19 @@ FSize& FSize::operator = (const FSize& s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FSize& FSize::operator = (FSize&& s)
|
||||
{
|
||||
width = s.width;
|
||||
height = s.height;
|
||||
s.width = s.height = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FSize& FSize::operator += (const FSize& s)
|
||||
{
|
||||
std::size_t max = std::numeric_limits<std::size_t>::max();
|
||||
constexpr std::size_t max = std::numeric_limits<std::size_t>::max();
|
||||
width = ( width < max - s.width) ? width + s.width : max;
|
||||
height = ( height < max - s.height) ? height + s.height : max;
|
||||
return *this;
|
||||
|
100
src/fstartoptions.cpp
Normal file
100
src/fstartoptions.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
/***********************************************************************
|
||||
* fstartoptions.cpp - Contains the start options for initialization *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2019 Markus Gans *
|
||||
* *
|
||||
* The 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. *
|
||||
* *
|
||||
* The 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/fstartoptions.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attribute
|
||||
FStartOptions* FStartOptions::start_options{};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FStartOptions
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FStartOptions::FStartOptions()
|
||||
: cursor_optimisation{true}
|
||||
, mouse_support{true}
|
||||
, terminal_detection{true}
|
||||
, color_change{true}
|
||||
, vgafont{false}
|
||||
, newfont{false}
|
||||
, encoding{fc::UNKNOWN}
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
, meta_sends_escape{true}
|
||||
, change_cursorstyle{true}
|
||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
, meta_sends_escape{true}
|
||||
#endif
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FStartOptions::~FStartOptions() // destructor
|
||||
{
|
||||
if ( start_options )
|
||||
delete start_options;
|
||||
}
|
||||
|
||||
// public methods of FStartOptions
|
||||
//----------------------------------------------------------------------
|
||||
FStartOptions& FStartOptions::getFStartOptions()
|
||||
{
|
||||
if ( start_options == 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
start_options = new FStartOptions;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
return *start_options;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FStartOptions::setDefault()
|
||||
{
|
||||
cursor_optimisation = true;
|
||||
mouse_support = true;
|
||||
terminal_detection = true;
|
||||
color_change = true;
|
||||
vgafont = false;
|
||||
newfont = false;
|
||||
encoding = fc::UNKNOWN;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
meta_sends_escape = true;
|
||||
change_cursorstyle = true;
|
||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
meta_sends_escape = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -22,7 +22,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "final/fevent.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -42,8 +44,8 @@ FStatusKey::FStatusKey(FWidget* parent)
|
||||
//----------------------------------------------------------------------
|
||||
FStatusKey::FStatusKey (FKey k, const FString& txt, FWidget* parent)
|
||||
: FWidget(parent)
|
||||
, key(k)
|
||||
, text(txt)
|
||||
, key(k)
|
||||
{
|
||||
init (parent);
|
||||
}
|
||||
@ -139,13 +141,13 @@ FStatusBar::~FStatusBar() // destructor
|
||||
|
||||
while ( iter != key_list.end() )
|
||||
{
|
||||
(*iter)->setConnectedStatusbar(0);
|
||||
(*iter)->setConnectedStatusbar(nullptr);
|
||||
delAccelerator (*iter);
|
||||
iter = key_list.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
setStatusBar(0);
|
||||
setStatusBar(nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -153,7 +155,7 @@ FStatusBar::~FStatusBar() // destructor
|
||||
//----------------------------------------------------------------------
|
||||
void FStatusBar::setMessage (const FString& mgs)
|
||||
{
|
||||
text = mgs;
|
||||
text.setString(mgs);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -173,11 +175,12 @@ bool FStatusBar::hasActivatedKey()
|
||||
void FStatusBar::hide()
|
||||
{
|
||||
FWindow::hide();
|
||||
const auto& wc = getFWidgetColors();
|
||||
FColor fg = wc.term_fg;
|
||||
FColor bg = wc.term_bg;
|
||||
setColor (fg, bg);
|
||||
screenWidth = getDesktopWidth();
|
||||
auto blank = createBlankArray(screenWidth + 1);
|
||||
char* blank = createBlankArray(screenWidth + 1);
|
||||
print() << FPoint(1, 1) << blank;
|
||||
destroyBlankArray (blank);
|
||||
}
|
||||
@ -185,10 +188,6 @@ void FStatusBar::hide()
|
||||
//----------------------------------------------------------------------
|
||||
void FStatusBar::drawMessage()
|
||||
{
|
||||
std::size_t termWidth;
|
||||
int space_offset;
|
||||
bool isLastActiveFocus, hasKeys;
|
||||
|
||||
if ( ! (isVisible() ) )
|
||||
return;
|
||||
|
||||
@ -196,9 +195,10 @@ void FStatusBar::drawMessage()
|
||||
return;
|
||||
|
||||
x = x_msg;
|
||||
termWidth = getDesktopWidth();
|
||||
space_offset = 1;
|
||||
hasKeys = bool(! key_list.empty());
|
||||
int space_offset{1};
|
||||
bool hasKeys( ! key_list.empty() );
|
||||
bool isLastActiveFocus{false};
|
||||
std::size_t termWidth = getDesktopWidth();
|
||||
|
||||
if ( hasKeys )
|
||||
{
|
||||
@ -212,6 +212,7 @@ void FStatusBar::drawMessage()
|
||||
if ( isLastActiveFocus )
|
||||
space_offset = 0;
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.statusbar_fg, wc.statusbar_bg);
|
||||
setPrintPos (FPoint(x, 1));
|
||||
|
||||
@ -235,7 +236,7 @@ void FStatusBar::drawMessage()
|
||||
print (' ');
|
||||
}
|
||||
|
||||
std::size_t msg_length = getMessage().getLength();
|
||||
auto msg_length = getColumnWidth(getMessage());
|
||||
x += int(msg_length);
|
||||
|
||||
if ( x - 1 <= int(termWidth) )
|
||||
@ -243,8 +244,9 @@ void FStatusBar::drawMessage()
|
||||
else
|
||||
{
|
||||
// Print ellipsis
|
||||
print ( getMessage().left(msg_length + termWidth - uInt(x) - 1) );
|
||||
print ("..");
|
||||
std::size_t len = msg_length + termWidth - uInt(x) - 1;
|
||||
print() << getColumnSubString ( getMessage(), 1, len)
|
||||
<< "..";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -285,7 +287,7 @@ void FStatusBar::remove (FStatusKey* skey)
|
||||
if ( (*iter) == skey )
|
||||
{
|
||||
iter = key_list.erase(iter);
|
||||
skey->setConnectedStatusbar(0);
|
||||
skey->setConnectedStatusbar(nullptr);
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -306,6 +308,7 @@ void FStatusBar::remove (int pos)
|
||||
void FStatusBar::clear()
|
||||
{
|
||||
key_list.clear();
|
||||
key_list.shrink_to_fit();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -349,15 +352,15 @@ void FStatusBar::onMouseDown (FMouseEvent* ev)
|
||||
|
||||
if ( ! key_list.empty() )
|
||||
{
|
||||
int X = 1;
|
||||
int X{1};
|
||||
auto iter = key_list.begin();
|
||||
auto last = key_list.end();
|
||||
|
||||
while ( iter != last )
|
||||
{
|
||||
int x1 = X
|
||||
, kname_len = int(getKeyName((*iter)->getKey()).getLength())
|
||||
, txt_length = int((*iter)->getText().getLength())
|
||||
, kname_len = getKeyNameWidth(*iter)
|
||||
, txt_length = getKeyTextWidth(*iter)
|
||||
, x2 = x1 + kname_len + txt_length + 1
|
||||
, mouse_x = ev->getX()
|
||||
, mouse_y = ev->getY();
|
||||
@ -392,15 +395,15 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
|
||||
|
||||
if ( ! key_list.empty() )
|
||||
{
|
||||
int X = 1;
|
||||
int X{1};
|
||||
auto iter = key_list.begin();
|
||||
auto last = key_list.end();
|
||||
|
||||
while ( iter != last )
|
||||
{
|
||||
int x1 = X
|
||||
, kname_len = int(getKeyName((*iter)->getKey()).getLength())
|
||||
, txt_length = int((*iter)->getText().getLength())
|
||||
, kname_len = getKeyNameWidth(*iter)
|
||||
, txt_length = getKeyTextWidth(*iter)
|
||||
, x2 = x1 + kname_len + txt_length + 1;
|
||||
|
||||
if ( (*iter)->hasMouseFocus() )
|
||||
@ -436,16 +439,16 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
|
||||
|
||||
if ( mouse_down && ! key_list.empty() )
|
||||
{
|
||||
bool focus_changed = false;
|
||||
int X = 1;
|
||||
bool focus_changed{false};
|
||||
int X{1};
|
||||
auto iter = key_list.begin();
|
||||
auto last = key_list.end();
|
||||
|
||||
while ( iter != last )
|
||||
{
|
||||
int x1 = X
|
||||
, kname_len = int(getKeyName((*iter)->getKey()).getLength())
|
||||
, txt_length = int((*iter)->getText().getLength())
|
||||
, kname_len = getKeyNameWidth(*iter)
|
||||
, txt_length = getKeyTextWidth(*iter)
|
||||
, x2 = x1 + kname_len + txt_length + 1
|
||||
, mouse_x = ev->getX()
|
||||
, mouse_y = ev->getY();
|
||||
@ -516,11 +519,26 @@ void FStatusBar::init()
|
||||
if ( getRootWidget() )
|
||||
getRootWidget()->setBottomPadding(1, true);
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.statusbar_fg);
|
||||
setBackgroundColor (wc.statusbar_bg);
|
||||
unsetFocusable();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FStatusBar::getKeyNameWidth (const FStatusKey* key)
|
||||
{
|
||||
const FString& key_name = getKeyName(key->getKey());
|
||||
return int(getColumnWidth(key_name));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FStatusBar::getKeyTextWidth (const FStatusKey* key)
|
||||
{
|
||||
const FString& key_text = key->getText();
|
||||
return int(getColumnWidth(key_text));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FStatusBar::draw()
|
||||
{
|
||||
@ -546,21 +564,22 @@ void FStatusBar::drawKeys()
|
||||
setReverse(true);
|
||||
|
||||
auto iter = key_list.begin();
|
||||
auto last = key_list.end();
|
||||
|
||||
while ( iter != last )
|
||||
while ( iter != key_list.end() )
|
||||
{
|
||||
keyname_len = int(getKeyName((*iter)->getKey()).getLength());
|
||||
auto item = *iter;
|
||||
keyname_len = getKeyNameWidth(item);
|
||||
|
||||
if ( x + keyname_len + 2 < int(screenWidth) )
|
||||
{
|
||||
if ( (*iter)->isActivated() || (*iter)->hasMouseFocus() )
|
||||
if ( item->isActivated() || item->hasMouseFocus() )
|
||||
drawActiveKey (iter);
|
||||
else
|
||||
drawKey (iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.statusbar_fg, wc.statusbar_bg);
|
||||
|
||||
for (; x <= int(screenWidth); x++)
|
||||
@ -581,9 +600,8 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
|
||||
{
|
||||
// Draw not active key
|
||||
|
||||
std::size_t txt_length;
|
||||
auto item = *iter;
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.statusbar_hotkey_fg, wc.statusbar_hotkey_bg);
|
||||
x++;
|
||||
print (' ');
|
||||
@ -592,23 +610,22 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
|
||||
setColor (wc.statusbar_fg, wc.statusbar_bg);
|
||||
x++;
|
||||
print ('-');
|
||||
txt_length = item->getText().getLength();
|
||||
x += int(txt_length);
|
||||
auto column_width = getColumnWidth (item->getText());
|
||||
x += int(column_width);
|
||||
|
||||
if ( x - 1 <= int(screenWidth) )
|
||||
print (item->getText());
|
||||
else
|
||||
{
|
||||
// Print ellipsis
|
||||
print ( item->getText()
|
||||
.left(txt_length + screenWidth - std::size_t(x) - 1) );
|
||||
print ("..");
|
||||
std::size_t len = column_width + screenWidth - std::size_t(x) - 1;
|
||||
print() << getColumnSubString(item->getText(), 1, len)
|
||||
<< "..";
|
||||
}
|
||||
|
||||
if ( iter + 1 != key_list.end()
|
||||
&& ( (*(iter + 1))->isActivated() || (*(iter + 1))->hasMouseFocus() )
|
||||
&& x + int(getKeyName((*(iter + 1))->getKey()).getLength()) + 3
|
||||
< int(screenWidth) )
|
||||
&& x + getKeyNameWidth(*(iter + 1)) + 3 < int(screenWidth) )
|
||||
{
|
||||
// Next element is active
|
||||
if ( isMonochron() )
|
||||
@ -641,12 +658,12 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
|
||||
{
|
||||
// Draw active key
|
||||
|
||||
std::size_t txt_length;
|
||||
auto item = *iter;
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor ( wc.statusbar_active_hotkey_fg
|
||||
, wc.statusbar_active_hotkey_bg );
|
||||
x++;
|
||||
@ -656,8 +673,8 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
|
||||
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg);
|
||||
x++;
|
||||
print ('-');
|
||||
txt_length = item->getText().getLength();
|
||||
x += int(txt_length);
|
||||
auto column_width = getColumnWidth (item->getText());
|
||||
x += int(column_width);
|
||||
|
||||
if ( x <= int(screenWidth) )
|
||||
{
|
||||
@ -668,9 +685,9 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
|
||||
else
|
||||
{
|
||||
// Print ellipsis
|
||||
print ( item->getText()
|
||||
.left(txt_length + screenWidth - std::size_t(x) - 1) );
|
||||
print ("..");
|
||||
std::size_t len = column_width + screenWidth - std::size_t(x) - 1;
|
||||
print() << getColumnSubString(item->getText(), 1, len)
|
||||
<< "..";
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
|
443
src/fstring.cpp
443
src/fstring.cpp
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2012-2018 Markus Gans *
|
||||
* Copyright 2012-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -20,7 +20,9 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "final/fstring.h"
|
||||
@ -51,12 +53,9 @@ FString::FString (std::size_t len)
|
||||
//----------------------------------------------------------------------
|
||||
FString::FString (std::size_t len, wchar_t c)
|
||||
{
|
||||
wchar_t* ps;
|
||||
wchar_t* pe;
|
||||
|
||||
initLength(len);
|
||||
ps = string;
|
||||
pe = string + len;
|
||||
const wchar_t* ps = string;
|
||||
wchar_t* pe = string + len;
|
||||
|
||||
while ( pe != ps )
|
||||
*--pe = c;
|
||||
@ -69,6 +68,13 @@ FString::FString (const FString& s) // copy constructor
|
||||
_assign (s.string);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString::FString (FString&& s) // move constructor
|
||||
{
|
||||
if ( ! s.isNull() )
|
||||
_assign (std::move(s.string));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString::FString (const std::wstring& s)
|
||||
{
|
||||
@ -160,6 +166,13 @@ FString& FString::operator = (const FString& s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator = (FString&& s)
|
||||
{
|
||||
_assign (std::move(s.string));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FString::operator += (const FString& s)
|
||||
{
|
||||
@ -179,9 +192,8 @@ const FString FString::operator + (const FString& s)
|
||||
//----------------------------------------------------------------------
|
||||
const FString FString::operator + (const wchar_t c)
|
||||
{
|
||||
wchar_t s[2];
|
||||
wchar_t s[2]{};
|
||||
s[0] = c;
|
||||
s[1] = L'\0';
|
||||
FString tmp(string);
|
||||
tmp._insert (length, 1, s);
|
||||
return tmp;
|
||||
@ -190,9 +202,8 @@ const FString FString::operator + (const wchar_t c)
|
||||
//----------------------------------------------------------------------
|
||||
const FString FString::operator + (const char c)
|
||||
{
|
||||
wchar_t s[2];
|
||||
wchar_t s[2]{};
|
||||
s[0] = wchar_t(c & 0xff);
|
||||
s[1] = L'\0';
|
||||
FString tmp(string);
|
||||
tmp._insert (length, 1, s);
|
||||
return tmp;
|
||||
@ -232,7 +243,7 @@ FString& FString::operator << (const char c)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator << (const sInt16 num)
|
||||
{
|
||||
FString numstr = FString().setNumber(num);
|
||||
FString numstr(FString().setNumber(num));
|
||||
_insert (length, numstr.length, numstr.string);
|
||||
return *this;
|
||||
}
|
||||
@ -240,7 +251,7 @@ FString& FString::operator << (const sInt16 num)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator << (const uInt16 num)
|
||||
{
|
||||
FString numstr = FString().setNumber(num);
|
||||
FString numstr(FString().setNumber(num));
|
||||
_insert (length, numstr.length, numstr.string);
|
||||
return *this;
|
||||
}
|
||||
@ -248,7 +259,7 @@ FString& FString::operator << (const uInt16 num)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator << (const int num)
|
||||
{
|
||||
FString numstr = FString().setNumber(num);
|
||||
FString numstr(FString().setNumber(num));
|
||||
_insert (length, numstr.length, numstr.string);
|
||||
return *this;
|
||||
}
|
||||
@ -256,7 +267,7 @@ FString& FString::operator << (const int num)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator << (const uInt num)
|
||||
{
|
||||
FString numstr = FString().setNumber(num);
|
||||
FString numstr(FString().setNumber(num));
|
||||
_insert (length, numstr.length, numstr.string);
|
||||
return *this;
|
||||
}
|
||||
@ -264,7 +275,7 @@ FString& FString::operator << (const uInt num)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator << (const long num)
|
||||
{
|
||||
FString numstr = FString().setNumber(num);
|
||||
FString numstr(FString().setNumber(num));
|
||||
_insert (length, numstr.length, numstr.string);
|
||||
return *this;
|
||||
}
|
||||
@ -272,7 +283,7 @@ FString& FString::operator << (const long num)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator << (const uLong num)
|
||||
{
|
||||
FString numstr = FString().setNumber(num);
|
||||
FString numstr(FString().setNumber(num));
|
||||
_insert (length, numstr.length, numstr.string);
|
||||
return *this;
|
||||
}
|
||||
@ -280,7 +291,7 @@ FString& FString::operator << (const uLong num)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator << (const float num)
|
||||
{
|
||||
FString numstr = FString().setNumber(num);
|
||||
FString numstr(FString().setNumber(num));
|
||||
_insert (length, numstr.length, numstr.string);
|
||||
return *this;
|
||||
}
|
||||
@ -288,7 +299,7 @@ FString& FString::operator << (const float num)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator << (const double num)
|
||||
{
|
||||
FString numstr = FString().setNumber(num);
|
||||
FString numstr(FString().setNumber(num));
|
||||
_insert (length, numstr.length, numstr.string);
|
||||
return *this;
|
||||
}
|
||||
@ -296,7 +307,7 @@ FString& FString::operator << (const double num)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator << (const lDouble num)
|
||||
{
|
||||
FString numstr = FString().setNumber(num);
|
||||
FString numstr(FString().setNumber(num));
|
||||
_insert (length, numstr.length, numstr.string);
|
||||
return *this;
|
||||
}
|
||||
@ -404,14 +415,11 @@ const FString& FString::operator () ()
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t FString::getUTF8length() const
|
||||
{
|
||||
std::size_t len;
|
||||
const char* s;
|
||||
|
||||
if ( ! string )
|
||||
return 0;
|
||||
|
||||
len = 0;
|
||||
s = c_str();
|
||||
std::size_t len{0};
|
||||
const char* s = c_str();
|
||||
|
||||
while ( *s )
|
||||
len += std::size_t((*s++ & 0xc0) != 0x80);
|
||||
@ -419,27 +427,6 @@ std::size_t FString::getUTF8length() const
|
||||
return len;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::sprintf (const FString format, ...)
|
||||
{
|
||||
static constexpr int BUFSIZE = 4096;
|
||||
wchar_t buffer[BUFSIZE];
|
||||
va_list args;
|
||||
|
||||
if ( ! format )
|
||||
{
|
||||
clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
va_start (args, format);
|
||||
std::vswprintf (buffer, BUFSIZE, format.wc_str(), args);
|
||||
va_end (args);
|
||||
|
||||
_assign (buffer);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::clear()
|
||||
{
|
||||
@ -503,46 +490,31 @@ const std::string FString::toString() const
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::toLower() const
|
||||
{
|
||||
wchar_t* p;
|
||||
FString s(string);
|
||||
p = s.string;
|
||||
|
||||
if ( p )
|
||||
{
|
||||
while ( *p )
|
||||
{
|
||||
*p = wchar_t(std::towlower(wint_t(*p)));
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
auto to_lower = [] (wchar_t& c)
|
||||
{
|
||||
c = wchar_t(std::towlower(std::wint_t(c)));
|
||||
};
|
||||
std::for_each (s.begin(), s.end(), to_lower);
|
||||
return s;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::toUpper() const
|
||||
{
|
||||
wchar_t* p;
|
||||
FString s(string);
|
||||
p = s.string;
|
||||
|
||||
if ( p )
|
||||
{
|
||||
while ( *p )
|
||||
{
|
||||
*p = wchar_t(std::towupper(wint_t(*p)));
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
auto to_upper = [] (wchar_t& c)
|
||||
{
|
||||
c = wchar_t(std::towupper(std::wint_t(c)));
|
||||
};
|
||||
std::for_each (s.begin(), s.end(), to_upper);
|
||||
return s;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
sInt16 FString::toShort() const
|
||||
{
|
||||
long num;
|
||||
num = toLong();
|
||||
long num = toLong();
|
||||
|
||||
if ( num > SHRT_MAX )
|
||||
throw std::overflow_error ("overflow");
|
||||
@ -556,8 +528,7 @@ sInt16 FString::toShort() const
|
||||
//----------------------------------------------------------------------
|
||||
uInt16 FString::toUShort() const
|
||||
{
|
||||
uLong num;
|
||||
num = uLong(toULong());
|
||||
uLong num = uLong(toULong());
|
||||
|
||||
if ( num > USHRT_MAX )
|
||||
throw std::overflow_error ("overflow");
|
||||
@ -568,8 +539,7 @@ uInt16 FString::toUShort() const
|
||||
//----------------------------------------------------------------------
|
||||
int FString::toInt() const
|
||||
{
|
||||
long num;
|
||||
num = toLong();
|
||||
long num = toLong();
|
||||
|
||||
if ( num > INT_MAX )
|
||||
throw std::overflow_error ("overflow");
|
||||
@ -583,8 +553,7 @@ int FString::toInt() const
|
||||
//----------------------------------------------------------------------
|
||||
uInt FString::toUInt() const
|
||||
{
|
||||
uLong num;
|
||||
num = uLong(toULong());
|
||||
uLong num = uLong(toULong());
|
||||
|
||||
if ( num > UINT_MAX )
|
||||
throw std::overflow_error ("overflow");
|
||||
@ -595,19 +564,12 @@ uInt FString::toUInt() const
|
||||
//----------------------------------------------------------------------
|
||||
long FString::toLong() const
|
||||
{
|
||||
bool neg;
|
||||
long num;
|
||||
long tenth_limit;
|
||||
long tenth_limit_digit;
|
||||
wchar_t* p;
|
||||
FString s;
|
||||
|
||||
neg = false;
|
||||
num = 0;
|
||||
tenth_limit = LONG_MAX / 10;
|
||||
tenth_limit_digit = LONG_MAX % 10;
|
||||
s = trim();
|
||||
p = s.string;
|
||||
bool neg{false};
|
||||
long num{0};
|
||||
long tenth_limit{LONG_MAX / 10};
|
||||
long tenth_limit_digit{LONG_MAX % 10};
|
||||
FString s(trim());
|
||||
const wchar_t* p = s.string;
|
||||
|
||||
if ( ! p )
|
||||
throw std::invalid_argument ("null value");
|
||||
@ -627,9 +589,9 @@ long FString::toLong() const
|
||||
p++;
|
||||
}
|
||||
|
||||
while ( std::iswdigit(wint_t(*p)) )
|
||||
while ( std::iswdigit(std::wint_t(*p)) )
|
||||
{
|
||||
uChar d = uChar((*p) - L'0');
|
||||
uChar d = uChar(*p - L'0');
|
||||
|
||||
if ( num > tenth_limit
|
||||
|| (num == tenth_limit && d > tenth_limit_digit) )
|
||||
@ -644,7 +606,7 @@ long FString::toLong() const
|
||||
p++;
|
||||
}
|
||||
|
||||
if ( *p != L'\0' && ! std::iswdigit(wint_t(*p)) )
|
||||
if ( *p != L'\0' && ! std::iswdigit(std::wint_t(*p)) )
|
||||
throw std::invalid_argument ("no valid number");
|
||||
|
||||
if ( neg )
|
||||
@ -656,17 +618,11 @@ long FString::toLong() const
|
||||
//----------------------------------------------------------------------
|
||||
uLong FString::toULong() const
|
||||
{
|
||||
uLong num;
|
||||
uLong tenth_limit;
|
||||
uLong tenth_limit_digit;
|
||||
wchar_t* p;
|
||||
FString s;
|
||||
|
||||
num = 0;
|
||||
tenth_limit = ULONG_MAX / 10;
|
||||
tenth_limit_digit = ULONG_MAX % 10;
|
||||
s = trim();
|
||||
p = s.string;
|
||||
uLong num{0};
|
||||
uLong tenth_limit{ULONG_MAX / 10};
|
||||
uLong tenth_limit_digit{ULONG_MAX % 10};
|
||||
FString s(trim());
|
||||
const wchar_t* p = s.string;
|
||||
|
||||
if ( ! p )
|
||||
throw std::invalid_argument ("null value");
|
||||
@ -683,9 +639,9 @@ uLong FString::toULong() const
|
||||
p++;
|
||||
}
|
||||
|
||||
while ( std::iswdigit(wint_t(*p)) )
|
||||
while ( std::iswdigit(std::wint_t(*p)) )
|
||||
{
|
||||
uChar d = uChar((*p) - L'0');
|
||||
uChar d = uChar(*p - L'0');
|
||||
|
||||
if ( num > tenth_limit
|
||||
|| (num == tenth_limit && d > tenth_limit_digit) )
|
||||
@ -697,7 +653,7 @@ uLong FString::toULong() const
|
||||
p++;
|
||||
}
|
||||
|
||||
if ( *p != L'\0' && ! std::iswdigit(wint_t(*p)) )
|
||||
if ( *p != L'\0' && ! std::iswdigit(std::wint_t(*p)) )
|
||||
throw std::invalid_argument ("no valid number");
|
||||
|
||||
return num;
|
||||
@ -706,8 +662,7 @@ uLong FString::toULong() const
|
||||
//----------------------------------------------------------------------
|
||||
float FString::toFloat() const
|
||||
{
|
||||
double num;
|
||||
num = toDouble();
|
||||
double num = toDouble();
|
||||
|
||||
if ( num > double(FLT_MAX) || num < double(-FLT_MAX) )
|
||||
throw std::overflow_error ("overflow");
|
||||
@ -721,16 +676,14 @@ float FString::toFloat() const
|
||||
//----------------------------------------------------------------------
|
||||
double FString::toDouble() const
|
||||
{
|
||||
wchar_t* p;
|
||||
double ret;
|
||||
|
||||
if ( ! string )
|
||||
throw std::invalid_argument ("null value");
|
||||
|
||||
if ( ! *string )
|
||||
throw std::invalid_argument ("empty value");
|
||||
|
||||
ret = std::wcstod(string, &p);
|
||||
wchar_t* p{};
|
||||
double ret = std::wcstod(string, &p);
|
||||
|
||||
if ( p != 0 && *p != '\0' )
|
||||
throw std::invalid_argument ("no valid floating point value");
|
||||
@ -750,16 +703,15 @@ double FString::toDouble() const
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::ltrim() const
|
||||
{
|
||||
wchar_t* p;
|
||||
FString s(string);
|
||||
|
||||
// handle NULL and empty string
|
||||
if ( ! (string && *string) )
|
||||
return s;
|
||||
|
||||
p = s.string;
|
||||
const wchar_t* p = s.string;
|
||||
|
||||
while ( std::iswspace(wint_t(*p)) )
|
||||
while ( std::iswspace(std::wint_t(*p)) )
|
||||
p++;
|
||||
|
||||
return FString(p);
|
||||
@ -768,21 +720,19 @@ FString FString::ltrim() const
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::rtrim() const
|
||||
{
|
||||
wchar_t* p;
|
||||
wchar_t* last;
|
||||
FString s(string);
|
||||
|
||||
// handle NULL and empty string
|
||||
if ( ! (string && *string) )
|
||||
return s;
|
||||
|
||||
p = s.string;
|
||||
last = p + length;
|
||||
wchar_t* p = s.string;
|
||||
wchar_t* last = p + length;
|
||||
|
||||
while ( std::iswspace(wint_t(*--last)) && last > p )
|
||||
while ( std::iswspace(std::wint_t(*--last)) && last > p )
|
||||
s.length--;
|
||||
|
||||
if ( last == p && std::iswspace(wint_t(*last)) )
|
||||
if ( last == p && std::iswspace(std::wint_t(*last)) )
|
||||
s = L"";
|
||||
else
|
||||
*(last + 1) = '\0';
|
||||
@ -804,7 +754,6 @@ FString FString::trim() const
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::left (std::size_t len) const
|
||||
{
|
||||
wchar_t* p;
|
||||
FString s(string);
|
||||
|
||||
// handle NULL and empty string
|
||||
@ -814,7 +763,7 @@ FString FString::left (std::size_t len) const
|
||||
if ( len > length )
|
||||
return s;
|
||||
|
||||
p = s.string;
|
||||
wchar_t* p = s.string;
|
||||
s.length = len;
|
||||
*(p + len) = '\0';
|
||||
return s;
|
||||
@ -823,7 +772,6 @@ FString FString::left (std::size_t len) const
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::right (std::size_t len) const
|
||||
{
|
||||
wchar_t* p;
|
||||
FString s(string);
|
||||
|
||||
// handle NULL and empty string
|
||||
@ -833,7 +781,7 @@ FString FString::right (std::size_t len) const
|
||||
if ( len > length )
|
||||
return s;
|
||||
|
||||
p = s.string;
|
||||
const wchar_t* p = s.string;
|
||||
p += (length - len);
|
||||
return FString(p);
|
||||
}
|
||||
@ -841,8 +789,6 @@ FString FString::right (std::size_t len) const
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::mid (std::size_t pos, std::size_t len) const
|
||||
{
|
||||
wchar_t* p;
|
||||
wchar_t* first;
|
||||
FString s(string);
|
||||
|
||||
// handle NULL and empty string
|
||||
@ -858,8 +804,8 @@ FString FString::mid (std::size_t pos, std::size_t len) const
|
||||
if ( pos > length || pos + len - 1 > length || len == 0 )
|
||||
return FString(L"");
|
||||
|
||||
p = s.string;
|
||||
first = p + pos - 1;
|
||||
wchar_t* p = s.string;
|
||||
wchar_t* first = p + pos - 1;
|
||||
*(first + len) = '\0';
|
||||
return FString(first);
|
||||
}
|
||||
@ -867,17 +813,15 @@ FString FString::mid (std::size_t pos, std::size_t len) const
|
||||
//----------------------------------------------------------------------
|
||||
FStringList FString::split (const FString& delimiter)
|
||||
{
|
||||
wchar_t* rest;
|
||||
wchar_t* token;
|
||||
FString s(string);
|
||||
FStringList string_list;
|
||||
FStringList string_list{};
|
||||
|
||||
// handle NULL and empty string
|
||||
if ( ! (string && *string) )
|
||||
return string_list;
|
||||
|
||||
rest = nullptr;
|
||||
token = extractToken(&rest, s.string, delimiter.wc_str());
|
||||
wchar_t* rest{nullptr};
|
||||
const wchar_t* token = extractToken(&rest, s.string, delimiter.wc_str());
|
||||
|
||||
while ( token )
|
||||
{
|
||||
@ -898,11 +842,9 @@ FString& FString::setString (const FString& s)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::setNumber (sInt64 num)
|
||||
{
|
||||
wchar_t* s;
|
||||
bool neg;
|
||||
bool neg{false};
|
||||
wchar_t buf[30];
|
||||
|
||||
s = &buf[29];
|
||||
wchar_t* s = &buf[29];
|
||||
|
||||
if ( num < 0 )
|
||||
{
|
||||
@ -933,10 +875,8 @@ FString& FString::setNumber (sInt64 num)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::setNumber (uInt64 num)
|
||||
{
|
||||
wchar_t* s;
|
||||
wchar_t buf[30];
|
||||
|
||||
s = &buf[29];
|
||||
wchar_t* s = &buf[29];
|
||||
*s = '\0';
|
||||
|
||||
do
|
||||
@ -953,10 +893,8 @@ FString& FString::setNumber (uInt64 num)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::setNumber (lDouble f_num, int precision)
|
||||
{
|
||||
wchar_t* s;
|
||||
wchar_t format[20]; // = "%.<precision>Lg"
|
||||
|
||||
s = &format[0];
|
||||
wchar_t* s = &format[0];
|
||||
*s++ = L'%';
|
||||
*s++ = L'.';
|
||||
|
||||
@ -986,13 +924,10 @@ FString& FString::setNumber (lDouble f_num, int precision)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::setFormatedNumber (sInt64 num, char separator)
|
||||
{
|
||||
int n;
|
||||
wchar_t* s;
|
||||
bool neg;
|
||||
bool neg{false};
|
||||
int n{0};
|
||||
wchar_t buf[30];
|
||||
|
||||
n = 0;
|
||||
s = &buf[29];
|
||||
wchar_t* s = &buf[29];
|
||||
|
||||
if ( separator == 0 )
|
||||
separator = ' ';
|
||||
@ -1029,12 +964,9 @@ FString& FString::setFormatedNumber (sInt64 num, char separator)
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::setFormatedNumber (uInt64 num, char separator)
|
||||
{
|
||||
int n;
|
||||
wchar_t* s;
|
||||
int n{0};
|
||||
wchar_t buf[30];
|
||||
|
||||
n = 0;
|
||||
s = &buf[29];
|
||||
wchar_t* s = &buf[29];
|
||||
*s = L'\0';
|
||||
|
||||
if ( separator == 0 )
|
||||
@ -1091,7 +1023,7 @@ bool FString::operator == (const FString& s) const
|
||||
if ( ! (string || s.string) )
|
||||
return true;
|
||||
|
||||
if ( bool(string) != bool(s.string) )
|
||||
if ( bool(string) != bool(s.string) || length != s.length )
|
||||
return false;
|
||||
|
||||
return ( std::wcscmp(string, s.string) == 0 );
|
||||
@ -1103,7 +1035,7 @@ bool FString::operator != (const FString& s) const
|
||||
if ( ! (string || s.string) )
|
||||
return false;
|
||||
|
||||
if ( bool(string) != bool(s.string) )
|
||||
if ( bool(string) != bool(s.string) || length != s.length )
|
||||
return true;
|
||||
|
||||
return ( std::wcscmp(string, s.string) != 0 );
|
||||
@ -1162,8 +1094,6 @@ const FString& FString::insert (const FString& s, std::size_t pos)
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::replace (const FString& from, const FString& to)
|
||||
{
|
||||
wchar_t* p;
|
||||
std::size_t from_length, to_length, pos;
|
||||
FString s(string);
|
||||
|
||||
// handle NULL and empty string
|
||||
@ -1176,10 +1106,10 @@ FString FString::replace (const FString& from, const FString& to)
|
||||
if ( from.isEmpty() )
|
||||
return s;
|
||||
|
||||
p = s.string;
|
||||
from_length = from.getLength();
|
||||
to_length = to.getLength();
|
||||
pos = 0;
|
||||
const wchar_t* p = s.string;
|
||||
std::size_t from_length = from.getLength();
|
||||
std::size_t to_length = to.getLength();
|
||||
std::size_t pos{0};
|
||||
|
||||
while ( *p )
|
||||
{
|
||||
@ -1203,32 +1133,24 @@ FString FString::replace (const FString& from, const FString& to)
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::replaceControlCodes() const
|
||||
{
|
||||
wchar_t* p;
|
||||
FString s(string);
|
||||
|
||||
p = s.string;
|
||||
|
||||
if ( p )
|
||||
for (auto&& c : s)
|
||||
{
|
||||
while ( *p )
|
||||
if ( c <= L'\x1f' )
|
||||
{
|
||||
if ( *p <= L'\x1f' )
|
||||
{
|
||||
*p += L'\x2400';
|
||||
}
|
||||
else if ( *p == L'\x7f' )
|
||||
{
|
||||
*p = L'\x2421';
|
||||
}
|
||||
else if ( *p >= L'\x80' && *p <= L'\x9f' )
|
||||
{
|
||||
*p = L' ';
|
||||
}
|
||||
else if ( ! std::iswprint(wint_t(*p)) )
|
||||
*p = L' ';
|
||||
|
||||
p++;
|
||||
c += L'\x2400';
|
||||
}
|
||||
else if ( c == L'\x7f' )
|
||||
{
|
||||
c = L'\x2421';
|
||||
}
|
||||
else if ( c >= L'\x80' && c <= L'\x9f' )
|
||||
{
|
||||
c = L' ';
|
||||
}
|
||||
else if ( ! std::iswprint(std::wint_t(c)) )
|
||||
c = L' ';
|
||||
}
|
||||
|
||||
return s;
|
||||
@ -1237,18 +1159,16 @@ FString FString::replaceControlCodes() const
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::expandTabs (int tabstop) const
|
||||
{
|
||||
uLong last;
|
||||
FStringList tab_split;
|
||||
FString instr(string);
|
||||
FString outstr;
|
||||
FString outstr{};
|
||||
|
||||
if ( tabstop <= 0 )
|
||||
return instr;
|
||||
|
||||
tab_split = instr.split("\t");
|
||||
last = tab_split.size();
|
||||
FStringList tab_split = instr.split("\t");
|
||||
uLong last = tab_split.size();
|
||||
|
||||
for (std::size_t i = 0; i < last; i++)
|
||||
for (std::size_t i{0}; i < last; i++)
|
||||
{
|
||||
std::size_t len = tab_split[i].getLength();
|
||||
std::size_t tab_len = std::size_t(tabstop);
|
||||
@ -1265,38 +1185,29 @@ FString FString::expandTabs (int tabstop) const
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::removeDel() const
|
||||
{
|
||||
wchar_t* p;
|
||||
FString s(string);
|
||||
p = s.string;
|
||||
std::size_t i{0};
|
||||
std::size_t count{0};
|
||||
|
||||
if ( p )
|
||||
for (auto&& c : s)
|
||||
{
|
||||
uInt i = 0;
|
||||
uInt d = 0;
|
||||
|
||||
while ( *p )
|
||||
if ( c == 0x7f )
|
||||
{
|
||||
if ( *p == 0x7f )
|
||||
{
|
||||
d++;
|
||||
}
|
||||
else if ( d > 0 )
|
||||
{
|
||||
d--;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.string[i] = *p;
|
||||
i++;
|
||||
}
|
||||
|
||||
p++;
|
||||
count++;
|
||||
}
|
||||
else if ( count > 0 )
|
||||
{
|
||||
count--;
|
||||
}
|
||||
else // count == 0
|
||||
{
|
||||
s.string[i] = c;
|
||||
i++;
|
||||
}
|
||||
|
||||
s.string[i] = L'\0';
|
||||
s.length = i;
|
||||
}
|
||||
|
||||
s.string[i] = L'\0';
|
||||
s.length = i;
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -1304,33 +1215,24 @@ FString FString::removeDel() const
|
||||
//----------------------------------------------------------------------
|
||||
FString FString::removeBackspaces() const
|
||||
{
|
||||
wchar_t* p;
|
||||
FString s(string);
|
||||
p = s.string;
|
||||
std::size_t i{0};
|
||||
|
||||
if ( p )
|
||||
for (auto&& c : s)
|
||||
{
|
||||
uInt i = 0;
|
||||
|
||||
while ( *p )
|
||||
if ( c != L'\b' )
|
||||
{
|
||||
if ( *p != L'\b' )
|
||||
{
|
||||
s.string[i] = *p;
|
||||
i++;
|
||||
}
|
||||
else if ( i > 0 )
|
||||
{
|
||||
i--;
|
||||
}
|
||||
|
||||
p++;
|
||||
s.string[i] = c;
|
||||
i++;
|
||||
}
|
||||
else if ( i > 0 )
|
||||
{
|
||||
i--;
|
||||
}
|
||||
|
||||
s.string[i] = L'\0';
|
||||
s.length = i;
|
||||
}
|
||||
|
||||
s.string[i] = L'\0';
|
||||
s.length = i;
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -1411,7 +1313,7 @@ inline void FString::initLength (std::size_t len)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FString::_assign (const wchar_t s[])
|
||||
void FString::_assign (const wchar_t s[])
|
||||
{
|
||||
if ( ! s )
|
||||
{
|
||||
@ -1422,7 +1324,7 @@ inline void FString::_assign (const wchar_t s[])
|
||||
if ( string && std::wcscmp(string, s) == 0 )
|
||||
return; // string == s
|
||||
|
||||
uInt new_length = uInt(std::wcslen(s));
|
||||
uInt new_length= uInt(std::wcslen(s));
|
||||
|
||||
if ( ! string || new_length > capacity() )
|
||||
{
|
||||
@ -1448,7 +1350,7 @@ inline void FString::_assign (const wchar_t s[])
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FString::_insert (std::size_t len, const wchar_t s[])
|
||||
void FString::_insert (std::size_t len, const wchar_t s[])
|
||||
{
|
||||
if ( len == 0 ) // String s is a null or a empty string
|
||||
return;
|
||||
@ -1474,9 +1376,9 @@ inline void FString::_insert (std::size_t len, const wchar_t s[])
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FString::_insert ( std::size_t pos
|
||||
, std::size_t len
|
||||
, const wchar_t s[] )
|
||||
void FString::_insert ( std::size_t pos
|
||||
, std::size_t len
|
||||
, const wchar_t s[] )
|
||||
{
|
||||
if ( len == 0 ) // String s is a null or a empty string
|
||||
return;
|
||||
@ -1487,7 +1389,7 @@ inline void FString::_insert ( std::size_t pos
|
||||
}
|
||||
else
|
||||
{
|
||||
std::size_t x;
|
||||
std::size_t x{};
|
||||
|
||||
if ( length + len <= capacity() )
|
||||
{
|
||||
@ -1502,9 +1404,9 @@ inline void FString::_insert ( std::size_t pos
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t* sptr;
|
||||
// output string > bufsize
|
||||
bufsize = FWDBUFFER + length + len + 1;
|
||||
wchar_t* sptr{};
|
||||
|
||||
try
|
||||
{
|
||||
@ -1516,7 +1418,7 @@ inline void FString::_insert ( std::size_t pos
|
||||
return;
|
||||
}
|
||||
|
||||
std::size_t y = 0;
|
||||
std::size_t y{0};
|
||||
|
||||
for (x = 0; x < pos; x++) // left side
|
||||
sptr[y++] = string[x];
|
||||
@ -1535,7 +1437,7 @@ inline void FString::_insert ( std::size_t pos
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FString::_remove (std::size_t pos, std::size_t len)
|
||||
void FString::_remove (std::size_t pos, std::size_t len)
|
||||
{
|
||||
if ( capacity() - length + len <= FWDBUFFER )
|
||||
{
|
||||
@ -1547,8 +1449,8 @@ inline void FString::_remove (std::size_t pos, std::size_t len)
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t* sptr;
|
||||
bufsize = length + 1 - len + FWDBUFFER;
|
||||
wchar_t* sptr{};
|
||||
|
||||
try
|
||||
{
|
||||
@ -1560,7 +1462,7 @@ inline void FString::_remove (std::size_t pos, std::size_t len)
|
||||
return;
|
||||
}
|
||||
|
||||
std::size_t x, y = 0;
|
||||
std::size_t x{}, y{};
|
||||
|
||||
for (x = 0; x < pos; x++) // left side
|
||||
sptr[y++] = string[x];
|
||||
@ -1577,11 +1479,6 @@ inline void FString::_remove (std::size_t pos, std::size_t len)
|
||||
//----------------------------------------------------------------------
|
||||
inline char* FString::wc_to_c_str (const wchar_t s[]) const
|
||||
{
|
||||
int mblength
|
||||
, size
|
||||
, dest_size;
|
||||
const wchar_t* src;
|
||||
|
||||
if ( ! s ) // handle NULL string
|
||||
return 0;
|
||||
|
||||
@ -1604,10 +1501,10 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
|
||||
if ( c_string )
|
||||
delete[](c_string);
|
||||
|
||||
size = int(std::wcslen(s)) + 1;
|
||||
dest_size = size * int(CHAR_SIZE);
|
||||
src = s;
|
||||
std::mbstate_t state;
|
||||
int size = int(std::wcslen(s)) + 1;
|
||||
int dest_size = size * int(CHAR_SIZE);
|
||||
const wchar_t* src = s;
|
||||
std::mbstate_t state{};
|
||||
std::memset (&state, '\0', sizeof(mbstate_t));
|
||||
|
||||
try
|
||||
@ -1623,7 +1520,8 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
mblength = int(std::wcsrtombs (c_string, &src, std::size_t(dest_size), &state));
|
||||
int mblength = \
|
||||
int(std::wcsrtombs (c_string, &src, std::size_t(dest_size), &state));
|
||||
|
||||
if ( mblength == -1 && errno != EILSEQ )
|
||||
{
|
||||
@ -1638,12 +1536,6 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
|
||||
//----------------------------------------------------------------------
|
||||
inline wchar_t* FString::c_to_wc_str (const char s[]) const
|
||||
{
|
||||
int wclength
|
||||
, size
|
||||
, dest_size;
|
||||
const char* src;
|
||||
wchar_t* dest;
|
||||
|
||||
if ( ! s ) // handle NULL string
|
||||
return 0;
|
||||
|
||||
@ -1661,10 +1553,11 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const
|
||||
}
|
||||
}
|
||||
|
||||
size = int(std::strlen(s)) + 1;
|
||||
dest_size = size * int(CHAR_SIZE);
|
||||
src = s;
|
||||
std::mbstate_t state;
|
||||
int size = int(std::strlen(s)) + 1;
|
||||
int dest_size = size * int(CHAR_SIZE);
|
||||
const char* src = s;
|
||||
wchar_t* dest{};
|
||||
std::mbstate_t state{};
|
||||
std::memset (&state, '\0', sizeof(mbstate_t));
|
||||
|
||||
try
|
||||
@ -1679,7 +1572,8 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
wclength = int(std::mbsrtowcs (dest, &src, std::size_t(dest_size), &state));
|
||||
int wclength = \
|
||||
int(std::mbsrtowcs (dest, &src, std::size_t(dest_size), &state));
|
||||
|
||||
if ( wclength == -1 )
|
||||
{
|
||||
@ -1709,8 +1603,7 @@ inline wchar_t* FString::extractToken ( wchar_t* rest[]
|
||||
, const wchar_t s[]
|
||||
, const wchar_t delim[] )
|
||||
{
|
||||
wchar_t* token;
|
||||
token = ( s ) ? const_cast<wchar_t*>(s) : *rest;
|
||||
wchar_t* token = ( s ) ? const_cast<wchar_t*>(s) : *rest;
|
||||
|
||||
if ( ! token )
|
||||
return 0;
|
||||
@ -1826,11 +1719,9 @@ std::ostream& operator << (std::ostream& outstr, const FString& s)
|
||||
//----------------------------------------------------------------------
|
||||
std::istream& operator >> (std::istream& instr, FString& s)
|
||||
{
|
||||
const wchar_t* wc_str;
|
||||
char buf[FString::INPBUFFER + 1];
|
||||
|
||||
char buf[FString::INPBUFFER + 1]{};
|
||||
instr.getline (buf, FString::INPBUFFER);
|
||||
wc_str = s.c_to_wc_str(buf);
|
||||
const wchar_t* wc_str = s.c_to_wc_str(buf);
|
||||
|
||||
if ( wc_str )
|
||||
{
|
||||
@ -1853,7 +1744,7 @@ std::wostream& operator << (std::wostream& outstr, const FString& s)
|
||||
//----------------------------------------------------------------------
|
||||
std::wistream& operator >> (std::wistream& instr, FString& s)
|
||||
{
|
||||
wchar_t buf[FString::INPBUFFER + 1];
|
||||
wchar_t buf[FString::INPBUFFER + 1]{};
|
||||
instr.getline (buf, FString::INPBUFFER);
|
||||
s._assign (buf);
|
||||
return instr;
|
||||
|
@ -20,7 +20,10 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fcolorpair.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/fswitch.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -34,7 +37,7 @@ namespace finalcut
|
||||
FSwitch::FSwitch(FWidget* parent)
|
||||
: FToggleButton(parent)
|
||||
{
|
||||
button_width = 11;
|
||||
setButtonWidth(11);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -42,7 +45,7 @@ FSwitch::FSwitch (const FString& txt, FWidget* parent)
|
||||
: FToggleButton(txt, parent)
|
||||
{
|
||||
switch_offset_pos = txt.getLength() + 1;
|
||||
button_width = 11;
|
||||
setButtonWidth(11);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -114,6 +117,9 @@ void FSwitch::onMouseUp (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FSwitch::draw()
|
||||
{
|
||||
if ( ! isVisible() )
|
||||
return;
|
||||
|
||||
drawLabel();
|
||||
drawCheckButton();
|
||||
FToggleButton::draw();
|
||||
@ -124,22 +130,20 @@ void FSwitch::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void FSwitch::drawCheckButton()
|
||||
{
|
||||
if ( ! isVisible() )
|
||||
return;
|
||||
|
||||
print() << FPoint(1 + int(switch_offset_pos), 1);
|
||||
|
||||
if ( checked )
|
||||
if ( isChecked() )
|
||||
drawChecked();
|
||||
else
|
||||
drawUnchecked();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FSwitch::drawChecked()
|
||||
inline void FSwitch::drawChecked()
|
||||
{
|
||||
wchar_t on[6] = L" On ";
|
||||
wchar_t off[6] = L" Off ";
|
||||
wchar_t on[6]{L" On "};
|
||||
wchar_t off[6]{L" Off "};
|
||||
const auto& wc = getFWidgetColors();
|
||||
|
||||
if ( hasFocus() && ! button_pressed )
|
||||
{
|
||||
@ -185,11 +189,12 @@ void FSwitch::drawChecked()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FSwitch::drawUnchecked()
|
||||
inline void FSwitch::drawUnchecked()
|
||||
{
|
||||
wchar_t on[6] = L" On ";
|
||||
wchar_t off[6] = L" Off ";
|
||||
wchar_t on[6]{L" On "};
|
||||
wchar_t off[6]{L" Off "};
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.button_inactive_fg, wc.button_inactive_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
|
42
src/fsystem.cpp
Normal file
42
src/fsystem.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
/***********************************************************************
|
||||
* fsystem.cpp - Abstract class for system calls *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2019 Markus Gans *
|
||||
* *
|
||||
* The 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. *
|
||||
* *
|
||||
* The 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/fsystem.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FSystem
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FSystem::FSystem()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FSystem::~FSystem() // destructor
|
||||
{ }
|
||||
|
||||
} // namespace finalcut
|
||||
|
42
src/fsystemimpl.cpp
Normal file
42
src/fsystemimpl.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
/***********************************************************************
|
||||
* fsystemimpl.cpp - FSystem implementation *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2019 Markus Gans *
|
||||
* *
|
||||
* The 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. *
|
||||
* *
|
||||
* The 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/fsystemimpl.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FSystemImpl
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FSystemImpl::FSystemImpl()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FSystemImpl::~FSystemImpl() // destructor
|
||||
{ }
|
||||
|
||||
} // namespace finalcut
|
||||
|
1255
src/fterm.cpp
1255
src/fterm.cpp
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,12 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fcolorpair.h"
|
||||
#include "final/fstring.h"
|
||||
#include "final/ftermbuffer.h"
|
||||
#include "final/fvterm.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
@ -36,56 +41,43 @@ FTermBuffer::~FTermBuffer() // destructor
|
||||
|
||||
// public methods of FTermBuffer
|
||||
//----------------------------------------------------------------------
|
||||
int FTermBuffer::writef (const FString format, ...)
|
||||
const FString FTermBuffer::toString() const
|
||||
{
|
||||
static constexpr int BUFSIZE = 4096;
|
||||
wchar_t buffer[BUFSIZE];
|
||||
va_list args;
|
||||
std::wstring wide_string{};
|
||||
wide_string.reserve(data.size());
|
||||
|
||||
if ( format.isEmpty() )
|
||||
return 0;
|
||||
for (auto&& tc : data)
|
||||
wide_string.push_back(tc.code);
|
||||
|
||||
va_start (args, format);
|
||||
std::vswprintf (buffer, BUFSIZE, format.wc_str(), args);
|
||||
va_end (args);
|
||||
|
||||
FString str(buffer);
|
||||
return write(str);
|
||||
return FString(wide_string);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FTermBuffer::write (const FString& s)
|
||||
int FTermBuffer::write (const FString& string)
|
||||
{
|
||||
assert ( ! s.isNull() );
|
||||
int len = 0;
|
||||
const wchar_t* p = s.wc_str();
|
||||
assert ( ! string.isNull() );
|
||||
int len = int(string.getLength());
|
||||
|
||||
if ( p )
|
||||
for (auto&& c : string)
|
||||
{
|
||||
while ( *p )
|
||||
{
|
||||
charData nc; // next character
|
||||
nc = FVTerm::getAttribute();
|
||||
nc.code = *p;
|
||||
nc.attr.bit.no_changes = false;
|
||||
nc.attr.bit.printed = false;
|
||||
|
||||
data.push_back(nc);
|
||||
|
||||
p++;
|
||||
len++;
|
||||
} // end of while
|
||||
charData nc; // next character
|
||||
nc = FVTerm::getAttribute();
|
||||
nc.code = c;
|
||||
getColumnWidth(nc); // add column width
|
||||
nc.attr.bit.no_changes = false;
|
||||
nc.attr.bit.printed = false;
|
||||
data.push_back(nc);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FTermBuffer::write (wchar_t c)
|
||||
int FTermBuffer::write (wchar_t ch)
|
||||
{
|
||||
charData nc; // next character
|
||||
nc = FVTerm::getAttribute();
|
||||
nc.code = c;
|
||||
charData nc = FVTerm::getAttribute(); // next character
|
||||
nc.code = ch;
|
||||
getColumnWidth(nc); // add column width
|
||||
nc.attr.bit.no_changes = false;
|
||||
nc.attr.bit.printed = false;
|
||||
|
||||
@ -96,18 +88,14 @@ int FTermBuffer::write (wchar_t c)
|
||||
//----------------------------------------------------------------------
|
||||
void FTermBuffer::write (const FColorPair& pair)
|
||||
{
|
||||
charData nc; // next character
|
||||
nc = FVTerm::getAttribute();
|
||||
nc.fg_color = pair.fg_color;
|
||||
nc.bg_color = pair.bg_color;
|
||||
FVTerm::setColor(pair.getForegroundColor(), pair.getBackgroundColor());
|
||||
}
|
||||
|
||||
|
||||
// FTermBuffer non-member operators
|
||||
//----------------------------------------------------------------------
|
||||
std::vector<FTermBuffer::charData>& operator << \
|
||||
( std::vector<FTermBuffer::charData>& termString
|
||||
, const FTermBuffer& buf )
|
||||
FTermBuffer::charDataVector& operator << ( FTermBuffer::charDataVector& termString
|
||||
, const FTermBuffer& buf )
|
||||
{
|
||||
if ( ! buf.data.empty() )
|
||||
termString.assign(buf.data.begin(), buf.data.end());
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2018 Markus Gans *
|
||||
* Copyright 2015-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -24,25 +24,31 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "final/emptyfstring.h"
|
||||
#include "final/fc.h"
|
||||
#include "final/fkey_map.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermdata.h"
|
||||
#include "final/ftermcap.h"
|
||||
#include "final/ftermdetection.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
bool FTermcap::background_color_erase = false;
|
||||
bool FTermcap::can_change_color_palette = false;
|
||||
bool FTermcap::automatic_left_margin = false;
|
||||
bool FTermcap::automatic_right_margin = false;
|
||||
bool FTermcap::eat_nl_glitch = false;
|
||||
bool FTermcap::ansi_default_color = false;
|
||||
bool FTermcap::osc_support = false;
|
||||
bool FTermcap::no_utf8_acs_chars = false;
|
||||
int FTermcap::max_color = 1;
|
||||
int FTermcap::tabstop = 8;
|
||||
int FTermcap::attr_without_color = 0;
|
||||
FTermData* FTermcap::fterm_data = nullptr;
|
||||
FTermDetection* FTermcap::term_detection = nullptr;
|
||||
bool FTermcap::background_color_erase {false};
|
||||
bool FTermcap::can_change_color_palette{false};
|
||||
bool FTermcap::automatic_left_margin {false};
|
||||
bool FTermcap::automatic_right_margin {false};
|
||||
bool FTermcap::eat_nl_glitch {false};
|
||||
bool FTermcap::ansi_default_color {false};
|
||||
bool FTermcap::osc_support {false};
|
||||
bool FTermcap::no_utf8_acs_chars {false};
|
||||
int FTermcap::max_color {1};
|
||||
int FTermcap::tabstop {8};
|
||||
int FTermcap::attr_without_color {0};
|
||||
FTermData* FTermcap::fterm_data {nullptr};
|
||||
FTermDetection* FTermcap::term_detection {nullptr};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -59,21 +65,11 @@ FTermDetection* FTermcap::term_detection = nullptr;
|
||||
*/
|
||||
|
||||
// public methods of FTermcap
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcap::setFTermData (FTermData* data)
|
||||
{
|
||||
fterm_data = data;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcap::setFTermDetection (FTermDetection* td)
|
||||
{
|
||||
term_detection = td;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcap::init()
|
||||
{
|
||||
fterm_data = FTerm::getFTermData();
|
||||
term_detection = FTerm::getFTermDetection();
|
||||
termcap();
|
||||
}
|
||||
|
||||
@ -81,11 +77,11 @@ void FTermcap::init()
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcap::termcap()
|
||||
{
|
||||
std::vector<std::string> terminals;
|
||||
std::vector<std::string> terminals{};
|
||||
static constexpr int success = 1;
|
||||
static constexpr int uninitialized = -2;
|
||||
static char term_buffer[2048];
|
||||
static char string_buf[2048];
|
||||
static char term_buffer[2048]{};
|
||||
static char string_buf[2048]{};
|
||||
char* buffer = string_buf;
|
||||
int status = uninitialized;
|
||||
bool color256 = term_detection->canDisplay256Colors();
|
||||
@ -225,8 +221,8 @@ void FTermcap::termcapStrings (char*& buffer)
|
||||
// Get termcap strings
|
||||
|
||||
// Read termcap output strings
|
||||
for (std::size_t i = 0; tcap[i].tname[0] != 0; i++)
|
||||
tcap[i].string = tgetstr(tcap[i].tname, &buffer);
|
||||
for (std::size_t i{0}; strings[i].tname[0] != 0; i++)
|
||||
strings[i].string = tgetstr(strings[i].tname, &buffer);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -234,7 +230,7 @@ void FTermcap::termcapKeys (char*& buffer)
|
||||
{
|
||||
// Read termcap key strings
|
||||
|
||||
for (std::size_t i = 0; fc::Fkey[i].tname[0] != 0; i++)
|
||||
for (std::size_t i{0}; fc::Fkey[i].tname[0] != 0; i++)
|
||||
{
|
||||
fc::Fkey[i].string = tgetstr(fc::Fkey[i].tname, &buffer);
|
||||
|
||||
@ -290,11 +286,11 @@ void FTermcap::termcapKeysVt100 (char*& buffer)
|
||||
|
||||
const char* key_up_string = tgetstr(C_STR("ku"), &buffer);
|
||||
|
||||
if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0))
|
||||
if ( (key_up_string && (std::strcmp(key_up_string, ESC "OA") == 0))
|
||||
|| ( TCAP(fc::t_cursor_up)
|
||||
&& (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
|
||||
{
|
||||
for (std::size_t i = 0; fc::Fkey[i].tname[0] != 0; i++)
|
||||
for (std::size_t i{0}; fc::Fkey[i].tname[0] != 0; i++)
|
||||
{
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kux", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "A"); // Key up
|
||||
@ -326,7 +322,7 @@ void FTermcap::termcapKeysVt100 (char*& buffer)
|
||||
|
||||
// private Data Member of FTermcap - termcap capabilities
|
||||
//----------------------------------------------------------------------
|
||||
FTermcap::tcap_map FTermcap::tcap[] =
|
||||
FTermcap::tcap_map FTermcap::strings[] =
|
||||
{
|
||||
// .------------- term string
|
||||
// | .-------- Tcap-code
|
||||
|
@ -22,15 +22,20 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fkey_map.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermcap.h"
|
||||
#include "final/ftermcapquirks.h"
|
||||
#include "final/ftermdata.h"
|
||||
#include "final/ftermdetection.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
FTermcap::tcap_map* FTermcapQuirks::tcap = nullptr;
|
||||
FTermData* FTermcapQuirks::fterm_data = nullptr;
|
||||
FTermDetection* FTermcapQuirks::term_detection = nullptr;
|
||||
FTermData* FTermcapQuirks::fterm_data {nullptr};
|
||||
FTermDetection* FTermcapQuirks::term_detection {nullptr};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -40,9 +45,7 @@ FTermDetection* FTermcapQuirks::term_detection = nullptr;
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FTermcapQuirks::FTermcapQuirks()
|
||||
{
|
||||
tcap = FTermcap::getTermcapMap();
|
||||
}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTermcapQuirks::~FTermcapQuirks() // destructor
|
||||
@ -51,22 +54,10 @@ FTermcapQuirks::~FTermcapQuirks() // destructor
|
||||
|
||||
// public methods of FTermcapQuirks
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::setFTermData (FTermData* data)
|
||||
{
|
||||
fterm_data = data;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::setFTermDetection (FTermDetection* td)
|
||||
{
|
||||
term_detection = td;
|
||||
}
|
||||
|
||||
|
||||
// private methods of FTermcapQuirks
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::terminalFixup()
|
||||
{
|
||||
fterm_data = FTerm::getFTermData();
|
||||
term_detection = FTerm::getFTermDetection();
|
||||
auto& td = term_detection;
|
||||
|
||||
if ( td->isCygwinTerminal() )
|
||||
@ -101,12 +92,12 @@ void FTermcapQuirks::terminalFixup()
|
||||
{
|
||||
screen();
|
||||
}
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
else if ( td->isFreeBSDTerm() )
|
||||
{
|
||||
freebsd();
|
||||
}
|
||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
|
||||
// xterm and compatible terminals
|
||||
if ( td->isXTerminal() && ! td->isPuttyTerminal() )
|
||||
@ -118,8 +109,10 @@ void FTermcapQuirks::terminalFixup()
|
||||
ecma48();
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
|
||||
// private methods of FTermcapQuirks
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
void FTermcapQuirks::freebsd()
|
||||
{
|
||||
// FreeBSD console fixes
|
||||
@ -143,7 +136,7 @@ void FTermcapQuirks::freebsd()
|
||||
|
||||
FTermcap::attr_without_color = 18;
|
||||
}
|
||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::cygwin()
|
||||
@ -409,7 +402,7 @@ void FTermcapQuirks::sunConsole()
|
||||
C_STR(CSI "%p1%dD");
|
||||
|
||||
// Sun Microsystems workstation console keys
|
||||
for (std::size_t i = 0; fc::Fkey[i].tname[0] != 0; i++)
|
||||
for (std::size_t i{0}; fc::Fkey[i].tname[0] != 0; i++)
|
||||
{
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "K2", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "218z"); // center of keypad
|
||||
|
90
src/ftermdebugdata.cpp
Normal file
90
src/ftermdebugdata.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
/***********************************************************************
|
||||
* ftermdebugdata.cpp - Debug data class for FTerm *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2019 Markus Gans *
|
||||
* *
|
||||
* The 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. *
|
||||
* *
|
||||
* The 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/fc.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermdata.h"
|
||||
#include "final/ftermdetection.h"
|
||||
#include "final/ftermdebugdata.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
#if DEBUG
|
||||
// static class attributes
|
||||
FTermData* FTermDebugData::data {nullptr};
|
||||
FTermDetection* FTermDebugData::term_detection {nullptr};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FClassName
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// public methods of FClassName
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDebugData::init()
|
||||
{
|
||||
data = FTerm::getFTermData();
|
||||
term_detection = FTerm::getFTermDetection();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDebugData::getAnswerbackString()
|
||||
{
|
||||
return term_detection->getAnswerbackString();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDebugData::getSecDAString()
|
||||
{
|
||||
return term_detection->getSecDAString();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDebugData::getTermType_256color()
|
||||
{
|
||||
return term_detection->getTermType_256color();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDebugData::getTermType_Answerback()
|
||||
{
|
||||
return term_detection->getTermType_Answerback();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDebugData::getTermType_SecDA()
|
||||
{
|
||||
return term_detection->getTermType_SecDA();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(__linux__)
|
||||
int FTermDebugData::getFramebufferBpp()
|
||||
{
|
||||
return data->getFramebufferBpp();
|
||||
}
|
||||
#endif // defined(__linux__)
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -20,31 +20,50 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
#include "final/fconfig.h" // includes _GNU_SOURCE for fd_set
|
||||
#endif
|
||||
|
||||
#include "final/emptyfstring.h"
|
||||
#include "final/fc.h"
|
||||
#include "final/fconfig.h"
|
||||
#include "final/fsystem.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermdata.h"
|
||||
#include "final/ftermdetection.h"
|
||||
#include "final/ftermios.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
#include "final/ftermfreebsd.h"
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
#include "final/ftermopenbsd.h"
|
||||
#endif
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
FTermDetection::terminalType FTermDetection::terminal_type = \
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
FTermDetection::colorEnv FTermDetection::color_env;
|
||||
FTermDetection::secondaryDA FTermDetection::secondary_da;
|
||||
FTermData* FTermDetection::fterm_data = nullptr;
|
||||
char FTermDetection::termtype[256] = { };
|
||||
char FTermDetection::ttytypename[256] = { };
|
||||
bool FTermDetection::decscusr_support;
|
||||
bool FTermDetection::terminal_detection;
|
||||
bool FTermDetection::color256;
|
||||
const FString* FTermDetection::answer_back = nullptr;
|
||||
const FString* FTermDetection::sec_da = nullptr;
|
||||
int FTermDetection::gnome_terminal_id;
|
||||
FTermDetection::terminalType FTermDetection::terminal_type{};
|
||||
FTermDetection::colorEnv FTermDetection::color_env{};
|
||||
FTermDetection::secondaryDA FTermDetection::secondary_da{};
|
||||
FTermData* FTermDetection::fterm_data{nullptr};
|
||||
FSystem* FTermDetection::fsystem{nullptr};
|
||||
char FTermDetection::termtype[256]{};
|
||||
char FTermDetection::ttytypename[256]{};
|
||||
bool FTermDetection::decscusr_support{};
|
||||
bool FTermDetection::terminal_detection{};
|
||||
bool FTermDetection::color256{};
|
||||
const FString* FTermDetection::answer_back{nullptr};
|
||||
const FString* FTermDetection::sec_da{nullptr};
|
||||
int FTermDetection::gnome_terminal_id{};
|
||||
|
||||
#if DEBUG
|
||||
char FTermDetection::termtype_256color[256] = { };
|
||||
char FTermDetection::termtype_Answerback[256] = { };
|
||||
char FTermDetection::termtype_SecDA[256] = { };
|
||||
char FTermDetection::termtype_256color[256]{};
|
||||
char FTermDetection::termtype_Answerback[256]{};
|
||||
char FTermDetection::termtype_SecDA[256]{};
|
||||
#endif // DEBUG
|
||||
|
||||
|
||||
@ -67,10 +86,6 @@ FTermDetection::FTermDetection()
|
||||
// a.b.c = a * 100 + b * 100 + c
|
||||
gnome_terminal_id = 0;
|
||||
|
||||
// Initialize the structs
|
||||
color_env.setDefault();
|
||||
secondary_da.setDefault();
|
||||
|
||||
// Set default ttytype file
|
||||
std::strncpy (ttytypename, C_STR("/etc/ttytype"), sizeof(ttytypename));
|
||||
ttytypename[sizeof(ttytypename) - 1] = '\0';
|
||||
@ -85,11 +100,19 @@ FTermDetection::~FTermDetection() // destructor
|
||||
|
||||
// public methods of FTermDetection
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDetection::setFTermData (FTermData* data)
|
||||
#if DEBUG
|
||||
const FString& FTermDetection::getAnswerbackString()
|
||||
{
|
||||
fterm_data = data;
|
||||
return ( answer_back ) ? *answer_back : fc::emptyFString::get();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDetection::getSecDAString()
|
||||
{
|
||||
return ( sec_da ) ? *sec_da : fc::emptyFString::get();
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDetection::setTtyTypeFileName (char ttytype_filename[])
|
||||
{
|
||||
@ -103,6 +126,8 @@ void FTermDetection::setTtyTypeFileName (char ttytype_filename[])
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDetection::detect()
|
||||
{
|
||||
fterm_data = FTerm::getFTermData();
|
||||
fsystem = FTerm::getFSystem();
|
||||
deallocation();
|
||||
|
||||
// Set the variable 'termtype' to the predefined type of the terminal
|
||||
@ -178,20 +203,17 @@ bool FTermDetection::getTTYtype()
|
||||
else
|
||||
term_basename++;
|
||||
|
||||
std::FILE *fp;
|
||||
std::FILE* fp{};
|
||||
char str[BUFSIZ]{};
|
||||
|
||||
if ( (fp = std::fopen(ttytypename, "r")) != 0 )
|
||||
if ( fsystem && (fp = fsystem->fopen(ttytypename, "r")) != 0 )
|
||||
{
|
||||
char* p;
|
||||
char str[BUFSIZ];
|
||||
|
||||
// Read and parse the file
|
||||
while ( fgets(str, sizeof(str) - 1, fp) != 0 )
|
||||
{
|
||||
char* name;
|
||||
char* type;
|
||||
type = name = nullptr; // nullptr == not found
|
||||
p = str;
|
||||
const char* type{nullptr}; // nullptr == not found
|
||||
const char* name{nullptr};
|
||||
char* p = str;
|
||||
|
||||
while ( *p )
|
||||
{
|
||||
@ -210,12 +232,12 @@ bool FTermDetection::getTTYtype()
|
||||
// Save name in termtype
|
||||
std::strncpy (termtype, type, sizeof(termtype));
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
std::fclose(fp);
|
||||
fsystem->fclose(fp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::fclose(fp);
|
||||
fsystem->fclose(fp);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -241,7 +263,7 @@ bool FTermDetection::getTTYSFileEntry()
|
||||
|
||||
if ( ttys_entryt )
|
||||
{
|
||||
char* type = ttys_entryt->ty_type;
|
||||
const char* type = ttys_entryt->ty_type;
|
||||
|
||||
if ( type != 0 )
|
||||
{
|
||||
@ -298,7 +320,7 @@ void FTermDetection::termtypeAnalysis()
|
||||
if ( std::strncmp(termtype, "screen", 6) == 0 )
|
||||
{
|
||||
terminal_type.screen = true;
|
||||
char* tmux = std::getenv("TMUX");
|
||||
const char* tmux = std::getenv("TMUX");
|
||||
|
||||
if ( tmux && std::strlen(tmux) != 0 )
|
||||
terminal_type.tmux = true;
|
||||
@ -319,7 +341,7 @@ void FTermDetection::detectTerminal()
|
||||
{
|
||||
// Terminal detection
|
||||
|
||||
char* new_termtype = nullptr;
|
||||
char* new_termtype{nullptr};
|
||||
|
||||
if ( terminal_detection )
|
||||
{
|
||||
@ -367,7 +389,7 @@ void FTermDetection::detectTerminal()
|
||||
//----------------------------------------------------------------------
|
||||
char* FTermDetection::init_256colorTerminal()
|
||||
{
|
||||
char* new_termtype = nullptr;
|
||||
char* new_termtype{nullptr};
|
||||
|
||||
if ( get256colorEnvString() )
|
||||
color256 = true;
|
||||
@ -430,7 +452,7 @@ bool FTermDetection::get256colorEnvString()
|
||||
//----------------------------------------------------------------------
|
||||
char* FTermDetection::termtype_256color_quirks()
|
||||
{
|
||||
char* new_termtype = nullptr;
|
||||
char* new_termtype{nullptr};
|
||||
|
||||
if ( ! color256 )
|
||||
return new_termtype;
|
||||
@ -517,16 +539,15 @@ char* FTermDetection::determineMaxColor (char current_termtype[])
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString FTermDetection::getXTermColorName (int color)
|
||||
const FString FTermDetection::getXTermColorName (FColor color)
|
||||
{
|
||||
FString color_str("");
|
||||
|
||||
fd_set ifds;
|
||||
struct timeval tv;
|
||||
FString color_str{""};
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
int stdin_no = FTermios::getStdIn();
|
||||
|
||||
char temp[512] = { };
|
||||
std::fprintf (stdout, OSC "4;%d;?" BEL, color); // get color
|
||||
char temp[512]{};
|
||||
std::fprintf (stdout, OSC "4;%hu;?" BEL, color); // get color
|
||||
std::fflush(stdout);
|
||||
|
||||
FD_ZERO(&ifds);
|
||||
@ -537,7 +558,7 @@ const FString FTermDetection::getXTermColorName (int color)
|
||||
// read the terminal answer
|
||||
if ( select (stdin_no + 1, &ifds, 0, 0, &tv) > 0 )
|
||||
{
|
||||
if ( std::scanf("\033]4;%10d;%509[^\n]s", &color, temp) == 2 )
|
||||
if ( std::scanf("\033]4;%10hu;%509[^\n]s", &color, temp) == 2 )
|
||||
{
|
||||
std::size_t n = std::strlen(temp);
|
||||
|
||||
@ -602,11 +623,10 @@ char* FTermDetection::parseAnswerbackMsg (char current_termtype[])
|
||||
//----------------------------------------------------------------------
|
||||
const FString FTermDetection::getAnswerbackMsg()
|
||||
{
|
||||
FString answerback = "";
|
||||
|
||||
fd_set ifds;
|
||||
struct timeval tv;
|
||||
char temp[10] = { };
|
||||
FString answerback{""};
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
char temp[10]{};
|
||||
int stdin_no = FTermios::getStdIn();
|
||||
|
||||
std::putchar (ENQ[0]); // Send enquiry character
|
||||
@ -647,7 +667,7 @@ char* FTermDetection::parseSecDA (char current_termtype[])
|
||||
return current_termtype;
|
||||
|
||||
// remove the first 3 bytes ("\033[>")
|
||||
FString temp = sec_da->right(sec_da->getLength() - 3);
|
||||
FString temp(sec_da->right(sec_da->getLength() - 3));
|
||||
// remove the last byte ("c")
|
||||
temp.remove(temp.getLength() - 1, 1);
|
||||
// split into components
|
||||
@ -706,15 +726,15 @@ int FTermDetection::str2int (const FString& s)
|
||||
//----------------------------------------------------------------------
|
||||
const FString FTermDetection::getSecDA()
|
||||
{
|
||||
FString sec_da_str = "";
|
||||
FString sec_da_str{""};
|
||||
|
||||
int a = 0
|
||||
, b = 0
|
||||
, c = 0
|
||||
, stdin_no = FTermios::getStdIn()
|
||||
, stdout_no = FTermios::getStdOut();
|
||||
fd_set ifds;
|
||||
struct timeval tv;
|
||||
int a{0}
|
||||
, b{0}
|
||||
, c{0}
|
||||
, stdin_no{FTermios::getStdIn()}
|
||||
, stdout_no{FTermios::getStdOut()};
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
|
||||
// Get the secondary device attributes
|
||||
ssize_t ret = write(stdout_no, SECDA, std::strlen(SECDA));
|
||||
@ -824,7 +844,7 @@ inline char* FTermDetection::secDA_Analysis_0 (char current_termtype[])
|
||||
else if ( secondary_da.terminal_id_version == 136 )
|
||||
terminal_type.putty = true; // PuTTY
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
if ( FTermFreeBSD::isFreeBSDConsole() )
|
||||
terminal_type.freebsd_con = true;
|
||||
#endif
|
||||
@ -849,7 +869,7 @@ inline char* FTermDetection::secDA_Analysis_24 (char current_termtype[])
|
||||
|
||||
char* new_termtype = current_termtype;
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
|
||||
if ( secondary_da.terminal_id_version == 20
|
||||
&& FTermOpenBSD::isBSDConsole() )
|
||||
@ -864,7 +884,7 @@ inline char* FTermDetection::secDA_Analysis_24 (char current_termtype[])
|
||||
}
|
||||
}
|
||||
|
||||
#endif // defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
|
||||
return new_termtype;
|
||||
}
|
||||
@ -874,9 +894,8 @@ inline char* FTermDetection::secDA_Analysis_32 (char[])
|
||||
{
|
||||
// Terminal ID 32 - Tera Term
|
||||
|
||||
char* new_termtype;
|
||||
terminal_type.tera_term = true;
|
||||
new_termtype = C_STR("teraterm");
|
||||
char* new_termtype = C_STR("teraterm");
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
@ -895,9 +914,8 @@ inline char* FTermDetection::secDA_Analysis_67 (char[])
|
||||
{
|
||||
// Terminal ID 67 - cygwin
|
||||
|
||||
char* new_termtype;
|
||||
terminal_type.cygwin = true;
|
||||
new_termtype = C_STR("cygwin");
|
||||
char* new_termtype = C_STR("cygwin");
|
||||
std::fflush(stdout);
|
||||
return new_termtype;
|
||||
}
|
||||
@ -907,10 +925,9 @@ inline char* FTermDetection::secDA_Analysis_77 (char[])
|
||||
{
|
||||
// Terminal ID 77 - mintty
|
||||
|
||||
char* new_termtype;
|
||||
terminal_type.mintty = true;
|
||||
decscusr_support = true;
|
||||
new_termtype = C_STR("xterm-256color");
|
||||
char* new_termtype = C_STR("xterm-256color");
|
||||
std::fflush(stdout);
|
||||
return new_termtype;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018 Markus Gans *
|
||||
* Copyright 2018-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -21,17 +21,23 @@
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fcharmap.h"
|
||||
#include "final/fsystem.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermdata.h"
|
||||
#include "final/ftermfreebsd.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
uInt FTermFreeBSD::bsd_alt_keymap = 0;
|
||||
FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style = fc::normal_cursor;
|
||||
bool FTermFreeBSD::change_cursorstyle = true;
|
||||
bool FTermFreeBSD::meta_sends_escape = true;
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
uInt FTermFreeBSD::bsd_alt_keymap{0};
|
||||
FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style{fc::normal_cursor};
|
||||
bool FTermFreeBSD::change_cursorstyle{true};
|
||||
bool FTermFreeBSD::meta_sends_escape{true};
|
||||
FSystem* FTermFreeBSD::fsystem{nullptr};
|
||||
FTermData* FTermFreeBSD::fterm_data{nullptr};
|
||||
#endif
|
||||
|
||||
|
||||
@ -41,29 +47,29 @@ namespace finalcut
|
||||
|
||||
// public methods of FTermFreeBSD
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle()
|
||||
{
|
||||
return cursor_style;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::setCursorStyle (CursorStyle style, bool hidden)
|
||||
bool FTermFreeBSD::setCursorStyle (CursorStyle style)
|
||||
{
|
||||
// Set cursor style in a BSD console
|
||||
|
||||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
if ( ! fsystem || ! isFreeBSDConsole() || ! change_cursorstyle )
|
||||
return false;
|
||||
|
||||
if ( ! change_cursorstyle )
|
||||
return;
|
||||
if ( ! fterm_data )
|
||||
fterm_data = FTerm::getFTermData();
|
||||
|
||||
cursor_style = style;
|
||||
|
||||
if ( hidden )
|
||||
return;
|
||||
if ( fterm_data->isCursorHidden() )
|
||||
return false;
|
||||
|
||||
ioctl(0, CONS_CURSORTYPE, &style);
|
||||
return setFreeBSDCursorStyle(style);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -71,49 +77,88 @@ bool FTermFreeBSD::isFreeBSDConsole()
|
||||
{
|
||||
// Check if it's a FreeBSD console
|
||||
|
||||
keymap_t keymap;
|
||||
keymap_t keymap{};
|
||||
|
||||
if ( ioctl(0, GIO_KEYMAP, &keymap) == 0 )
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem && fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::setBeep (int Hz, int ms)
|
||||
{
|
||||
if ( ! FTerm::isFreeBSDTerm() )
|
||||
return;
|
||||
|
||||
// Range for frequency: 21-32766
|
||||
if ( Hz < 21 || Hz > 32766 )
|
||||
return;
|
||||
|
||||
// Range for duration: 0-1999
|
||||
if ( ms < 0 || ms > 1999 )
|
||||
return;
|
||||
|
||||
constexpr int timer_frequency = 1193182;
|
||||
int period = timer_frequency / Hz;
|
||||
ms /= 10;
|
||||
FTerm::putstringf (CSI "=%d;%dB", period, ms);
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::resetBeep()
|
||||
{
|
||||
if ( ! FTerm::isFreeBSDTerm() )
|
||||
return;
|
||||
|
||||
// Default frequency: 1491 Hz
|
||||
// Default duration: 50 ms
|
||||
FTerm::putstring (CSI "=800;5B");
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::init()
|
||||
{
|
||||
// initialize BSD console
|
||||
// Initialize BSD console
|
||||
|
||||
fsystem = FTerm::getFSystem();
|
||||
fterm_data = FTerm::getFTermData();
|
||||
|
||||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
|
||||
if ( meta_sends_escape )
|
||||
{
|
||||
// save current left alt key mapping
|
||||
// Save current left alt key mapping
|
||||
saveFreeBSDAltKey();
|
||||
|
||||
// map meta key to left alt key
|
||||
// Map meta key to left alt key
|
||||
setFreeBSDAlt2Meta();
|
||||
}
|
||||
|
||||
if ( change_cursorstyle )
|
||||
{
|
||||
// Initialize FreeBSD console cursor
|
||||
setCursorStyle (fc::destructive_cursor, true);
|
||||
setCursorStyle (fc::destructive_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS])
|
||||
void FTermFreeBSD::initCharMap()
|
||||
{
|
||||
// A FreeBSD console can't show ASCII codes from 0x00 to 0x1b
|
||||
|
||||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
|
||||
for (std::size_t i = 0; i <= fc::lastCharItem; i++)
|
||||
if ( char_map[i][fc::PC] < 0x1c )
|
||||
char_map[i][fc::PC] = char_map[i][fc::ASCII];
|
||||
for (std::size_t i{0}; i <= fc::lastCharItem; i++)
|
||||
if ( fc::character[i][fc::PC] < 0x1c )
|
||||
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -127,16 +172,9 @@ void FTermFreeBSD::finish()
|
||||
if ( meta_sends_escape )
|
||||
resetFreeBSDAlt2Meta();
|
||||
|
||||
setCursorStyle (fc::normal_cursor, false);
|
||||
setFreeBSDCursorStyle (fc::normal_cursor);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::restoreCursorStyle()
|
||||
{
|
||||
// Reset to the last used FreeBSD console cursor style
|
||||
|
||||
setCursorStyle (getCursorStyle(), false);
|
||||
}
|
||||
|
||||
// private methods of FTermFreeBSD
|
||||
//----------------------------------------------------------------------
|
||||
@ -145,16 +183,17 @@ bool FTermFreeBSD::saveFreeBSDAltKey()
|
||||
// Saving the current mapping for the alt key
|
||||
|
||||
static constexpr int left_alt = 0x38;
|
||||
int ret;
|
||||
keymap_t keymap;
|
||||
int ret{-1};
|
||||
keymap_t keymap{};
|
||||
|
||||
ret = ioctl(0, GIO_KEYMAP, &keymap);
|
||||
if ( fsystem )
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
return false;
|
||||
|
||||
// save current mapping
|
||||
bsd_alt_keymap = keymap.key[left_alt].map[0];
|
||||
// Save current mapping
|
||||
bsd_alt_keymap = uInt(keymap.key[left_alt].map[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -164,18 +203,20 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
|
||||
// Remapping the alt key
|
||||
|
||||
static constexpr int left_alt = 0x38;
|
||||
int ret;
|
||||
keymap_t keymap;
|
||||
int ret{-1};
|
||||
keymap_t keymap{};
|
||||
|
||||
ret = ioctl(0, GIO_KEYMAP, &keymap);
|
||||
if ( fsystem )
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
return false;
|
||||
|
||||
// map to meta key
|
||||
keymap.key[left_alt].map[0] = key;
|
||||
// Mapping "key" on the left alt key
|
||||
keymap.key[left_alt].map[0] = int(key);
|
||||
|
||||
if ( (keymap.n_keys > 0) && (ioctl(0, PIO_KEYMAP, &keymap) < 0) )
|
||||
if ( (keymap.n_keys > 0)
|
||||
&& fsystem && (fsystem->ioctl(0, PIO_KEYMAP, &keymap) < 0) )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@ -196,6 +237,15 @@ bool FTermFreeBSD::resetFreeBSDAlt2Meta()
|
||||
|
||||
return setFreeBSDAltKey (bsd_alt_keymap);
|
||||
}
|
||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style)
|
||||
{
|
||||
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -71,7 +71,7 @@ void FTermios::init()
|
||||
//----------------------------------------------------------------------
|
||||
termios FTermios::getTTY()
|
||||
{
|
||||
struct termios t;
|
||||
struct termios t{};
|
||||
tcgetattr (stdin_no, &t);
|
||||
return t;
|
||||
}
|
||||
@ -100,7 +100,7 @@ void FTermios::restoreTTYsettings()
|
||||
void FTermios::setHardwareEcho()
|
||||
{
|
||||
// Info under: man 3 termios
|
||||
struct termios t;
|
||||
struct termios t{};
|
||||
tcgetattr (stdin_no, &t);
|
||||
|
||||
// local mode
|
||||
@ -120,7 +120,7 @@ void FTermios::setHardwareEcho()
|
||||
void FTermios::unsetHardwareEcho()
|
||||
{
|
||||
// Info under: man 3 termios
|
||||
struct termios t;
|
||||
struct termios t{};
|
||||
tcgetattr (stdin_no, &t);
|
||||
|
||||
// local mode
|
||||
@ -139,7 +139,7 @@ void FTermios::unsetHardwareEcho()
|
||||
//----------------------------------------------------------------------
|
||||
void FTermios::setCaptureSendCharacters()
|
||||
{
|
||||
struct termios t;
|
||||
struct termios t{};
|
||||
tcgetattr (stdin_no, &t);
|
||||
t.c_lflag &= uInt(~(ICANON | ECHO));
|
||||
t.c_cc[VTIME] = 1; // Timeout in deciseconds
|
||||
@ -150,7 +150,7 @@ void FTermios::setCaptureSendCharacters()
|
||||
//----------------------------------------------------------------------
|
||||
void FTermios::unsetCaptureSendCharacters()
|
||||
{
|
||||
struct termios t;
|
||||
struct termios t{};
|
||||
tcgetattr (stdin_no, &t);
|
||||
t.c_lflag |= uInt(ICANON | ECHO);
|
||||
t.c_cc[VTIME] = 0; // Timeout in deciseconds
|
||||
@ -166,7 +166,7 @@ bool FTermios::setRawMode (bool enable)
|
||||
return raw_mode;
|
||||
|
||||
// Info under: man 3 termios
|
||||
struct termios t;
|
||||
struct termios t{};
|
||||
tcgetattr (stdin_no, &t);
|
||||
|
||||
if ( enable )
|
||||
@ -230,7 +230,10 @@ uInt FTermios::getBaudRate()
|
||||
outspeed[B115200] = 115200; // 115,200 baud
|
||||
outspeed[B230400] = 230400; // 230,400 baud
|
||||
|
||||
return outspeed[cfgetospeed(&term_init)];
|
||||
if ( outspeed.find(cfgetospeed(&term_init)) != outspeed.end() )
|
||||
return outspeed[cfgetospeed(&term_init)];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -20,10 +20,19 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fcharmap.h"
|
||||
#include "final/fsystem.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermcap.h"
|
||||
#include "final/ftermdetection.h"
|
||||
#include "final/ftermlinux.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/keyboard.h> // need keyboard modifiers
|
||||
#include "../fonts/newfont.h"
|
||||
#include "../fonts/unicodemap.h"
|
||||
#include "../fonts/vgafont.h"
|
||||
@ -34,22 +43,21 @@ namespace finalcut
|
||||
|
||||
// static class attributes
|
||||
#if defined(__linux__)
|
||||
FTermLinux::modifier_key FTermLinux::mod_key;
|
||||
console_font_op FTermLinux::screen_font;
|
||||
unimapdesc FTermLinux::screen_unicode_map;
|
||||
FTermLinux::modifier_key FTermLinux::mod_key{};
|
||||
console_font_op FTermLinux::screen_font{};
|
||||
unimapdesc FTermLinux::screen_unicode_map{};
|
||||
|
||||
bool FTermLinux::new_font;
|
||||
bool FTermLinux::vga_font;
|
||||
bool FTermLinux::shadow_character = true;
|
||||
bool FTermLinux::half_block_character = true;
|
||||
bool FTermLinux::has_saved_palette = false;
|
||||
bool FTermLinux::new_font{false};
|
||||
bool FTermLinux::vga_font{false};
|
||||
bool FTermLinux::has_saved_palette{false};
|
||||
|
||||
FTermData* FTermLinux::fterm_data = nullptr;
|
||||
FTermDetection* FTermLinux::term_detection = nullptr;
|
||||
fc::linuxConsoleCursorStyle FTermLinux::linux_console_cursor_style;
|
||||
FTermLinux::ColorMap FTermLinux::saved_color_map;
|
||||
FTermLinux::ColorMap FTermLinux::cmap;
|
||||
int FTermLinux::framebuffer_bpp = -1;
|
||||
FTermData* FTermLinux::fterm_data{nullptr};
|
||||
FSystem* FTermLinux::fsystem{nullptr};
|
||||
FTermDetection* FTermLinux::term_detection{nullptr};
|
||||
fc::linuxConsoleCursorStyle FTermLinux::linux_console_cursor_style{};
|
||||
FTermLinux::ColorMap FTermLinux::saved_color_map{};
|
||||
FTermLinux::ColorMap FTermLinux::cmap{};
|
||||
int FTermLinux::framebuffer_bpp{-1};
|
||||
#endif // defined(__linux__)
|
||||
|
||||
|
||||
@ -81,23 +89,34 @@ fc::linuxConsoleCursorStyle FTermLinux::getCursorStyle()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
char* FTermLinux::setCursorStyle ( fc::linuxConsoleCursorStyle style
|
||||
, bool hidden )
|
||||
char* FTermLinux::getCursorStyleString()
|
||||
{
|
||||
// Gets the current cursor style string of the Linux console
|
||||
|
||||
static char buf[16]{};
|
||||
std::fill (std::begin(buf), std::end(buf), '\0');
|
||||
std::sprintf (buf, CSI "?%dc", getCursorStyle());
|
||||
return buf;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermLinux::setCursorStyle (fc::linuxConsoleCursorStyle style)
|
||||
{
|
||||
// Set cursor style in linux console
|
||||
|
||||
static char buf[16] = { };
|
||||
if ( ! fterm_data )
|
||||
fterm_data = FTerm::getFTermData();
|
||||
|
||||
if ( ! FTerm::isLinuxTerm() )
|
||||
return buf;
|
||||
return false;
|
||||
|
||||
linux_console_cursor_style = style;
|
||||
|
||||
if ( hidden )
|
||||
return buf;
|
||||
if ( fterm_data->isCursorHidden() )
|
||||
return false;
|
||||
|
||||
std::sprintf (buf, CSI "?%dc", style);
|
||||
return buf;
|
||||
setLinuxCursorStyle(style);
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -135,22 +154,36 @@ bool FTermLinux::isLinuxConsole()
|
||||
{
|
||||
// Check if it's a Linux console
|
||||
|
||||
char arg = 0;
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
char arg{0};
|
||||
int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
|
||||
// get keyboard type an compare
|
||||
return ( isatty (fd_tty)
|
||||
&& ioctl(fd_tty, KDGKBTYPE, &arg) == 0
|
||||
// Get keyboard type an compare
|
||||
return ( fsystem->isTTY(fd_tty)
|
||||
&& fsystem->ioctl(fd_tty, KDGKBTYPE, &arg) == 0
|
||||
&& ((arg == KB_101) || (arg == KB_84)) );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermLinux::init()
|
||||
{
|
||||
// initialize Linux console
|
||||
// Initialize Linux console
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( ! fterm_data )
|
||||
fterm_data = FTerm::getFTermData();
|
||||
|
||||
fsystem = FTerm::getFSystem();
|
||||
term_detection = FTerm::getFTermDetection();
|
||||
screen_unicode_map.entries = nullptr;
|
||||
screen_font.data = nullptr;
|
||||
fterm_data->supportShadowCharacter (true);
|
||||
fterm_data->supportHalfBlockCharacter (true);
|
||||
getVGAPalette();
|
||||
|
||||
if ( FTerm::openConsole() == 0 )
|
||||
{
|
||||
@ -169,7 +202,7 @@ void FTermLinux::init()
|
||||
FTermcap::max_color = 8;
|
||||
#endif
|
||||
// Underline cursor
|
||||
setCursorStyle (fc::underscore_cursor, true);
|
||||
setCursorStyle (fc::underscore_cursor);
|
||||
|
||||
// Framebuffer color depth in bits per pixel
|
||||
framebuffer_bpp = getFramebuffer_bpp();
|
||||
@ -190,23 +223,23 @@ void FTermLinux::init()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermLinux::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS])
|
||||
void FTermLinux::initCharMap()
|
||||
{
|
||||
constexpr sInt16 NOT_FOUND = -1;
|
||||
|
||||
if ( new_font || vga_font )
|
||||
return;
|
||||
|
||||
if ( screen_unicode_map.entry_ct != 0 )
|
||||
if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries )
|
||||
{
|
||||
for (std::size_t i = 0; i <= fc::lastCharItem; i++ )
|
||||
for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
|
||||
{
|
||||
auto ucs = wchar_t(char_map[i][fc::UTF8]);
|
||||
auto ucs = wchar_t(fc::character[i][fc::UTF8]);
|
||||
sInt16 fontpos = getFontPos(ucs);
|
||||
|
||||
// Fix for a non-cp437 Linux console with PC charset encoding
|
||||
if ( fontpos > 255 || fontpos == NOT_FOUND )
|
||||
char_map[i][fc::PC] = char_map[i][fc::ASCII];
|
||||
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
|
||||
|
||||
// Character substitutions for missing characters
|
||||
if ( fontpos == NOT_FOUND )
|
||||
@ -236,7 +269,7 @@ void FTermLinux::finish()
|
||||
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
||||
setBlinkAsIntensity (false);
|
||||
#endif
|
||||
setCursorStyle (fc::default_cursor, false);
|
||||
setLinuxCursorStyle (fc::default_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,6 +277,7 @@ void FTermLinux::finish()
|
||||
bool FTermLinux::loadVGAFont()
|
||||
{
|
||||
vga_font = true;
|
||||
new_font = false;
|
||||
|
||||
if ( FTerm::openConsole() == 0 )
|
||||
{
|
||||
@ -255,7 +289,7 @@ bool FTermLinux::loadVGAFont()
|
||||
if ( ret != 0 )
|
||||
vga_font = false;
|
||||
|
||||
// unicode character mapping
|
||||
// Unicode character mapping
|
||||
struct unimapdesc unimap;
|
||||
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_cp437_pairs)
|
||||
/ sizeof(unipair) );
|
||||
@ -272,7 +306,10 @@ bool FTermLinux::loadVGAFont()
|
||||
vga_font = false;
|
||||
|
||||
if ( vga_font )
|
||||
shadow_character = half_block_character = true;
|
||||
{
|
||||
fterm_data->supportShadowCharacter (true);
|
||||
fterm_data->supportHalfBlockCharacter (true);
|
||||
}
|
||||
|
||||
return vga_font;
|
||||
}
|
||||
@ -281,6 +318,7 @@ bool FTermLinux::loadVGAFont()
|
||||
bool FTermLinux::loadNewFont()
|
||||
{
|
||||
new_font = true;
|
||||
vga_font = false;
|
||||
|
||||
if ( FTerm::openConsole() == 0 )
|
||||
{
|
||||
@ -292,7 +330,7 @@ bool FTermLinux::loadNewFont()
|
||||
if ( ret != 0 )
|
||||
new_font = false;
|
||||
|
||||
// unicode character mapping
|
||||
// Unicode character mapping
|
||||
struct unimapdesc unimap;
|
||||
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_cp437_pairs)
|
||||
/ sizeof(unipair) );
|
||||
@ -308,16 +346,19 @@ bool FTermLinux::loadNewFont()
|
||||
else
|
||||
new_font = false;
|
||||
|
||||
if ( vga_font )
|
||||
shadow_character = half_block_character = true;
|
||||
if ( new_font )
|
||||
{
|
||||
fterm_data->supportShadowCharacter (true);
|
||||
fterm_data->supportHalfBlockCharacter (true);
|
||||
}
|
||||
|
||||
return new_font;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermLinux::loadOldFont (uInt char_map[][fc::NUM_OF_ENCODINGS])
|
||||
bool FTermLinux::loadOldFont()
|
||||
{
|
||||
bool retval = false;
|
||||
bool retval{false};
|
||||
|
||||
if ( FTerm::openConsole() == 0 )
|
||||
{
|
||||
@ -340,7 +381,7 @@ bool FTermLinux::loadOldFont (uInt char_map[][fc::NUM_OF_ENCODINGS])
|
||||
if ( screen_unicode_map.entries )
|
||||
{
|
||||
setUnicodeMap (&screen_unicode_map);
|
||||
initCharMap(char_map);
|
||||
initCharMap();
|
||||
delete[] screen_unicode_map.entries;
|
||||
screen_unicode_map.entries = nullptr;
|
||||
}
|
||||
@ -388,11 +429,11 @@ void FTermLinux::setBeep (int Hz, int ms)
|
||||
if ( ! FTerm::isLinuxTerm() )
|
||||
return;
|
||||
|
||||
// range for frequency: 21-32766
|
||||
// Range for frequency: 21-32766
|
||||
if ( Hz < 21 || Hz > 32766 )
|
||||
return;
|
||||
|
||||
// range for duration: 0-1999
|
||||
// Range for duration: 0-1999
|
||||
if ( ms < 0 || ms > 1999 )
|
||||
return;
|
||||
|
||||
@ -408,25 +449,21 @@ void FTermLinux::resetBeep()
|
||||
if ( ! FTerm::isLinuxTerm() )
|
||||
return;
|
||||
|
||||
// default frequency: 750 Hz
|
||||
// default duration: 125 ms
|
||||
// Default frequency: 750 Hz
|
||||
// Default duration: 125 ms
|
||||
FTerm::putstring ( CSI "10;750]"
|
||||
CSI "11;125]" );
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
char* FTermLinux::restoreCursorStyle()
|
||||
{
|
||||
// Reset to the last used Linux console cursor style
|
||||
|
||||
return setCursorStyle (getCursorStyle(), false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FKey FTermLinux::modifierKeyCorrection (const FKey& key_id)
|
||||
{
|
||||
// Get the current modifier key state
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
modifier_key& m = getModifierKey();
|
||||
|
||||
if ( ! (m.shift || m.ctrl || m.alt) )
|
||||
@ -470,32 +507,34 @@ FKey FTermLinux::modifierKeyCorrection (const FKey& key_id)
|
||||
//----------------------------------------------------------------------
|
||||
int FTermLinux::getFramebuffer_bpp()
|
||||
{
|
||||
int fd = -1;
|
||||
struct fb_var_screeninfo fb_var;
|
||||
struct fb_fix_screeninfo fb_fix;
|
||||
|
||||
int fd{-1};
|
||||
const char* fb = C_STR("/dev/fb/0");
|
||||
struct fb_var_screeninfo fb_var{};
|
||||
struct fb_fix_screeninfo fb_fix{};
|
||||
|
||||
if ( (fd = open(fb, O_RDWR)) < 0 )
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( (fd = fsystem->open(fb, O_RDWR)) < 0 )
|
||||
{
|
||||
if ( errno != ENOENT && errno != ENOTDIR )
|
||||
return -1;
|
||||
|
||||
fb = C_STR("/dev/fb0");
|
||||
|
||||
if ( (fd = open(fb, O_RDWR)) < 0 )
|
||||
if ( (fd = fsystem->open(fb, O_RDWR)) < 0 )
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( ! ioctl(fd, FBIOGET_VSCREENINFO, &fb_var)
|
||||
&& ! ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix) )
|
||||
if ( fsystem->ioctl(fd, FBIOGET_VSCREENINFO, &fb_var) == 0
|
||||
&& fsystem->ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix) == 0 )
|
||||
{
|
||||
::close(fd);
|
||||
fsystem->close(fd);
|
||||
return int(fb_var.bits_per_pixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
::close(fd);
|
||||
fsystem->close(fd);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -504,16 +543,14 @@ int FTermLinux::getFramebuffer_bpp()
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermLinux::getScreenFont()
|
||||
{
|
||||
static constexpr std::size_t data_size = 4 * 32 * 512;
|
||||
struct console_font_op font;
|
||||
struct console_font_op font{};
|
||||
int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
|
||||
int ret;
|
||||
int ret{-1};
|
||||
|
||||
if ( fd_tty < 0 )
|
||||
return false;
|
||||
|
||||
// initialize unused padding bytes in struct
|
||||
// Initialize unused padding bytes in struct
|
||||
std::memset (&font, 0, sizeof(console_font_op));
|
||||
|
||||
font.op = KD_FONT_OP_GET;
|
||||
@ -522,9 +559,10 @@ bool FTermLinux::getScreenFont()
|
||||
font.height = 32;
|
||||
font.charcount = 512;
|
||||
|
||||
// initialize with 0
|
||||
// Initialize with 0
|
||||
try
|
||||
{
|
||||
static constexpr std::size_t data_size = 4 * 32 * 512;
|
||||
font.data = new uChar[data_size]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
@ -533,26 +571,30 @@ bool FTermLinux::getScreenFont()
|
||||
return false;
|
||||
}
|
||||
|
||||
// font operation
|
||||
ret = ioctl (fd_tty, KDFONTOP, &font);
|
||||
// Font operation
|
||||
if ( fsystem )
|
||||
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
|
||||
|
||||
if ( ret == 0 )
|
||||
if ( ret != 0 )
|
||||
{
|
||||
screen_font.width = font.width;
|
||||
screen_font.height = font.height;
|
||||
screen_font.charcount = font.charcount;
|
||||
screen_font.data = font.data;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if ( font.data )
|
||||
delete[] font.data;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
screen_font.width = font.width;
|
||||
screen_font.height = font.height;
|
||||
screen_font.charcount = font.charcount;
|
||||
screen_font.data = font.data;
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermLinux::getUnicodeMap()
|
||||
{
|
||||
int ret;
|
||||
int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
int ret{-1};
|
||||
|
||||
if ( fd_tty < 0 )
|
||||
return false;
|
||||
@ -560,8 +602,9 @@ bool FTermLinux::getUnicodeMap()
|
||||
screen_unicode_map.entry_ct = 0;
|
||||
screen_unicode_map.entries = nullptr;
|
||||
|
||||
// get count
|
||||
ret = ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map);
|
||||
// Get count
|
||||
if ( fsystem )
|
||||
ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map);
|
||||
|
||||
if ( ret != 0 )
|
||||
{
|
||||
@ -580,8 +623,9 @@ bool FTermLinux::getUnicodeMap()
|
||||
return false;
|
||||
}
|
||||
|
||||
// get unicode-to-font mapping from kernel
|
||||
ret = ioctl(fd_tty, GIO_UNIMAP, &screen_unicode_map);
|
||||
// Get unicode-to-font mapping from kernel
|
||||
if ( fsystem )
|
||||
ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map);
|
||||
|
||||
if ( ret != 0 )
|
||||
return false;
|
||||
@ -595,13 +639,13 @@ FTermLinux::modifier_key& FTermLinux::getModifierKey()
|
||||
{
|
||||
// Get Linux console shift state
|
||||
|
||||
char subcode = 6; // Shift state command + return value
|
||||
char subcode{6}; // Shift state command + return value
|
||||
|
||||
// fill bit field with 0
|
||||
// Fill bit field with 0
|
||||
std::memset (&mod_key, 0x00, sizeof(mod_key));
|
||||
|
||||
// TIOCLINUX, subcode = 6
|
||||
if ( ioctl(0, TIOCLINUX, &subcode) >= 0 )
|
||||
// TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE)
|
||||
if ( fsystem && fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 )
|
||||
{
|
||||
if ( subcode & (1 << KG_SHIFT) )
|
||||
mod_key.shift = true;
|
||||
@ -624,14 +668,14 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
|
||||
, uInt fontwidth, uInt fontheight
|
||||
, bool direct)
|
||||
{
|
||||
struct console_font_op font;
|
||||
int ret;
|
||||
struct console_font_op font{};
|
||||
int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
int ret{-1};
|
||||
|
||||
if ( fd_tty < 0 )
|
||||
return -1;
|
||||
|
||||
// initialize unused padding bytes in struct
|
||||
// Initialize unused padding bytes in struct
|
||||
std::memset (&font, 0x00, sizeof(console_font_op));
|
||||
|
||||
font.op = KD_FONT_OP_SET;
|
||||
@ -649,7 +693,7 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
|
||||
|
||||
try
|
||||
{
|
||||
font.data = new uChar[data_size](); // initialize with 0
|
||||
font.data = new uChar[data_size](); // Initialize with 0
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
@ -657,14 +701,15 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
|
||||
return -1;
|
||||
}
|
||||
|
||||
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)
|
||||
, &fontdata[i * font.height]
|
||||
, font.height);
|
||||
}
|
||||
|
||||
// font operation
|
||||
ret = ioctl (fd_tty, KDFONTOP, &font);
|
||||
// Font operation
|
||||
if ( fsystem )
|
||||
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
|
||||
|
||||
if ( ret != 0 && errno != ENOSYS && errno != EINVAL )
|
||||
{
|
||||
@ -687,8 +732,8 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
|
||||
int FTermLinux::setUnicodeMap (struct unimapdesc* unimap)
|
||||
{
|
||||
struct unimapinit advice;
|
||||
int ret;
|
||||
int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
int ret{-1};
|
||||
|
||||
if ( fd_tty < 0 )
|
||||
return -1;
|
||||
@ -699,14 +744,16 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap)
|
||||
|
||||
do
|
||||
{
|
||||
// clear the unicode-to-font table
|
||||
ret = ioctl(fd_tty, PIO_UNIMAPCLR, &advice);
|
||||
// Clear the unicode-to-font table
|
||||
if ( fsystem )
|
||||
ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice);
|
||||
|
||||
if ( ret != 0 )
|
||||
return -1;
|
||||
|
||||
// put the new unicode-to-font mapping in kernel
|
||||
ret = ioctl(fd_tty, PIO_UNIMAP, unimap);
|
||||
// Put the new unicode-to-font mapping in kernel
|
||||
if ( fsystem )
|
||||
ret = fsystem->ioctl (fd_tty, PIO_UNIMAP, unimap);
|
||||
|
||||
if ( ret != 0 )
|
||||
advice.advised_hashlevel++;
|
||||
@ -719,17 +766,27 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap)
|
||||
return -1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermLinux::setLinuxCursorStyle (CursorStyle style)
|
||||
{
|
||||
FTerm::putstringf (CSI "?%dc", style);
|
||||
}
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
||||
//----------------------------------------------------------------------
|
||||
inline uInt16 FTermLinux::getInputStatusRegisterOne()
|
||||
{
|
||||
// Gets the VGA input-status-register-1
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
// Miscellaneous output (read port)
|
||||
static constexpr uInt16 misc_read = 0x3cc;
|
||||
const uInt16 io_base = ( inb(misc_read) & 0x01 ) ? 0x3d0 : 0x3b0;
|
||||
// 0x3ba : Input status 1 MDA (read port)
|
||||
// 0x3da : Input status 1 CGA (read port)
|
||||
uChar misc_value = fsystem->inPortByte(misc_read);
|
||||
const uInt16 io_base = ( misc_value & 0x01 ) ? 0x3d0 : 0x3b0;
|
||||
// 0x3ba : Input status 1 mono/MDA (read port)
|
||||
// 0x3da : Input status 1 color/CGA (read port)
|
||||
return io_base + 0x0a;
|
||||
}
|
||||
|
||||
@ -738,21 +795,25 @@ uChar FTermLinux::readAttributeController (uChar index)
|
||||
{
|
||||
// Reads a byte from the attribute controller from a given index
|
||||
|
||||
uChar res;
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
// Attribute controller (write port)
|
||||
static constexpr uInt16 attrib_cntlr_write = 0x3c0;
|
||||
// Attribute controller (read port)
|
||||
static constexpr uInt16 attrib_cntlr_read = 0x3c1;
|
||||
const uInt16 input_status_1 = getInputStatusRegisterOne();
|
||||
|
||||
inb (input_status_1); // switch to index mode
|
||||
outb (index & 0x1f, attrib_cntlr_write);
|
||||
res = inb (attrib_cntlr_read);
|
||||
fsystem->inPortByte (input_status_1); // switch to index mode
|
||||
fsystem->outPortByte (index & 0x1f, attrib_cntlr_write); // selects address register
|
||||
uChar res = fsystem->inPortByte (attrib_cntlr_read); // read from data register
|
||||
|
||||
inb (input_status_1); // switch to data mode
|
||||
// Disable access to the palette and unblank the display
|
||||
fsystem->inPortByte (input_status_1); // switch to index mode
|
||||
index = (index & 0x1f) | 0x20; // set bit 5 (enable display)
|
||||
outb (index, attrib_cntlr_write);
|
||||
inb (attrib_cntlr_read);
|
||||
fsystem->outPortByte (index, attrib_cntlr_write);
|
||||
fsystem->inPortByte (attrib_cntlr_read);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -761,18 +822,22 @@ void FTermLinux::writeAttributeController (uChar index, uChar data)
|
||||
{
|
||||
// Writes a byte from the attribute controller from a given index
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
// Attribute controller (write port)
|
||||
static constexpr uInt16 attrib_cntlr_write = 0x3c0;
|
||||
const uInt16 input_status_1 = getInputStatusRegisterOne();
|
||||
|
||||
inb (input_status_1); // switch to index mode
|
||||
outb (index & 0x1f, attrib_cntlr_write);
|
||||
outb (data, attrib_cntlr_write);
|
||||
fsystem->inPortByte (input_status_1); // switch to index mode
|
||||
fsystem->outPortByte (index & 0x1f, attrib_cntlr_write); // selects address register
|
||||
fsystem->outPortByte (data, attrib_cntlr_write); // write to data register
|
||||
|
||||
inb (input_status_1); // switch to data mode
|
||||
// Disable access to the palette and unblank the display
|
||||
fsystem->inPortByte (input_status_1); // switch to index mode
|
||||
index = (index & 0x1f) | 0x20; // set bit 5 (enable display)
|
||||
outb (index, attrib_cntlr_write);
|
||||
outb (data, attrib_cntlr_write);
|
||||
fsystem->outPortByte (index, attrib_cntlr_write);
|
||||
fsystem->outPortByte (data, attrib_cntlr_write);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -797,20 +862,23 @@ int FTermLinux::setBlinkAsIntensity (bool enable)
|
||||
// Uses blink-bit as background intensity.
|
||||
// That permits 16 colors for background
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
|
||||
// Test if the blink-bit is used by the screen font (512 characters)
|
||||
if ( screen_font.charcount > 256 )
|
||||
return -1;
|
||||
|
||||
if ( getuid() != 0 ) // Direct hardware access requires root privileges
|
||||
if ( fsystem->getuid() != 0 ) // Direct hardware access requires root privileges
|
||||
return -2;
|
||||
|
||||
if ( fd_tty < 0 )
|
||||
return -1;
|
||||
|
||||
// Enable access to VGA I/O ports (from 0x3B4 with num = 0x2C)
|
||||
if ( ioctl(fd_tty, KDENABIO, 0) < 0 )
|
||||
if ( fsystem->ioctl(fd_tty, KDENABIO, 0) < 0 )
|
||||
return -1; // error on KDENABIO
|
||||
|
||||
if ( enable )
|
||||
@ -819,12 +887,42 @@ int FTermLinux::setBlinkAsIntensity (bool enable)
|
||||
setAttributeMode (getAttributeMode() | 0x08); // set bit 3
|
||||
|
||||
// Disable access to VGA I/O ports
|
||||
if ( ioctl(fd_tty, KDDISABIO, 0) < 0 )
|
||||
if ( fsystem->ioctl(fd_tty, KDDISABIO, 0) < 0 )
|
||||
return -1; // error on KDDISABIO
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermLinux::getVGAPalette()
|
||||
{
|
||||
if ( fsystem && fsystem->ioctl(0, GIO_CMAP, &cmap) != 0 )
|
||||
setVGADefaultPalette(); // Fallback, if GIO_CMAP does not work
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermLinux::setVGADefaultPalette()
|
||||
{
|
||||
constexpr rgb defaultColor[16] =
|
||||
{
|
||||
{0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00},
|
||||
{0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00},
|
||||
{0x00, 0x00, 0xaa}, {0xaa, 0x00, 0xaa},
|
||||
{0x00, 0xaa, 0xaa}, {0xaa, 0xaa, 0xaa},
|
||||
{0x55, 0x55, 0x55}, {0xff, 0x55, 0x55},
|
||||
{0x55, 0xff, 0x55}, {0xff, 0xff, 0x55},
|
||||
{0x55, 0x55, 0xff}, {0xff, 0x55, 0xff},
|
||||
{0x55, 0xff, 0xff}, {0xff, 0xff, 0xff}
|
||||
};
|
||||
|
||||
for (std::size_t index{0}; index < 16; index++)
|
||||
{
|
||||
cmap.color[index].red = defaultColor[index].red;
|
||||
cmap.color[index].green = defaultColor[index].green;
|
||||
cmap.color[index].blue = defaultColor[index].blue;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b)
|
||||
{
|
||||
@ -839,10 +937,10 @@ bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b)
|
||||
cmap.color[index].blue = uChar(b);
|
||||
}
|
||||
|
||||
if ( ioctl (0, PIO_CMAP, &cmap) )
|
||||
return false;
|
||||
else
|
||||
if ( fsystem && fsystem->ioctl(0, PIO_CMAP, &cmap) == 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -850,10 +948,10 @@ bool FTermLinux::saveVGAPalette()
|
||||
{
|
||||
// Save the current vga color map
|
||||
|
||||
if ( ioctl (0, GIO_CMAP, &saved_color_map) )
|
||||
has_saved_palette = false;
|
||||
else
|
||||
if ( fsystem && fsystem->ioctl(0, GIO_CMAP, &saved_color_map) == 0 )
|
||||
has_saved_palette = true;
|
||||
else
|
||||
has_saved_palette = false;
|
||||
|
||||
return has_saved_palette;
|
||||
}
|
||||
@ -865,31 +963,14 @@ bool FTermLinux::resetVGAPalette()
|
||||
|
||||
if ( has_saved_palette )
|
||||
{
|
||||
if ( ioctl (0, PIO_CMAP, &saved_color_map) )
|
||||
if ( fsystem && fsystem->ioctl (0, PIO_CMAP, &saved_color_map) )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
rgb defaultColor[16] =
|
||||
{
|
||||
{0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00},
|
||||
{0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00},
|
||||
{0x00, 0x00, 0xaa}, {0xaa, 0x00, 0xaa},
|
||||
{0x00, 0xaa, 0xaa}, {0xaa, 0xaa, 0xaa},
|
||||
{0x55, 0x55, 0x55}, {0xff, 0x55, 0x55},
|
||||
{0x55, 0xff, 0x55}, {0xff, 0xff, 0x55},
|
||||
{0x55, 0x55, 0xff}, {0xff, 0x55, 0xff},
|
||||
{0x55, 0xff, 0xff}, {0xff, 0xff, 0xff}
|
||||
};
|
||||
setVGADefaultPalette();
|
||||
|
||||
for (std::size_t index = 0; index < 16; index++)
|
||||
{
|
||||
cmap.color[index].red = defaultColor[index].red;
|
||||
cmap.color[index].green = defaultColor[index].green;
|
||||
cmap.color[index].blue = defaultColor[index].blue;
|
||||
}
|
||||
|
||||
if ( ioctl (0, PIO_CMAP, &cmap) )
|
||||
if ( fsystem && fsystem->ioctl(0, PIO_CMAP, &cmap) != 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1069,10 +1150,10 @@ FKey FTermLinux::shiftAltKeyCorrection (const FKey& key_id)
|
||||
return fc::Fmkey_sdown; // Shift+Meta+Down
|
||||
|
||||
case fc::Fkey_left:
|
||||
return fc::Fmkey_sright; // Shift+Meta+Left
|
||||
return fc::Fmkey_sleft; // Shift+Meta+Left
|
||||
|
||||
case fc::Fkey_right:
|
||||
return fc::Fmkey_sleft; // Shift+Meta+Right
|
||||
return fc::Fmkey_sright; // Shift+Meta+Right
|
||||
|
||||
case fc::Fkey_ic:
|
||||
return fc::Fmkey_sic; // Shift+Meta+Ins
|
||||
@ -1188,7 +1269,7 @@ inline void FTermLinux::initSpecialCharacter()
|
||||
|| FTerm::charEncode(c2, fc::PC) == FTerm::charEncode(c2, fc::ASCII)
|
||||
|| FTerm::charEncode(c3, fc::PC) == FTerm::charEncode(c3, fc::ASCII) )
|
||||
{
|
||||
shadow_character = false;
|
||||
fterm_data->supportShadowCharacter (false);
|
||||
}
|
||||
|
||||
wchar_t c4 = fc::RightHalfBlock;
|
||||
@ -1197,20 +1278,22 @@ inline void FTermLinux::initSpecialCharacter()
|
||||
if ( FTerm::charEncode(c4, fc::PC) == FTerm::charEncode(c4, fc::ASCII)
|
||||
|| FTerm::charEncode(c5, fc::PC) == FTerm::charEncode(c5, fc::ASCII) )
|
||||
{
|
||||
half_block_character = false;
|
||||
fterm_data->supportHalfBlockCharacter (false);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
sInt16 FTermLinux::getFontPos (wchar_t ucs)
|
||||
{
|
||||
for (std::size_t n = 0; n < screen_unicode_map.entry_ct; n++)
|
||||
constexpr sInt16 NOT_FOUND = -1;
|
||||
|
||||
for (std::size_t n{0}; n < screen_unicode_map.entry_ct; n++)
|
||||
{
|
||||
if ( screen_unicode_map.entries[n].unicode == ucs )
|
||||
return sInt16(screen_unicode_map.entries[n].fontpos);
|
||||
}
|
||||
|
||||
return -1;
|
||||
return NOT_FOUND;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1218,7 +1301,7 @@ void FTermLinux::characterFallback ( wchar_t ucs
|
||||
, std::vector<wchar_t> fallback )
|
||||
{
|
||||
constexpr sInt16 NOT_FOUND = -1;
|
||||
characterSub& sub_map = fterm_data->getCharSubstitutionMap();
|
||||
charSubstitution& sub_map = fterm_data->getCharSubstitutionMap();
|
||||
|
||||
if ( fallback.size() < 2 || ucs != fallback[0] )
|
||||
return;
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018 Markus Gans *
|
||||
* Copyright 2018-2019 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
@ -20,15 +20,18 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fsystem.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermopenbsd.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
kbd_t FTermOpenBSD::bsd_keyboard_encoding = 0;
|
||||
bool FTermOpenBSD::meta_sends_escape = true;
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
kbd_t FTermOpenBSD::bsd_keyboard_encoding{0};
|
||||
bool FTermOpenBSD::meta_sends_escape{true};
|
||||
FSystem* FTermOpenBSD::fsystem{nullptr};
|
||||
#endif
|
||||
|
||||
|
||||
@ -38,14 +41,18 @@ namespace finalcut
|
||||
|
||||
// public methods of FTermOpenBSD
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
bool FTermOpenBSD::isBSDConsole()
|
||||
{
|
||||
// Check if it's a NetBSD/OpenBSD workstation console
|
||||
|
||||
static kbd_t kbdencoding;
|
||||
static kbd_t kbdencoding{};
|
||||
|
||||
if ( ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem
|
||||
&& fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@ -54,17 +61,19 @@ bool FTermOpenBSD::isBSDConsole()
|
||||
//----------------------------------------------------------------------
|
||||
void FTermOpenBSD::init()
|
||||
{
|
||||
// initialize BSD workstation console
|
||||
// Initialize BSD workstation console
|
||||
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( ! isBSDConsole() )
|
||||
return;
|
||||
|
||||
if ( meta_sends_escape )
|
||||
{
|
||||
// save current left alt key mapping
|
||||
// Save current left alt key mapping
|
||||
saveBSDConsoleEncoding();
|
||||
|
||||
// alt key generate ESC prefix
|
||||
// Alt key generate ESC prefix
|
||||
setBSDConsoleMetaEsc();
|
||||
}
|
||||
}
|
||||
@ -79,18 +88,67 @@ void FTermOpenBSD::finish()
|
||||
resetBSDConsoleEncoding();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::setBeep (int Hz, int ms)
|
||||
{
|
||||
if ( ! isBSDConsole() )
|
||||
return false;
|
||||
|
||||
// Range for frequency: 21-32766
|
||||
if ( Hz < 21 || Hz > 32766 )
|
||||
return false;
|
||||
|
||||
// Range for duration: 0-1999
|
||||
if ( ms < 0 || ms > 1999 )
|
||||
return false;
|
||||
|
||||
wskbd_bell_data bell;
|
||||
bell.which = WSKBD_BELL_DOALL;
|
||||
bell.pitch = uInt(Hz);
|
||||
bell.period = uInt(ms);
|
||||
bell.volume = 50; // 50% volume
|
||||
|
||||
if ( fsystem && fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::resetBeep()
|
||||
{
|
||||
wskbd_bell_data default_bell;
|
||||
|
||||
// Gets the default setting for the bell
|
||||
if ( fsystem
|
||||
&& fsystem->ioctl(0, WSKBDIO_GETDEFAULTBELL, &default_bell) < 0 )
|
||||
return false;
|
||||
|
||||
default_bell.which = WSKBD_BELL_DOALL;
|
||||
|
||||
// Sets the bell settings
|
||||
if ( fsystem
|
||||
&& fsystem->ioctl(0, WSKBDIO_SETBELL, &default_bell) < 0 )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// private methods of FTermOpenBSD
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::saveBSDConsoleEncoding()
|
||||
{
|
||||
static kbd_t k_encoding;
|
||||
int ret = ioctl(0, WSKBDIO_GETENCODING, &k_encoding);
|
||||
static kbd_t k_encoding{};
|
||||
int ret{-1};
|
||||
|
||||
if ( fsystem )
|
||||
ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding);
|
||||
|
||||
if ( ret < 0 )
|
||||
return false;
|
||||
|
||||
// save current encoding
|
||||
// Save current encoding
|
||||
bsd_keyboard_encoding = k_encoding;
|
||||
return true;
|
||||
}
|
||||
@ -98,7 +156,8 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding)
|
||||
{
|
||||
if ( ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 )
|
||||
if ( fsystem
|
||||
&& fsystem->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@ -107,7 +166,7 @@ bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding)
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::setBSDConsoleMetaEsc()
|
||||
{
|
||||
static constexpr kbd_t meta_esc = 0x20; // generate ESC prefix on ALT-key
|
||||
static constexpr kbd_t meta_esc = 0x20; // Generate ESC prefix on ALT-key
|
||||
|
||||
return setBSDConsoleEncoding (bsd_keyboard_encoding | meta_esc);
|
||||
}
|
||||
@ -117,6 +176,6 @@ bool FTermOpenBSD::resetBSDConsoleEncoding()
|
||||
{
|
||||
return setBSDConsoleEncoding (bsd_keyboard_encoding);
|
||||
}
|
||||
#endif // defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -20,30 +20,40 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
#include "final/fconfig.h" // includes _GNU_SOURCE for fd_set
|
||||
#endif
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fstring.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermcap.h"
|
||||
#include "final/ftermdetection.h"
|
||||
#include "final/ftermfreebsd.h"
|
||||
#include "final/ftermios.h"
|
||||
#include "final/ftermxterminal.h"
|
||||
#include "final/fsize.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
bool FTermXTerminal::mouse_support;
|
||||
bool FTermXTerminal::meta_sends_esc;
|
||||
bool FTermXTerminal::xterm_default_colors;
|
||||
std::size_t FTermXTerminal::term_width = 80;
|
||||
std::size_t FTermXTerminal::term_height = 24;
|
||||
const FString* FTermXTerminal::xterm_font = nullptr;
|
||||
const FString* FTermXTerminal::xterm_title = nullptr;
|
||||
const FString* FTermXTerminal::foreground_color = nullptr;
|
||||
const FString* FTermXTerminal::background_color = nullptr;
|
||||
const FString* FTermXTerminal::cursor_color = nullptr;
|
||||
const FString* FTermXTerminal::mouse_foreground_color = nullptr;
|
||||
const FString* FTermXTerminal::mouse_background_color = nullptr;
|
||||
const FString* FTermXTerminal::highlight_background_color = nullptr;
|
||||
FTermcap::tcap_map* FTermXTerminal::tcap = nullptr;
|
||||
FTermDetection* FTermXTerminal::term_detection = nullptr;
|
||||
fc::xtermCursorStyle FTermXTerminal::cursor_style = fc::unknown_cursor_style;
|
||||
bool FTermXTerminal::mouse_support{false};
|
||||
bool FTermXTerminal::meta_sends_esc{false};
|
||||
bool FTermXTerminal::xterm_default_colors{false};
|
||||
std::size_t FTermXTerminal::term_width{80};
|
||||
std::size_t FTermXTerminal::term_height{24};
|
||||
const FString* FTermXTerminal::xterm_font{nullptr};
|
||||
const FString* FTermXTerminal::xterm_title{nullptr};
|
||||
const FString* FTermXTerminal::foreground_color{nullptr};
|
||||
const FString* FTermXTerminal::background_color{nullptr};
|
||||
const FString* FTermXTerminal::cursor_color{nullptr};
|
||||
const FString* FTermXTerminal::mouse_foreground_color{nullptr};
|
||||
const FString* FTermXTerminal::mouse_background_color{nullptr};
|
||||
const FString* FTermXTerminal::highlight_background_color{nullptr};
|
||||
FSystem* FTermXTerminal::fsystem{nullptr};
|
||||
FTermDetection* FTermXTerminal::term_detection{nullptr};
|
||||
fc::xtermCursorStyle FTermXTerminal::cursor_style{fc::unknown_cursor_style};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -54,12 +64,8 @@ fc::xtermCursorStyle FTermXTerminal::cursor_style = fc::unknown_cursor_style;
|
||||
//----------------------------------------------------------------------
|
||||
FTermXTerminal::FTermXTerminal()
|
||||
{
|
||||
// Preset to false
|
||||
mouse_support = \
|
||||
meta_sends_esc = \
|
||||
xterm_default_colors = false;
|
||||
|
||||
tcap = FTermcap::getTermcapMap();
|
||||
// Get FSystem object
|
||||
fsystem = FTerm::getFSystem();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -229,6 +235,12 @@ void FTermXTerminal::metaSendsESC (bool enable)
|
||||
disableXTermMetaSendsESC();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::init()
|
||||
{
|
||||
term_detection = FTerm::getFTermDetection();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::setDefaults()
|
||||
{
|
||||
@ -372,7 +384,7 @@ void FTermXTerminal::setXTermCursorStyle()
|
||||
{
|
||||
// Set the xterm cursor style
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
if ( FTermFreeBSD::isFreeBSDConsole() )
|
||||
return;
|
||||
#endif
|
||||
@ -386,6 +398,7 @@ void FTermXTerminal::setXTermCursorStyle()
|
||||
|
||||
if ( TCAP(fc::t_cursor_style)
|
||||
|| term_detection->isXTerminal()
|
||||
|| term_detection->isCygwinTerminal()
|
||||
|| term_detection->isMinttyTerm()
|
||||
|| term_detection->hasSetCursorStyleSupport() )
|
||||
{
|
||||
@ -401,6 +414,7 @@ void FTermXTerminal::setXTermTitle()
|
||||
|
||||
if ( term_detection->isXTerminal()
|
||||
|| term_detection->isScreenTerm()
|
||||
|| term_detection->isCygwinTerminal()
|
||||
|| term_detection->isMinttyTerm()
|
||||
|| term_detection->isPuttyTerminal()
|
||||
|| FTermcap::osc_support )
|
||||
@ -553,17 +567,9 @@ void FTermXTerminal::setXTerm8ColorDefaults()
|
||||
if ( term_detection->isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
setMouseBackground("rgb:ffff/ffff/ffff"); // white
|
||||
setMouseForeground ("rgb:0000/0000/0000"); // black
|
||||
setXTermDefaultsMouseCursor();
|
||||
|
||||
if ( ! term_detection->isGnomeTerminal() )
|
||||
setCursorColor("rgb:ffff/ffff/ffff"); // white
|
||||
|
||||
if ( xterm_default_colors
|
||||
&& ! (term_detection->isMinttyTerm()
|
||||
|| term_detection->isMltermTerminal()
|
||||
|| term_detection->isRxvtTerminal()
|
||||
|| term_detection->isScreenTerm()) )
|
||||
if ( canSetXTermBackground() )
|
||||
{
|
||||
// mintty and rxvt can't reset these settings
|
||||
setBackground("rgb:2222/2222/b2b2"); // blue
|
||||
@ -581,17 +587,9 @@ void FTermXTerminal::setXTerm16ColorDefaults()
|
||||
if ( term_detection->isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
setMouseBackground("rgb:ffff/ffff/ffff"); // white
|
||||
setMouseForeground ("rgb:0000/0000/0000"); // black
|
||||
setXTermDefaultsMouseCursor();
|
||||
|
||||
if ( ! term_detection->isGnomeTerminal() )
|
||||
setCursorColor("rgb:ffff/ffff/ffff"); // white
|
||||
|
||||
if ( xterm_default_colors
|
||||
&& ! (term_detection->isMinttyTerm()
|
||||
|| term_detection->isMltermTerminal()
|
||||
|| term_detection->isRxvtTerminal()
|
||||
|| term_detection->isScreenTerm()) )
|
||||
if ( canSetXTermBackground() )
|
||||
{
|
||||
// mintty and rxvt can't reset these settings
|
||||
setBackground("rgb:8080/a4a4/ecec"); // very light blue
|
||||
@ -600,6 +598,29 @@ void FTermXTerminal::setXTerm16ColorDefaults()
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FTermXTerminal::setXTermDefaultsMouseCursor()
|
||||
{
|
||||
setMouseBackground("rgb:ffff/ffff/ffff"); // white
|
||||
setMouseForeground ("rgb:0000/0000/0000"); // black
|
||||
|
||||
if ( ! term_detection->isGnomeTerminal() )
|
||||
setCursorColor("rgb:ffff/ffff/ffff"); // white
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermXTerminal::canSetXTermBackground()
|
||||
{
|
||||
if ( xterm_default_colors
|
||||
&& ! (term_detection->isMinttyTerm()
|
||||
|| term_detection->isMltermTerminal()
|
||||
|| term_detection->isRxvtTerminal()
|
||||
|| term_detection->isScreenTerm()) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::resetXTermColorMap()
|
||||
{
|
||||
@ -607,16 +628,15 @@ void FTermXTerminal::resetXTermColorMap()
|
||||
|
||||
if ( term_detection->isMinttyTerm() )
|
||||
{
|
||||
FTerm::putstringf (ESC "c"); // Full Reset (RIS)
|
||||
FTerm::putstring (ESC "c"); // Full Reset (RIS)
|
||||
}
|
||||
else if ( canResetColor() )
|
||||
{
|
||||
oscPrefix();
|
||||
FTerm::putstringf (OSC "104" BEL);
|
||||
FTerm::putstring (OSC "104" BEL);
|
||||
oscPostfix();
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -697,7 +717,7 @@ void FTermXTerminal::resetXTermHighlightBackground()
|
||||
if ( canResetColor() )
|
||||
{
|
||||
oscPrefix();
|
||||
FTerm::putstringf (OSC "117" BEL);
|
||||
FTerm::putstring (OSC "117" BEL);
|
||||
oscPostfix();
|
||||
std::fflush(stdout);
|
||||
}
|
||||
@ -755,8 +775,8 @@ const FString* FTermXTerminal::captureXTermFont()
|
||||
|| term_detection->isScreenTerm()
|
||||
|| FTermcap::osc_support )
|
||||
{
|
||||
fd_set ifds;
|
||||
struct timeval tv;
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
int stdin_no = FTermios::getStdIn();
|
||||
|
||||
oscPrefix();
|
||||
@ -772,7 +792,7 @@ const FString* FTermXTerminal::captureXTermFont()
|
||||
// Read the terminal answer
|
||||
if ( select(stdin_no + 1, &ifds, 0, 0, &tv) > 0 )
|
||||
{
|
||||
char temp[150] = { };
|
||||
char temp[150]{};
|
||||
|
||||
if ( std::scanf("\033]50;%148[^\n]s", temp) == 1 )
|
||||
{
|
||||
@ -807,8 +827,8 @@ const FString* FTermXTerminal::captureXTermTitle()
|
||||
if ( term_detection->isKdeTerminal() )
|
||||
return 0;
|
||||
|
||||
fd_set ifds;
|
||||
struct timeval tv;
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
int stdin_no = FTermios::getStdIn();
|
||||
|
||||
FTerm::putstring (CSI "21t"); // get title
|
||||
@ -822,7 +842,7 @@ const FString* FTermXTerminal::captureXTermTitle()
|
||||
// read the terminal answer
|
||||
if ( select (stdin_no + 1, &ifds, 0, 0, &tv) > 0 )
|
||||
{
|
||||
char temp[512] = { };
|
||||
char temp[512]{};
|
||||
|
||||
if ( std::scanf("\033]l%509[^\n]s", temp) == 1 )
|
||||
{
|
||||
@ -864,6 +884,9 @@ void FTermXTerminal::enableXTermMouse()
|
||||
if ( mouse_support )
|
||||
return;
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
FTerm::putstring (CSI "?1001s" // save old highlight mouse tracking
|
||||
CSI "?1000h" // enable x11 mouse tracking
|
||||
CSI "?1002h" // enable cell motion mouse tracking
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user