commit
58c775c252
25
ChangeLog
25
ChangeLog
|
@ -1,3 +1,28 @@
|
|||
2019-10-15 Markus Gans <guru.mail@muenster.de>
|
||||
* Version 0.6.0
|
||||
|
||||
2019-10-13 Markus Gans <guru.mail@muenster.de>
|
||||
* Compile fix for Cygwin and Linux on arm architectures
|
||||
* A small color palette optimization
|
||||
* Corrected east asian ambiguous character width for OpenBSD, NetBSD,
|
||||
FreeBSD and Solaris
|
||||
|
||||
2019-10-05 Markus Gans <guru.mail@muenster.de>
|
||||
* Internal redesign of the callback call
|
||||
* Mapping of key functions in an associative container to simplify
|
||||
onKeyPress() in FListBox, FListView, FTextView and FScrollView
|
||||
|
||||
2019-10-01 Markus Gans <guru.mail@muenster.de>
|
||||
* Replacing null-terminated wide strings with FString objects
|
||||
* Fix for getColumnWidth() with newfont character
|
||||
|
||||
2019-09-29 Markus Gans <guru.mail@muenster.de>
|
||||
* Streaming into an FTextView() object
|
||||
* Fixes the streaming of empty FString objects into a stream with
|
||||
a width > 0
|
||||
* The FString operator [] now returns a null character ('\0')
|
||||
if the position is equal to the string length
|
||||
|
||||
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
|
||||
|
|
63
README.md
63
README.md
|
@ -1,5 +1,4 @@
|
|||
![FINAL CUT](logo/svg/finalcut-logo.svg)
|
||||
============================================
|
||||
|
||||
# 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.
|
||||
|
@ -7,18 +6,15 @@ The FINAL CUT is a C++ class library and widget toolkit with full mouse support
|
|||
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 />
|
||||
     [![Latest Release](https://img.shields.io/github/release/gansm/finalcut.svg)](https://github.com/gansm/finalcut/releases) <br />
|
||||
*License:*<br />
|
||||
     [![license](https://img.shields.io/github/license/gansm/finalcut.svg?colorA=#333)](COPYING) <br />
|
||||
*Travis CI:*<br />
|
||||
     [![Build Status](https://travis-ci.org/gansm/finalcut.svg?branch=master)](https://travis-ci.org/gansm/finalcut) <br />
|
||||
*Coverity Scan:*<br />
|
||||
     [![Coverity Scan Status](https://img.shields.io/coverity/scan/6508.svg)](https://scan.coverity.com/projects/6508) <br />
|
||||
*LGTM:*<br />
|
||||
     [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/gansm/finalcut.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/gansm/finalcut/context:cpp) <br />
|
||||
*Class Reference:*<br />
|
||||
     [![documented](https://codedocs.xyz/gansm/finalcut.svg)](https://codedocs.xyz/gansm/finalcut/hierarchy.html)
|
||||
| | Badge |
|
||||
|-------------------:|:------|
|
||||
| *Latest release* | [![Latest Release](https://img.shields.io/github/release/gansm/finalcut.svg)](https://github.com/gansm/finalcut/releases) |
|
||||
| *License* | [![license](https://img.shields.io/github/license/gansm/finalcut.svg?colorA=#333)](COPYING) |
|
||||
| *Class Reference* | [![documented](https://codedocs.xyz/gansm/finalcut.svg)](https://codedocs.xyz/gansm/finalcut/hierarchy.html) |
|
||||
| *Travis CI* | [![Build Status](https://travis-ci.org/gansm/finalcut.svg?branch=master)](https://travis-ci.org/gansm/finalcut)
|
||||
|*Coverity Scan* | [![Coverity Scan Status](https://img.shields.io/coverity/scan/6508.svg)](https://scan.coverity.com/projects/6508 )|
|
||||
| *LGTM* | [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/gansm/finalcut.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/gansm/finalcut/context:cpp) |
|
||||
| *CodeFactor* | [![CodeFactor](https://www.codefactor.io/repository/github/gansm/finalcut/badge)](https://www.codefactor.io/repository/github/gansm/finalcut) |
|
||||
|
||||
## Installation
|
||||
```bash
|
||||
|
@ -40,7 +36,7 @@ The structure of the Qt framework was originally the inspiration for the C++ cla
|
|||
* Solaris
|
||||
|
||||
## First steps
|
||||
Read here [how to use the library](doc/first-steps.md#first-steps-with-the-final-cut-widget-toolkit)
|
||||
See the [first steps](doc/first-steps.md#first-steps-with-the-final-cut-widget-toolkit) documentation for information on how to use the library.
|
||||
|
||||
## Some screenshots
|
||||
|
||||
|
@ -83,41 +79,34 @@ The calculator example in newfont mode:
|
|||
|
||||
Virtual terminal
|
||||
----------------
|
||||
It uses a virtual terminal to print the character via an update method on the screen.
|
||||
The virtual windows are an overlying layer to realizing window movements.
|
||||
The update method transmits only the changes to the virtual terminal or the screen.
|
||||
FINAL CUT uses a virtual terminal to print character via an update method on the screen. It provides (as an overlying layer) virtual windows for the realization of window movements. The update methods only transfer differences to the virtual terminal or physical screen.
|
||||
|
||||
<pre style="line-height: 1 !important;">
|
||||
print(...)
|
||||
printf(...)
|
||||
│
|
||||
│ ╔═════════════════════════[ vterm ]═════════════════════════╗
|
||||
│ ╔════════════════════════[ vterm ]════════════════════════╗
|
||||
│ ║createVTerm() ║
|
||||
│ ║ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ║
|
||||
│ ║ ║
|
||||
│ ║ │ restoreVTerm(x,y,w,h) │ ║
|
||||
│ ║ ║
|
||||
│ ║ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ║
|
||||
│ ║ ║
|
||||
│ ┌───────╨─────[ vwin ]─────────────┐ ║
|
||||
│ │createArea(area) │ ║
|
||||
│ ┌───────╨────[ vwin ]────────────┐ ║
|
||||
│ │createArea(area) │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ║
|
||||
│ │ │ ║
|
||||
│ │ │ ║
|
||||
└───┼─────────────► ──────► updateVTerm(area) ────► ║
|
||||
└──┼────────► putArea(area) ────► ║
|
||||
│ │ ║
|
||||
│ putArea(x,y,area) ────► ║
|
||||
│ │ ║
|
||||
│ ◄──── getArea(x,y,area) ║
|
||||
│ │ ║
|
||||
│ putArea(x,y,area) ║
|
||||
│ ────────────────────► ║
|
||||
│ getArea(x,y,area) ║
|
||||
│ ◄──────────────────── ║
|
||||
│ │ ║
|
||||
│ │ ║
|
||||
│ resizeArea(area)│ ║
|
||||
└───────╥──────────────────────────┘ ║
|
||||
║ ║
|
||||
║ ║
|
||||
└───────╥────────────────────────┘ ║
|
||||
║ ║
|
||||
║ │ resizeVTerm()║
|
||||
╚═══▼═══════════════════════════════════════════════════════╝
|
||||
╚═══════▼═════════════════════════════════════════════════╝
|
||||
│
|
||||
│ putVTerm()
|
||||
└──────────────────► updateTerminalLine(y)
|
||||
|
@ -127,10 +116,8 @@ printf(...)
|
|||
│ output_buffer │
|
||||
└───────────────┘
|
||||
│
|
||||
│ flush_out()
|
||||
│ +
|
||||
│ Fputchar(char)
|
||||
│
|
||||
│ flushOutputBuffer()
|
||||
│ and putchar(char)
|
||||
▼
|
||||
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
|
||||
▌ ▐
|
||||
|
@ -261,9 +248,7 @@ GNU Lesser General Public License Version 3
|
|||
|
||||
Frequently Asked Questions
|
||||
--------------------------
|
||||
If you have any problems, please read the
|
||||
[FAQ](doc/faq.md#frequently-asked-questions)
|
||||
before you give up.
|
||||
For general questions about FINAL CUT, likely the answer is already included in the [FAQ](doc/faq.md#frequently-asked-questions).
|
||||
|
||||
Please send bug reports to
|
||||
--------------------------
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT([finalcut], [0.5.1])
|
||||
AC_INIT([finalcut], [0.6.0])
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
AX_PREFIX_CONFIG_H([src/include/final/fconfig.h], [F])
|
||||
AC_CONFIG_SRCDIR([src/fobject.cpp])
|
||||
|
@ -61,7 +61,7 @@ LT_OUTPUT
|
|||
### This defines the version number of the installed .so files
|
||||
### Update this value for every release! (A:B:C will map to foo.so.(A-C).C.B)
|
||||
### using libtool's versioning system.
|
||||
AC_SUBST(SO_VERSION, ["5:1:5"])
|
||||
AC_SUBST(SO_VERSION, ["6:0:6"])
|
||||
|
||||
AC_SUBST([LIBTOOL_DEPS])
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
||||
<fontconfig>
|
||||
<selectfont>
|
||||
<acceptfont>
|
||||
<pattern>
|
||||
<patelt name="family"><string>8x16graph</string></patelt>
|
||||
</pattern>
|
||||
</acceptfont>
|
||||
</selectfont>
|
||||
</fontconfig>
|
|
@ -1,3 +1,9 @@
|
|||
finalcut (0.6.0) unstable; urgency=low
|
||||
|
||||
* Release (version 0.6.0)
|
||||
|
||||
-- Markus Gans <guru.mail@muenster.de> Mon, 14 Oct 2019 01:49:57 +0100
|
||||
|
||||
finalcut (0.5.0) unstable; urgency=low
|
||||
|
||||
* Release (version 0.5.0)
|
||||
|
|
|
@ -19,7 +19,8 @@ Architecture: any
|
|||
Pre-Depends: ${misc:Pre-Depends}
|
||||
Multi-Arch: same
|
||||
Depends:
|
||||
${shlibs:Depends}
|
||||
xfonts-utils
|
||||
, ${shlibs:Depends}
|
||||
, ${misc:Depends}
|
||||
Suggests:
|
||||
coreutils
|
||||
|
|
|
@ -30,3 +30,4 @@ doc/vt100_line_drawing_graphics.png
|
|||
doc/virtual-terminal.txt
|
||||
doc/xterm.txt
|
||||
doc/xgraphics
|
||||
fonts/newfont.txt
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
examples/.libs/* usr/share/doc/libfinal-examples/examples
|
||||
examples/*.cpp usr/share/doc/libfinal-examples/examples
|
||||
examples/Makefile.clang usr/share/doc/libfinal-examples/examples
|
||||
examples/Makefile.gcc usr/share/doc/libfinal-examples/examples
|
||||
doc/readme.txt usr/lib/libfinal/examples
|
||||
examples/.libs/* usr/lib/libfinal/examples
|
||||
examples/*.cpp usr/lib/libfinal/examples
|
||||
examples/Makefile.clang usr/lib/libfinal/examples
|
||||
examples/Makefile.gcc usr/lib/libfinal/examples
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
usr/share/doc/libfinal-examples/examples/Makefile.gcc usr/share/doc/libfinal-examples/examples/Makefile
|
||||
usr/lib/libfinal/examples usr/share/doc/libfinal-examples/examples
|
||||
usr/lib/libfinal/examples/Makefile.gcc usr/lib/libfinal/examples/Makefile
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
AUTHORS
|
||||
COPYING
|
||||
COPYING.LESSER
|
||||
ChangeLog
|
||||
doc/readme.txt
|
||||
fonts/newfont.txt
|
|
@ -1,3 +1,5 @@
|
|||
usr/lib/*/lib*.so
|
||||
usr/lib/*/lib*.so.*
|
||||
|
||||
fonts/8x16graph.pcf.gz /usr/share/fonts/X11/misc/
|
||||
fonts/xfonts-finalcut-newfont.alias /etc/X11/fonts/misc/
|
||||
debian/40-finalcut-newfont.conf etc/fonts/conf.avail
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
etc/fonts/conf.avail/40-finalcut-newfont.conf etc/fonts/conf.d/40-finalcut-newfont.conf
|
|
@ -1 +1 @@
|
|||
libfinal 0 libfinal0 (>= 0.5.1)
|
||||
libfinal 0 libfinal0 (>= 0.6.0)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,6 +19,8 @@ include /usr/share/dpkg/default.mk
|
|||
|
||||
# main packaging script based on dh7 syntax
|
||||
%:
|
||||
sed -i 's/doc\///g' README.md
|
||||
test -f fonts/fonts.alias && cp fonts/fonts.alias fonts/xfonts-finalcut-newfont.alias || true
|
||||
dh $@ --with autotools-dev
|
||||
|
||||
# debmake generated override targets
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
docdir = ${datadir}/doc/${PACKAGE}
|
||||
|
||||
EXTRA_DIST = \
|
||||
build_openbsd.txt \
|
||||
build_solaris.txt \
|
||||
calendar-draft.png \
|
||||
calculator.png \
|
||||
class-diagram.txt \
|
||||
|
@ -34,6 +36,8 @@ EXTRA_DIST = \
|
|||
xgraphics
|
||||
|
||||
doc_DATA = \
|
||||
build_openbsd.txt \
|
||||
build_solaris.txt \
|
||||
calendar-draft.png \
|
||||
calculator.png \
|
||||
class-diagram.txt \
|
||||
|
|
|
@ -116,7 +116,6 @@ class FClassName
|
|||
// Data members
|
||||
|
||||
// Friend class
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -900,6 +900,7 @@ class dialogWidget : public FDialog
|
|||
setGeometry (FPoint(28, 2), FSize(24, 21));
|
||||
scrollview.setGeometry(FPoint(1, 1), FSize(22, 11));
|
||||
scrollview.setScrollSize(FSize(60, 27));
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.label_inactive_fg, wc.dialog_bg);
|
||||
scrollview.clearArea();
|
||||
FColorPair red (fc::LightRed, wc.dialog_bg);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
----------------------------------------------------------------------
|
||||
The Final Cut
|
||||
FINAL CUT
|
||||
----------------------------------------------------------------------
|
||||
|
||||
The Final Cut is a C++ class library and widget toolkit with full mouse
|
||||
The FINAL CUT is a C++ class library and widget toolkit with full mouse
|
||||
support for creating a 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.
|
||||
|
@ -12,3 +12,50 @@ 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
|
||||
------------
|
||||
> git clone git://github.com/gansm/finalcut.git
|
||||
> cd finalcut
|
||||
> autoreconf --install --force
|
||||
> ./configure --prefix=/usr
|
||||
> make
|
||||
> su -c "make install"
|
||||
|
||||
|
||||
Supported platforms
|
||||
-------------------
|
||||
* Linux
|
||||
* FreeBSD
|
||||
* NetBSD
|
||||
* OpenBSD
|
||||
* macOS
|
||||
* Cygwin
|
||||
* Solaris
|
||||
|
||||
|
||||
First steps
|
||||
-----------
|
||||
See the first-steps.md documentation for information on how to use
|
||||
the library.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
GNU Lesser General Public License Version 3
|
||||
|
||||
|
||||
Frequently Asked Questions
|
||||
--------------------------
|
||||
For general questions about FINAL CUT, likely the answer is already included in the faq.md.
|
||||
|
||||
|
||||
Download
|
||||
--------
|
||||
You can find the latest version at https://github.com/gansm/finalcut
|
||||
|
||||
|
||||
Please send bug reports to
|
||||
--------------------------
|
||||
https://github.com/gansm/finalcut/issues
|
||||
|
||||
|
|
|
@ -1,36 +1,38 @@
|
|||
The virtual terminal (vterm)
|
||||
----------------------------
|
||||
|
||||
FINAL CUT uses a virtual terminal to print character via an update method
|
||||
on the screen. It provides (as an overlying layer) virtual windows for
|
||||
the realization of window movements. The update methods only transfer
|
||||
differences to the virtual terminal or physical screen.
|
||||
|
||||
|
||||
|
||||
print(...)
|
||||
printf(...)
|
||||
│
|
||||
│ ╔═════════════════════════[ vterm ]═════════════════════════╗
|
||||
│ ╔════════════════════════[ vterm ]════════════════════════╗
|
||||
│ ║createVTerm() ║
|
||||
│ ║ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ║
|
||||
│ ║ ║
|
||||
│ ║ │ restoreVTerm(x,y,w,h) │ ║
|
||||
│ ║ ║
|
||||
│ ║ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ║
|
||||
│ ║ ║
|
||||
│ ┌───────╨─────[ vwin ]─────────────┐ ║
|
||||
│ │createArea(area) │ ║
|
||||
│ ┌───────╨────[ vwin ]────────────┐ ║
|
||||
│ │createArea(area) │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ║
|
||||
│ │ │ ║
|
||||
│ │ │ ║
|
||||
└───┼─────────────► ──────► updateVTerm(area) ────► ║
|
||||
└──┼────────► putArea(area) ────► ║
|
||||
│ │ ║
|
||||
│ putArea(x,y,area) ────► ║
|
||||
│ │ ║
|
||||
│ ◄──── getArea(x,y,area) ║
|
||||
│ │ ║
|
||||
│ putArea(x,y,area) ║
|
||||
│ ────────────────────► ║
|
||||
│ getArea(x,y,area) ║
|
||||
│ ◄──────────────────── ║
|
||||
│ │ ║
|
||||
│ │ ║
|
||||
│ resizeArea(area)│ ║
|
||||
└───────╥──────────────────────────┘ ║
|
||||
║ ║
|
||||
║ ║
|
||||
└───────╥────────────────────────┘ ║
|
||||
║ ║
|
||||
║ │ resizeVTerm()║
|
||||
╚═══▼═══════════════════════════════════════════════════════╝
|
||||
╚═══════▼═════════════════════════════════════════════════╝
|
||||
│
|
||||
│ putVTerm()
|
||||
└──────────────────► updateTerminalLine(y)
|
||||
|
@ -40,10 +42,8 @@ printf(...)
|
|||
│ output_buffer │
|
||||
└───────────────┘
|
||||
│
|
||||
│ flush_out()
|
||||
│ +
|
||||
│ Fputchar(char)
|
||||
│
|
||||
│ flushOutputBuffer()
|
||||
│ and putchar(char)
|
||||
▼
|
||||
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
|
||||
▌ ▐
|
||||
|
@ -54,4 +54,3 @@ printf(...)
|
|||
▀▀▀▀▀▀▀███▀▀▀▀▀▀▀
|
||||
███
|
||||
▀▀▀▀▀▀▀▀▀
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ INCLUDES = -I../src/include -I/usr/include/final
|
|||
RM = rm -f
|
||||
|
||||
ifdef DEBUG
|
||||
OPTIMIZE = -O0 -fsanitize=bool,bounds,enum,float-cast-overflow,function,null
|
||||
OPTIMIZE = -O0 -fsanitize=undefined
|
||||
else
|
||||
OPTIMIZE = -O2
|
||||
endif
|
||||
|
|
|
@ -80,7 +80,7 @@ void Button::setChecked (bool enable)
|
|||
}
|
||||
else
|
||||
{
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
const auto& wc = getFWidgetColors();
|
||||
setBackgroundColor(wc.button_active_bg);
|
||||
setFocusForegroundColor(wc.button_active_focus_fg);
|
||||
setFocusBackgroundColor(wc.button_active_focus_bg);
|
||||
|
@ -328,7 +328,7 @@ void Calc::drawDispay()
|
|||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
const auto& wc = getFWidgetColors();
|
||||
print() << FColorPair(fc::Black, fc::LightGray)
|
||||
<< FPoint(3, 3) << display << ' '
|
||||
<< FColorPair(wc.dialog_fg, wc.dialog_bg);
|
||||
|
@ -898,9 +898,7 @@ lDouble& Calc::getValue()
|
|||
//----------------------------------------------------------------------
|
||||
void Calc::setDisplay (lDouble d)
|
||||
{
|
||||
char buffer[33]{};
|
||||
snprintf (buffer, sizeof(buffer), "%32.11Lg", d);
|
||||
input = buffer;
|
||||
input.sprintf("%32.11Lg", d);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -126,12 +126,10 @@ void CheckList::populate()
|
|||
{ "Lemons", "Low" }
|
||||
};
|
||||
|
||||
constexpr int lastItem = int(sizeof(list) / sizeof(list[0])) - 1;
|
||||
|
||||
for (int i{0}; i <= lastItem; i++)
|
||||
for (const auto& line : list)
|
||||
{
|
||||
const finalcut::FStringList line (&list[i][0], &list[i][0] + 2);
|
||||
auto iter = listView.insert (line);
|
||||
const finalcut::FStringList string_line (&line[0], &line[0] + 2);
|
||||
auto iter = listView.insert (string_line);
|
||||
auto item = static_cast<finalcut::FListViewItem*>(*iter);
|
||||
item->setCheckable(true);
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ int main (int argc, char* argv[])
|
|||
ok.addCallback
|
||||
(
|
||||
"clicked",
|
||||
F_FUNCTION_CALLBACK (&cb_quit),
|
||||
&cb_quit,
|
||||
&dgl
|
||||
);
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ int main (int argc, char* argv[])
|
|||
btn.addCallback
|
||||
(
|
||||
"clicked",
|
||||
F_FUNCTION_CALLBACK (&cb_quit),
|
||||
&cb_quit,
|
||||
&app
|
||||
);
|
||||
|
||||
|
|
|
@ -74,9 +74,9 @@ int main (int argc, char* argv[])
|
|||
scroll_text.setGeometry (FPoint(2, 8), FSize(32, 3));
|
||||
finalcut::FString text_line{"FINAL CUT supports "
|
||||
"full-width characters."};
|
||||
scroll_text << full(text_line);
|
||||
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);
|
||||
|
|
|
@ -120,7 +120,7 @@ int main (int argc, char* argv[])
|
|||
check1.addCallback
|
||||
(
|
||||
"clicked",
|
||||
F_FUNCTION_CALLBACK (&cb_publish),
|
||||
&cb_publish,
|
||||
&check2
|
||||
);
|
||||
|
||||
|
@ -128,7 +128,7 @@ int main (int argc, char* argv[])
|
|||
btn.addCallback
|
||||
(
|
||||
"clicked",
|
||||
F_FUNCTION_CALLBACK (&cb_quit),
|
||||
&cb_quit,
|
||||
&app
|
||||
);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ FString& mapToString ( std::map<FString
|
|||
, FString>::const_iterator iter );
|
||||
|
||||
|
||||
// Lazy conversion import function
|
||||
// Lazy conversion insert function
|
||||
void doubleToItem ( FListBoxItem& item
|
||||
, FDataPtr container, int index)
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ void doubleToItem ( FListBoxItem& item
|
|||
item.setData (FDataPtr(&(*iter)));
|
||||
}
|
||||
|
||||
// Import converter functions
|
||||
// Insert converter functions
|
||||
FString& doubleToString (std::list<double>::const_iterator iter)
|
||||
{
|
||||
auto temp = temp_str.lock();
|
||||
|
@ -127,12 +127,12 @@ Listbox::Listbox (FWidget* parent)
|
|||
list2.setText ("double");
|
||||
|
||||
//
|
||||
// Import via lazy conversion on print
|
||||
// Insert via lazy conversion on print
|
||||
//
|
||||
list2.insert (&double_list, doubleToItem);
|
||||
|
||||
//
|
||||
// Direct import of the complete list
|
||||
// Direct insert of the complete list
|
||||
//
|
||||
//list2.insert (double_list.begin(), double_list.end(), doubleToString);
|
||||
|
||||
|
|
|
@ -173,11 +173,9 @@ void Listview::populate()
|
|||
{ "Zurich", "Mostly Cloudy", "23°C", "44%", "1023.7 mb" }
|
||||
};
|
||||
|
||||
constexpr int lastItem = int(sizeof(weather) / sizeof(weather[0])) - 1;
|
||||
|
||||
for (int i{0}; i <= lastItem; i++)
|
||||
for (const auto& place : weather)
|
||||
{
|
||||
finalcut::FStringList line (&weather[i][0], &weather[i][0] + 5);
|
||||
finalcut::FStringList line (&place[0], &place[0] + 5);
|
||||
listView.insert (line);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -350,7 +350,7 @@ class MouseDraw : public finalcut::FDialog
|
|||
void cb_colorChanged (finalcut::FWidget*, FDataPtr);
|
||||
|
||||
// Data members
|
||||
term_area* canvas{nullptr};
|
||||
FTermArea* canvas{nullptr};
|
||||
ColorChooser c_chooser{this};
|
||||
Brushes brush{this};
|
||||
};
|
||||
|
@ -495,13 +495,13 @@ void MouseDraw::drawCanvas()
|
|||
|
||||
for (int y{0}; y < y_end; y++) // line loop
|
||||
{
|
||||
finalcut::charData* canvaschar{}; // canvas character
|
||||
finalcut::charData* winchar{}; // window character
|
||||
canvaschar = &canvas->text[y * x_end];
|
||||
winchar = &printarea->text[(ay + y) * w_line_len + ax];
|
||||
finalcut::FChar* canvaschar{}; // canvas character
|
||||
finalcut::FChar* winchar{}; // window character
|
||||
canvaschar = &canvas->data[y * x_end];
|
||||
winchar = &printarea->data[(ay + y) * w_line_len + ax];
|
||||
std::memcpy ( winchar
|
||||
, canvaschar
|
||||
, sizeof(finalcut::charData) * unsigned(x_end) );
|
||||
, sizeof(finalcut::FChar) * unsigned(x_end) );
|
||||
|
||||
if ( int(printarea->changes[ay + y].xmin) > ax )
|
||||
printarea->changes[ay + y].xmin = uInt(ax);
|
||||
|
|
|
@ -87,8 +87,7 @@ 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 from[26]{}, to[26]{}, byte[20]{};
|
||||
finalcut::FString buffer{}, sequence{}, from{}, to{}, byte{};
|
||||
const std::string ctrl_character[] =
|
||||
{
|
||||
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
|
||||
|
@ -100,36 +99,33 @@ void move (int xold, int yold, int xnew, int ynew)
|
|||
|
||||
term_boundaries(xold, yold);
|
||||
term_boundaries(xnew, ynew);
|
||||
snprintf (from, sizeof(from), "(%3d;%3d)", xold, yold);
|
||||
snprintf (to, sizeof(to), "(%3d;%3d)", xnew, ynew);
|
||||
std::cout << std::right << std::setw(10) << from
|
||||
<< " -> "
|
||||
<< std::left << std::setw(10) << to
|
||||
<< " ";
|
||||
|
||||
// get the move string
|
||||
char* buffer = finalcut::FTerm::moveCursorString (xold, yold, xnew, ynew);
|
||||
uInt len = uInt(std::strlen(buffer));
|
||||
buffer = finalcut::FTerm::moveCursorString (xold, yold, xnew, ynew);
|
||||
|
||||
for (uInt i = 0; i < len; i++)
|
||||
for (auto&& ch : buffer)
|
||||
{
|
||||
char ch = buffer[i];
|
||||
|
||||
if ( ch < 0x21 )
|
||||
sequence += ctrl_character[uInt(ch)];
|
||||
sequence += ctrl_character[std::size_t(ch)];
|
||||
else
|
||||
sequence += ch;
|
||||
|
||||
sequence += ' ';
|
||||
}
|
||||
|
||||
std::cout << std::setw(21) << sequence << " ";
|
||||
from.sprintf ("(%3d;%3d)", xold, yold);
|
||||
to.sprintf ("(%3d;%3d)", xnew, ynew);
|
||||
std::size_t len = buffer.getLength();
|
||||
|
||||
if ( len <= 1 )
|
||||
snprintf (byte, sizeof(byte), "%d byte ", len);
|
||||
byte.sprintf ("%d byte ", len);
|
||||
else
|
||||
snprintf (byte, sizeof(byte), "%d bytes", len);
|
||||
byte.sprintf ("%d bytes", len);
|
||||
|
||||
std::cout << std::right << std::setw(10) << byte << "\r\n";
|
||||
std::cout << std::right << std::setw(10) << from << " -> "
|
||||
<< std::left << std::setw(10) << to << " "
|
||||
<< std::setw(21) << sequence << " "
|
||||
<< std::right << std::setw(10) << byte << "\r\n";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ void Scrollview::draw()
|
|||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.label_inactive_fg, wc.dialog_bg);
|
||||
clearArea();
|
||||
|
||||
|
@ -141,7 +141,6 @@ void Scrollview::draw()
|
|||
|
||||
for (int x{0}; x < int(getScrollWidth()); x++)
|
||||
print (32 + ((x + y) % 0x5f));
|
||||
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
|
|
|
@ -262,7 +262,7 @@ void AttribDemo::printColorLine()
|
|||
//----------------------------------------------------------------------
|
||||
void AttribDemo::printAltCharset()
|
||||
{
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
const auto& wc = getFWidgetColors();
|
||||
auto parent = static_cast<AttribDlg*>(getParent());
|
||||
|
||||
if ( ! isMonochron() )
|
||||
|
@ -413,7 +413,7 @@ void AttribDemo::printProtected()
|
|||
void AttribDemo::draw()
|
||||
{
|
||||
// test alternate character set
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
const auto& wc = getFWidgetColors();
|
||||
printAltCharset();
|
||||
|
||||
std::vector<std::function<void()> > effect
|
||||
|
|
|
@ -44,8 +44,6 @@ void string();
|
|||
|
||||
struct data
|
||||
{
|
||||
static int getNumberOfItems();
|
||||
|
||||
struct alignas(alignof(std::string)) termcap_string
|
||||
{
|
||||
const std::string name;
|
||||
|
@ -144,13 +142,6 @@ data::termcap_string data::strings[] =
|
|||
{ "t_key_mouse", fc::t_key_mouse }
|
||||
};
|
||||
|
||||
// data inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline int data::getNumberOfItems()
|
||||
{
|
||||
return int ( sizeof(strings) / sizeof(strings[0]) ) - 1;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Functions
|
||||
|
@ -290,10 +281,10 @@ void string()
|
|||
finalcut::FTermcap::tcap_map (&tcap_strings)[] \
|
||||
= finalcut::FTermcap::strings;
|
||||
|
||||
for (int n{0}; n <= data::getNumberOfItems(); n++ )
|
||||
for (const auto& entry : data::strings)
|
||||
{
|
||||
const std::string name = data::strings[n].name;
|
||||
const fc::termcaps cap = data::strings[n].cap;
|
||||
const std::string name = entry.name;
|
||||
const fc::termcaps cap = entry.cap;
|
||||
tcapString (name, tcap_strings[cap].string);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ void Transparent::draw()
|
|||
|
||||
if ( type == shadow )
|
||||
{
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor(wc.shadow_bg, wc.shadow_fg);
|
||||
setTransShadow();
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ void MainWindow::onTimer (finalcut::FTimerEvent*)
|
|||
line1 = line1.right(length - 1) + first_Char[0];
|
||||
line2 = line2.right(length - 1) + first_Char[1];
|
||||
redraw();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -322,7 +322,7 @@ Treeview::Treeview (finalcut::FWidget* parent)
|
|||
listView.setTreeView();
|
||||
|
||||
// Populate FListView with a list of items
|
||||
static TreeItem continent[] =
|
||||
static TreeItem continent_list[] =
|
||||
{
|
||||
{ "Africa", "944,000,000", "31.2", africa },
|
||||
{ "Asia", "4,010,000,000", "90.3", asia },
|
||||
|
@ -330,17 +330,14 @@ Treeview::Treeview (finalcut::FWidget* parent)
|
|||
{ "North America", "523,000,000", "21", north_america },
|
||||
{ "South America", "381,000,000", "21.4", south_america },
|
||||
{ "Antarctica", "1000", "0", 0 },
|
||||
{ "Australia/Oceania", "34,000,000", "4", oceania },
|
||||
{ 0, 0, 0, 0 }
|
||||
{ "Australia/Oceania", "34,000,000", "4", oceania }
|
||||
};
|
||||
|
||||
auto continent_list = continent;
|
||||
|
||||
while ( continent_list->name )
|
||||
for (const auto& continent : continent_list)
|
||||
{
|
||||
auto& country_list = continent_list->child_element;
|
||||
finalcut::FStringList continent_line ( continent_list->begin()
|
||||
, continent_list->end() );
|
||||
TreeItem* country_list = continent.child_element;
|
||||
finalcut::FStringList continent_line ( continent.begin()
|
||||
, continent.end() );
|
||||
const auto& iter = listView.insert (continent_line);
|
||||
|
||||
while ( country_list && country_list->name )
|
||||
|
@ -350,8 +347,6 @@ Treeview::Treeview (finalcut::FWidget* parent)
|
|||
listView.insert (country_line, iter);
|
||||
country_list++;
|
||||
}
|
||||
|
||||
continent_list++;
|
||||
}
|
||||
|
||||
// Quit button
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
@ -95,6 +96,7 @@ ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
|
|||
progressBar.setGeometry(FPoint(2, 3), FSize(34, 1), false);
|
||||
//progressBar.setPercentage(78);
|
||||
|
||||
using namespace std::placeholders;
|
||||
reset.addCallback
|
||||
(
|
||||
"clicked",
|
||||
|
@ -134,7 +136,7 @@ void ProgressDialog::onTimer (finalcut::FTimerEvent*)
|
|||
{
|
||||
auto p = progressBar.getPercentage();
|
||||
progressBar.setPercentage(++p);
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
|
||||
if ( p != 100 )
|
||||
return;
|
||||
|
@ -152,7 +154,7 @@ void ProgressDialog::onTimer (finalcut::FTimerEvent*)
|
|||
getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -68,7 +68,7 @@ class SmallWindow : public finalcut::FDialog
|
|||
SmallWindow::SmallWindow (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
{
|
||||
const finalcut::FWidgetColors& wc = getFWidgetColors();
|
||||
const auto& wc = getFWidgetColors();
|
||||
wchar_t arrow_up, arrow_down;
|
||||
arrow_up = fc::BlackUpPointingTriangle;
|
||||
arrow_down = fc::BlackDownPointingTriangle;
|
||||
|
@ -377,7 +377,7 @@ void Window::addClickedCallback ( finalcut::FWidget* widget
|
|||
, WindowCallback call )
|
||||
{
|
||||
FMemberCallback callback
|
||||
= reinterpret_cast<finalcut::FWidget::FMemberCallback>(call);
|
||||
= reinterpret_cast<FMemberCallback>(call);
|
||||
|
||||
widget->addCallback
|
||||
(
|
||||
|
@ -391,7 +391,7 @@ void Window::addClickedCallback ( finalcut::FWidget* widget
|
|||
, FAppCallback call )
|
||||
{
|
||||
FMemberCallback callback
|
||||
= reinterpret_cast<finalcut::FWidget::FMemberCallback>(call);
|
||||
= reinterpret_cast<FMemberCallback>(call);
|
||||
|
||||
widget->addCallback
|
||||
(
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
-------------------------------------------------------------------
|
||||
Mon Oct 14 23:49:57 UTC 2019 - Markus Gans <guru.mail@muenster.de>
|
||||
- Release (version 0.6.0)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Dec 01 21:28:25 UTC 2018 - Markus Gans <guru.mail@muenster.de>
|
||||
- Release (version 0.5.1)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Nov 28 23:36:24 UTC 2018 - Markus Gans <guru.mail@muenster.de>
|
||||
- Package name adjustment
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Nov 26 11:22:27 UTC 2018 - mvetter@suse.com
|
||||
|
||||
- Prepare to push to devel project
|
||||
- Remove old tarball: finalcut-0.3.0.tar.gz
|
||||
- Remove old tarball: finalcut-0.4.0.tar.gz
|
||||
- Clean spec with spec-cleaner
|
||||
- Add changes file
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Nov 25 00:03:36 UTC 2018 - Markus Gans <guru.mail@muenster.de>
|
||||
- Release (version 0.5.0)
|
||||
|
@ -17,3 +38,4 @@ Sat Dec 19 21:01:48 UTC 2015 - Markus Gans <guru.mail@muenster.de>
|
|||
-------------------------------------------------------------------
|
||||
Fri Sep 18 22:35:57 UTC 2015 - Markus Gans <guru.mail@muenster.de>
|
||||
- Initial Release (version 0.1.1)
|
||||
|
||||
|
|
|
@ -15,3 +15,13 @@ EXTRA_DIST = \
|
|||
newfont.h \
|
||||
unicodemap.h \
|
||||
vgafont.h
|
||||
|
||||
docdir = ${datadir}/doc/${PACKAGE}
|
||||
doc_DATA = \
|
||||
newfont.txt
|
||||
|
||||
fontdir = ${datadir}/fonts/X11/misc/${PACKAGE}
|
||||
font_DATA = \
|
||||
8x16graph.pcf.gz \
|
||||
fonts.alias \
|
||||
fonts.dir
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# The FINAL CUT newfont
|
||||
## *A graphical text font for X11 and the Linux console*
|
||||
|
||||
|
||||
### How can I use the new graphical font under the Linux text console?
|
||||
|
||||
Simply start your program with the parameter `--newfont`.
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
----------------------------------------------------------------------
|
||||
The FINAL CUT newfont
|
||||
A graphical text font for X11 and the Linux console
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
How can I use the new graphical font under the Linux text console?
|
||||
------------------------------------------------------------------
|
||||
|
|
@ -9,7 +9,7 @@ else
|
|||
fi
|
||||
|
||||
# Is the file executable?
|
||||
test ! -x "$PROG" && echo "No executable file not found" && exit -1
|
||||
test ! -x "$PROG" && echo "No executable file not found" && exit 1
|
||||
|
||||
|
||||
LD_LIBRARY_PATH=../src/.libs/ valgrind --tool=callgrind -v "$PROG" 2>/dev/null
|
||||
|
|
|
@ -11,12 +11,12 @@ else
|
|||
fi
|
||||
|
||||
# Is the file executable?
|
||||
test ! -x "$PROG" && echo "No executable file not found" && exit -1
|
||||
test ! -x "$PROG" && echo "No executable file not found" && exit 1
|
||||
|
||||
# ELF executable file?
|
||||
ELFMAGIC="$(echo -e "\\x7fELF")"
|
||||
MAGIC="$(dd bs=1 count=4 if="$PROG" 2>/dev/null)"
|
||||
test "$MAGIC" != "$ELFMAGIC" && echo "No ELF executable file" && exit -2
|
||||
test "$MAGIC" != "$ELFMAGIC" && echo "No ELF executable file" && exit 2
|
||||
|
||||
LD_LIBRARY_PATH=../src/.libs/ valgrind --tool=memcheck --suppressions=../doc/ncurses.supp --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes --log-file=./valgrind.txt "$PROG" "$@"
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ libfinal_la_SOURCES = \
|
|||
ftermdetection.cpp \
|
||||
ftermios.cpp \
|
||||
fterm.cpp \
|
||||
fterm_functions.cpp \
|
||||
fvterm.cpp \
|
||||
fevent.cpp \
|
||||
foptiattr.cpp \
|
||||
|
@ -66,6 +67,7 @@ libfinal_la_SOURCES = \
|
|||
fcolorpalette.cpp \
|
||||
fwidgetcolors.cpp \
|
||||
fwidget.cpp \
|
||||
fwidget_functions.cpp \
|
||||
fobject.cpp
|
||||
|
||||
libfinal_la_LDFLAGS = -version-info @SO_VERSION@
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#-----------------------------------------------------------------------------
|
||||
|
||||
# This is where make install will install the library
|
||||
VERSION = "0.5.1"
|
||||
VERSION = "0.6.0"
|
||||
MAJOR := $(shell echo ${VERSION} | cut -d. -f1)
|
||||
LIBDIR = /usr/local/lib
|
||||
INCLUDEDIR1 = include/final
|
||||
|
@ -118,6 +118,7 @@ OBJS = \
|
|||
fstartoptions.o \
|
||||
ftermcap.o \
|
||||
fterm.o \
|
||||
fterm_functions.o \
|
||||
ftermdebugdata.o \
|
||||
ftermios.o \
|
||||
ftermdetection.o \
|
||||
|
@ -134,14 +135,14 @@ OBJS = \
|
|||
fcolorpalette.o \
|
||||
fwidgetcolors.o \
|
||||
fwidget.o \
|
||||
fwidget_functions.o \
|
||||
fevent.o \
|
||||
fobject.o
|
||||
|
||||
TERMCAP := $(shell test -n "$$(ldd {/usr,}/lib64/libncursesw.so.5 2>/dev/null | grep libtinfo)" && echo "-ltinfo" || echo "-lncurses")
|
||||
|
||||
ifdef DEBUG
|
||||
OPTIMIZE = -O0 -fsanitize=bool,bounds,enum,float-cast-overflow,function,null
|
||||
# OPTIMIZE = -O0 -fsanitize=undefined
|
||||
OPTIMIZE = -O0 -fsanitize=undefined
|
||||
else
|
||||
OPTIMIZE = -O2
|
||||
endif
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#-----------------------------------------------------------------------------
|
||||
|
||||
# This is where make install will install the library
|
||||
VERSION = "0.5.1"
|
||||
VERSION = "0.6.0"
|
||||
MAJOR := $(shell echo ${VERSION} | cut -d. -f1)
|
||||
LIBDIR = /usr/local/lib
|
||||
INCLUDEDIR1 = include/final
|
||||
|
@ -118,6 +118,7 @@ OBJS = \
|
|||
ftermcap.o \
|
||||
fstartoptions.o \
|
||||
fterm.o \
|
||||
fterm_functions.o \
|
||||
ftermdebugdata.o \
|
||||
ftermios.o \
|
||||
ftermdetection.o \
|
||||
|
@ -134,6 +135,7 @@ OBJS = \
|
|||
fcolorpalette.o \
|
||||
fwidgetcolors.o \
|
||||
fwidget.o \
|
||||
fwidget_functions.o \
|
||||
fevent.o \
|
||||
fobject.o
|
||||
|
||||
|
|
|
@ -122,12 +122,12 @@ int FApplication::exec() // run
|
|||
quit_now = false;
|
||||
quit_code = 0;
|
||||
|
||||
enter_loop();
|
||||
enterLoop();
|
||||
return quit_code;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FApplication::enter_loop() // event loop
|
||||
int FApplication::enterLoop() // event loop
|
||||
{
|
||||
loop_level++;
|
||||
quit_now = false;
|
||||
|
@ -144,7 +144,7 @@ int FApplication::enter_loop() // event loop
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::exit_loop()
|
||||
void FApplication::exitLoop()
|
||||
{
|
||||
app_exit_loop = true;
|
||||
}
|
||||
|
@ -172,10 +172,7 @@ void FApplication::quit()
|
|||
bool FApplication::sendEvent ( const FObject* receiver
|
||||
, const FEvent* event )
|
||||
{
|
||||
if ( quit_now || app_exit_loop )
|
||||
return false;
|
||||
|
||||
if ( ! receiver )
|
||||
if ( quit_now || app_exit_loop || ! receiver )
|
||||
return false;
|
||||
|
||||
if ( receiver->isWidget() )
|
||||
|
@ -370,9 +367,12 @@ void FApplication::init (uInt64 key_time, uInt64 dblclick_time)
|
|||
// Set the keyboard keypress timeout
|
||||
if ( keyboard )
|
||||
{
|
||||
FKeyboardCommand key_cmd1 (this, &FApplication::keyPressed);
|
||||
FKeyboardCommand key_cmd2 (this, &FApplication::keyReleased);
|
||||
FKeyboardCommand key_cmd3 (this, &FApplication::escapeKeyPressed);
|
||||
auto cmd1 = std::bind(&FApplication::keyPressed, this);
|
||||
auto cmd2 = std::bind(&FApplication::keyReleased, this);
|
||||
auto cmd3 = std::bind(&FApplication::escapeKeyPressed, this);
|
||||
FKeyboardCommand key_cmd1 (cmd1);
|
||||
FKeyboardCommand key_cmd2 (cmd2);
|
||||
FKeyboardCommand key_cmd3 (cmd3);
|
||||
keyboard->setPressCommand (key_cmd1);
|
||||
keyboard->setReleaseCommand (key_cmd2);
|
||||
keyboard->setEscPressedCommand (key_cmd3);
|
||||
|
@ -425,7 +425,7 @@ void FApplication::cmd_options (const int& argc, char* argv[])
|
|||
{C_STR("no-esc-for-alt-meta"), no_argument, 0, 0 },
|
||||
#endif
|
||||
|
||||
{0, 0, 0, 0 }
|
||||
{nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
||||
opterr = 0;
|
||||
|
@ -669,7 +669,7 @@ void FApplication::processKeyboardEvent()
|
|||
return;
|
||||
|
||||
findKeyboardWidget();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
keyboard->clearKeyBufferOnTimeout();
|
||||
|
||||
if ( isKeyPressed() )
|
||||
|
@ -773,10 +773,7 @@ FWidget*& FApplication::determineClickedWidget()
|
|||
{
|
||||
FWidget*& clicked = FWidget::getClickedWidget();
|
||||
|
||||
if ( clicked )
|
||||
return clicked;
|
||||
|
||||
if ( ! mouse )
|
||||
if ( clicked || ! mouse )
|
||||
return clicked;
|
||||
|
||||
if ( ! mouse->isLeftButtonPressed()
|
||||
|
@ -795,7 +792,7 @@ FWidget*& FApplication::determineClickedWidget()
|
|||
if ( window )
|
||||
{
|
||||
// Determine the widget at the current click position
|
||||
auto child = childWidgetAt (window, mouse_position);
|
||||
auto child = window->childWidgetAt (mouse_position);
|
||||
clicked = ( child != 0 ) ? child : window;
|
||||
setClickedWidget (clicked);
|
||||
}
|
||||
|
@ -858,7 +855,7 @@ void FApplication::closeOpenMenu()
|
|||
FWidget::getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -872,13 +869,7 @@ void FApplication::unselectMenubarItems()
|
|||
if ( openmenu || (mouse && mouse->isMoved()) )
|
||||
return;
|
||||
|
||||
if ( ! menu_bar )
|
||||
return;
|
||||
|
||||
if ( ! menu_bar->hasSelectedItem() )
|
||||
return;
|
||||
|
||||
if ( ! mouse )
|
||||
if ( ! (menu_bar && menu_bar->hasSelectedItem() && mouse) )
|
||||
return;
|
||||
|
||||
const auto& mouse_position = mouse->getPos();
|
||||
|
@ -899,7 +890,7 @@ void FApplication::unselectMenubarItems()
|
|||
FWidget::getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -908,10 +899,7 @@ void FApplication::sendMouseEvent()
|
|||
{
|
||||
auto clicked = FWidget::getClickedWidget();
|
||||
|
||||
if ( ! clicked )
|
||||
return;
|
||||
|
||||
if ( ! mouse )
|
||||
if ( ! (clicked && mouse) )
|
||||
return;
|
||||
|
||||
const auto& mouse_position = mouse->getPos();
|
||||
|
|
|
@ -251,14 +251,11 @@ void FButton::hide()
|
|||
if ( size == 0 )
|
||||
return;
|
||||
|
||||
char* blank = createBlankArray(size + 1);
|
||||
|
||||
for (std::size_t y{0}; y < getHeight() + s + (f << 1); y++)
|
||||
{
|
||||
print() << FPoint(1 - int(f), 1 + int(y - f)) << blank;
|
||||
print() << FPoint(1 - int(f), 1 + int(y - f))
|
||||
<< FString(size, L' ');
|
||||
}
|
||||
|
||||
destroyBlankArray (blank);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -422,25 +419,7 @@ void FButton::init()
|
|||
//----------------------------------------------------------------------
|
||||
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)) )
|
||||
{
|
||||
addAccelerator (FKey(std::tolower(int(hotkey))));
|
||||
addAccelerator (FKey(std::toupper(int(hotkey))));
|
||||
// Meta + hotkey
|
||||
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
|
||||
}
|
||||
else
|
||||
addAccelerator (hotkey);
|
||||
}
|
||||
else
|
||||
delAccelerator();
|
||||
setHotkeyViaString (this, text);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -461,9 +440,9 @@ inline std::size_t FButton::clickAnimationIndent (FWidget* parent_widget)
|
|||
|
||||
// noshadow + indent one character to the right
|
||||
if ( getFlags().flat )
|
||||
clearFlatBorder();
|
||||
clearFlatBorder(this);
|
||||
else if ( hasShadow() )
|
||||
clearShadow();
|
||||
clearShadow(this);
|
||||
|
||||
if ( parent_widget )
|
||||
setColor ( parent_widget->getForegroundColor()
|
||||
|
@ -560,7 +539,7 @@ inline void FButton::drawTopBottomBackground()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FButton::drawButtonTextLine (wchar_t button_text[])
|
||||
inline void FButton::drawButtonTextLine (const FString& button_text)
|
||||
{
|
||||
std::size_t pos{};
|
||||
print() << FPoint(2 + int(indent), 1 + int(vcenter_offset))
|
||||
|
@ -638,23 +617,12 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
|
|||
//----------------------------------------------------------------------
|
||||
void FButton::draw()
|
||||
{
|
||||
wchar_t* button_text{};
|
||||
FString button_text{};
|
||||
auto parent_widget = getParentWidget();
|
||||
auto txtlength = text.getLength();
|
||||
column_width = getColumnWidth(text);
|
||||
space_char = int(' ');
|
||||
active_focus = getFlags().active && getFlags().focus;
|
||||
|
||||
try
|
||||
{
|
||||
button_text = new wchar_t[txtlength + 1]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true); // Light background
|
||||
|
||||
|
@ -671,9 +639,9 @@ void FButton::draw()
|
|||
setReverse(false); // Dark background
|
||||
|
||||
if ( getFlags().flat && ! button_down )
|
||||
drawFlatBorder();
|
||||
drawFlatBorder(this);
|
||||
|
||||
hotkeypos = finalcut::getHotkeyPos(text.wc_str(), button_text, uInt(txtlength));
|
||||
hotkeypos = finalcut::getHotkeyPos(text, button_text);
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
column_width--;
|
||||
|
@ -697,12 +665,11 @@ void FButton::draw()
|
|||
|
||||
// Draw button shadow
|
||||
if ( ! getFlags().flat && getFlags().shadow && ! button_down )
|
||||
drawShadow();
|
||||
drawShadow(this);
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false); // Dark background
|
||||
|
||||
delete[] button_text;
|
||||
updateStatusBar();
|
||||
}
|
||||
|
||||
|
|
|
@ -182,6 +182,7 @@ void FButtonGroup::hide()
|
|||
{
|
||||
for (auto&& item : buttonlist)
|
||||
{
|
||||
// Hide items
|
||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||
toggle_button->hide();
|
||||
}
|
||||
|
@ -205,15 +206,13 @@ void FButtonGroup::hide()
|
|||
if ( size == 0 )
|
||||
return;
|
||||
|
||||
char* blank = createBlankArray(size + 1);
|
||||
// Hide border
|
||||
unsetViewportPrint();
|
||||
|
||||
for (int y{0}; y < int(getHeight()); y++)
|
||||
{
|
||||
FWidget::setPrintPos (FPoint(1, 1 + y));
|
||||
print (blank);
|
||||
}
|
||||
print() << FPoint(1, 1 + y) << FString(size, L' ');
|
||||
|
||||
destroyBlankArray (blank);
|
||||
setViewportPrint();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -308,10 +307,10 @@ void FButtonGroup::onAccel (FAccelEvent*)
|
|||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
|
||||
{
|
||||
in_ev->ignore(); // Change default value to ignore
|
||||
|
||||
if ( hasCheckedButton() && ! buttonlist.empty() )
|
||||
{
|
||||
in_ev->ignore();
|
||||
|
||||
for (auto&& item : buttonlist)
|
||||
{
|
||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||
|
@ -365,7 +364,7 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
|
|||
{
|
||||
getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,25 +373,7 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
|
|||
//----------------------------------------------------------------------
|
||||
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)) )
|
||||
{
|
||||
addAccelerator (FKey(std::tolower(int(hotkey))));
|
||||
addAccelerator (FKey(std::toupper(int(hotkey))));
|
||||
// Meta + hotkey
|
||||
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
|
||||
}
|
||||
else
|
||||
addAccelerator (hotkey);
|
||||
}
|
||||
else
|
||||
delAccelerator();
|
||||
setHotkeyViaString (this, text);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -417,36 +398,18 @@ void FButtonGroup::drawLabel()
|
|||
if ( text.isNull() || text.isEmpty() )
|
||||
return;
|
||||
|
||||
wchar_t* LabelText{};
|
||||
FString label_text{};
|
||||
FString txt{" " + text + " "};
|
||||
std::size_t length = txt.getLength();
|
||||
|
||||
try
|
||||
{
|
||||
LabelText = new wchar_t[length + 1]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
wchar_t* src = const_cast<wchar_t*>(txt.wc_str());
|
||||
wchar_t* dest = const_cast<wchar_t*>(LabelText);
|
||||
unsetViewportPrint();
|
||||
auto hotkeypos = finalcut::getHotkeyPos(src, dest, length);
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
length--;
|
||||
auto hotkeypos = finalcut::getHotkeyPos(txt, label_text);
|
||||
|
||||
if ( hasBorder() )
|
||||
FWidget::setPrintPos (FPoint(2, 1));
|
||||
else
|
||||
FWidget::setPrintPos (FPoint(0, 1));
|
||||
|
||||
drawText (LabelText, hotkeypos, length);
|
||||
drawText (label_text, hotkeypos);
|
||||
setViewportPrint();
|
||||
delete[] LabelText;
|
||||
}
|
||||
|
||||
|
||||
|
@ -457,8 +420,7 @@ bool FButtonGroup::isRadioButton (const FToggleButton* button) const
|
|||
if ( ! button )
|
||||
return false;
|
||||
|
||||
return bool ( std::strcmp ( button->getClassName()
|
||||
, C_STR("FRadioButton") ) == 0 );
|
||||
return bool( button->getClassName() == "FRadioButton" );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -472,18 +434,18 @@ void FButtonGroup::init()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::drawText ( wchar_t LabelText[]
|
||||
, std::size_t hotkeypos
|
||||
, std::size_t length )
|
||||
void FButtonGroup::drawText ( const FString& label_text
|
||||
, std::size_t hotkeypos )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
std::size_t column_width = getColumnWidth(LabelText);
|
||||
std::size_t column_width = getColumnWidth(label_text);
|
||||
std::size_t length = label_text.getLength();
|
||||
bool ellipsis{false};
|
||||
|
||||
if ( column_width > getClientWidth() )
|
||||
{
|
||||
std::size_t len = getClientWidth() - 3;
|
||||
FString s = finalcut::getColumnSubString (LabelText, 1, len);
|
||||
FString s = finalcut::getColumnSubString (label_text, 1, len);
|
||||
length = s.getLength();
|
||||
ellipsis = true;
|
||||
}
|
||||
|
@ -505,7 +467,7 @@ void FButtonGroup::drawText ( wchar_t LabelText[]
|
|||
if ( ! getFlags().no_underline )
|
||||
setUnderline();
|
||||
|
||||
print (LabelText[z]);
|
||||
print (label_text[z]);
|
||||
|
||||
if ( ! getFlags().no_underline )
|
||||
unsetUnderline();
|
||||
|
@ -513,7 +475,7 @@ void FButtonGroup::drawText ( wchar_t LabelText[]
|
|||
setColor (wc.label_emphasis_fg, wc.label_bg);
|
||||
}
|
||||
else
|
||||
print (LabelText[z]);
|
||||
print (label_text[z]);
|
||||
}
|
||||
|
||||
if ( ellipsis ) // Print ellipsis
|
||||
|
@ -577,7 +539,7 @@ void FButtonGroup::directFocus()
|
|||
{
|
||||
getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,8 +144,7 @@ uInt character[][fc::NUM_OF_ENCODINGS] =
|
|||
{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
|
||||
{0x221a, 0, 0xfb, 'x'} // √ - square root
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -204,7 +203,7 @@ 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] =
|
||||
wchar_t cp437_ucs[][2] =
|
||||
{
|
||||
{0x00, 0x0000}, // null
|
||||
{0x01, 0x263a}, // white smiling face
|
||||
|
@ -465,10 +464,10 @@ wchar_t cp437_to_ucs[][2] =
|
|||
};
|
||||
|
||||
const std::size_t lastCP437Item = \
|
||||
std::size_t((sizeof(cp437_to_ucs) / sizeof(cp437_to_ucs[0])) - 1);
|
||||
std::size_t((sizeof(cp437_ucs) / sizeof(cp437_ucs[0])) - 1);
|
||||
|
||||
// Based on http://www.unicode.org/charts/PDF/UFF00.pdf
|
||||
wchar_t halfWidth_fullWidth[][2] =
|
||||
const wchar_t halfWidth_fullWidth[][2] =
|
||||
{
|
||||
// Fullwidth ASCII variants
|
||||
{0x0020, 0x3000}, // ' ' -> ' '
|
||||
|
|
|
@ -37,18 +37,18 @@ FColorPalette::~FColorPalette() // destructor
|
|||
void FColorPalette::set8ColorPalette (funcp setPalette)
|
||||
{
|
||||
setPalette (fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::Blue, 0x22, 0x22, 0xb2);
|
||||
setPalette (fc::Blue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (fc::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::Cyan, 0x66, 0x66, 0xff);
|
||||
setPalette (fc::Cyan, 0xa0, 0xb2, 0xb2);
|
||||
setPalette (fc::Red, 0xb2, 0x18, 0x18);
|
||||
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (fc::LightGray, 0xe0, 0xe0, 0xe0);
|
||||
// The same colors again...
|
||||
setPalette (fc::DarkGray, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::LightBlue, 0x22, 0x22, 0xb2);
|
||||
setPalette (fc::LightBlue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (fc::LightGreen, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::LightCyan, 0x66, 0x66, 0xff);
|
||||
setPalette (fc::Cyan, 0xa0, 0xb2, 0xb2);
|
||||
setPalette (fc::LightRed, 0xb2, 0x18, 0x18);
|
||||
setPalette (fc::LightMagenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Yellow, 0xe8, 0x87, 0x1f);
|
||||
|
@ -59,9 +59,9 @@ void FColorPalette::set8ColorPalette (funcp setPalette)
|
|||
void FColorPalette::set16ColorPalette (funcp setPalette)
|
||||
{
|
||||
setPalette (fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::Blue, 0x22, 0x22, 0xb2);
|
||||
setPalette (fc::Blue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (fc::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::Cyan, 0x4a, 0x4a, 0xe4);
|
||||
setPalette (fc::Cyan, 0x55, 0x6a, 0xcf);
|
||||
setPalette (fc::Red, 0xba, 0x1a, 0x1a);
|
||||
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
|
|
|
@ -135,7 +135,7 @@ void FDialog::show()
|
|||
if ( isModal() )
|
||||
{
|
||||
auto fapp = FApplication::getApplicationObject();
|
||||
fapp->enter_loop();
|
||||
fapp->enterLoop();
|
||||
|
||||
if ( this == getMainWidget() )
|
||||
fapp->quit();
|
||||
|
@ -150,7 +150,7 @@ void FDialog::hide()
|
|||
if ( isModal() )
|
||||
{
|
||||
auto fapp = FApplication::getApplicationObject();
|
||||
fapp->exit_loop();
|
||||
fapp->exitLoop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,6 @@ int FDialog::exec()
|
|||
//----------------------------------------------------------------------
|
||||
void FDialog::setPos (const FPoint& pos, bool)
|
||||
{
|
||||
|
||||
setPos_error = false;
|
||||
|
||||
// Avoid to move widget completely outside the terminal
|
||||
|
@ -749,7 +748,7 @@ void FDialog::drawDialogShadow()
|
|||
if ( isMonochron() && ! getFlags().trans_shadow )
|
||||
return;
|
||||
|
||||
drawShadow();
|
||||
drawShadow(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -926,14 +925,10 @@ void FDialog::drawBorder()
|
|||
<< fc::NF_rev_border_line_right; // border right⎹
|
||||
}
|
||||
|
||||
print() << r.getLowerLeftPos() // lower left corner border ⎣
|
||||
<< fc::NF_border_corner_lower_left;
|
||||
|
||||
for (int x = r.getX1() + 1; x < r.getX2(); x++)
|
||||
print (fc::NF_border_line_bottom); // low line _
|
||||
|
||||
// lower right corner border ⎦
|
||||
print (fc::NF_rev_border_corner_lower_right);
|
||||
print() << r.getLowerLeftPos()
|
||||
<< fc::NF_border_corner_lower_left // ⎣
|
||||
<< FString(r.getWidth() - 2, fc::NF_border_line_bottom) // _
|
||||
<< fc::NF_rev_border_corner_lower_right; // ⎦
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1188,7 +1183,7 @@ void FDialog::leaveMenu()
|
|||
getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1233,7 +1228,7 @@ void FDialog::selectFirstMenuItem()
|
|||
getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <strings.h> // need for strcasecmp
|
||||
#endif
|
||||
|
||||
#include <pwd.h>
|
||||
#include <vector>
|
||||
|
||||
#include "final/fevent.h"
|
||||
|
@ -92,6 +91,7 @@ const FString fileChooser ( FWidget* parent
|
|||
// static class attributes
|
||||
FSystem* FFileDialog::fsystem{nullptr};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FFileDialog
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -453,12 +453,12 @@ void FFileDialog::clear()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
long FFileDialog::numOfDirs()
|
||||
sInt64 FFileDialog::numOfDirs()
|
||||
{
|
||||
if ( dir_entries.empty() )
|
||||
return 0;
|
||||
|
||||
long n = std::count_if ( std::begin(dir_entries)
|
||||
sInt64 n = std::count_if ( std::begin(dir_entries)
|
||||
, std::end(dir_entries)
|
||||
, [] (dir_entry& entry)
|
||||
{
|
||||
|
@ -472,14 +472,14 @@ long FFileDialog::numOfDirs()
|
|||
//----------------------------------------------------------------------
|
||||
void FFileDialog::sortDir()
|
||||
{
|
||||
long start{};
|
||||
sInt64 start{};
|
||||
|
||||
if ( std::strcmp((*dir_entries.begin()).name, "..") == 0 )
|
||||
start = 1;
|
||||
else
|
||||
start = 0;
|
||||
|
||||
long dir_num = numOfDirs();
|
||||
sInt64 dir_num = numOfDirs();
|
||||
// directories first
|
||||
std::sort ( dir_entries.begin() + start
|
||||
, dir_entries.end()
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace finalcut
|
|||
namespace fc
|
||||
{
|
||||
|
||||
fkeymap Fkey[] =
|
||||
FKeyMap fkey[] =
|
||||
{
|
||||
{ fc::Fkey_backspace , 0, "kb" }, // backspace key
|
||||
{ fc::Fkey_catab , 0, "ka" }, // clear-all-tabs key
|
||||
|
@ -205,7 +205,7 @@ fkeymap Fkey[] =
|
|||
{ 0 , 0, "\0" }
|
||||
};
|
||||
|
||||
fmetakeymap Fmetakey[] =
|
||||
FMetakeyMap fmetakey[] =
|
||||
{
|
||||
{ fc::Fmkey_ic , "\033[2;3~" }, // M-insert
|
||||
{ fc::Fmkey_ic , "\033\033[2~" }, // M-insert
|
||||
|
@ -438,7 +438,7 @@ fmetakeymap Fmetakey[] =
|
|||
{ 0 , "\0" }
|
||||
};
|
||||
|
||||
keyname FkeyName[] =
|
||||
FKeyName fkeyname[] =
|
||||
{
|
||||
{ fc::Fckey_a , "Ctrl+A" },
|
||||
{ fc::Fckey_b , "Ctrl+B" },
|
||||
|
|
|
@ -49,25 +49,6 @@ struct timeval FKeyboard::time_keypressed{};
|
|||
FTermLinux* FKeyboard::linux{nullptr};
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FKeyboardCommand
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FKeyboardCommand::FKeyboardCommand ( FApplication* object
|
||||
, void(FApplication::*method)() )
|
||||
: instance(object)
|
||||
, handler(method)
|
||||
{ }
|
||||
|
||||
// public methods of FKeyboardCommand
|
||||
//----------------------------------------------------------------------
|
||||
void FKeyboardCommand::execute()
|
||||
{
|
||||
(instance->*handler)();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FKeyboard
|
||||
|
@ -102,9 +83,9 @@ void FKeyboard::fetchKeyCode()
|
|||
//----------------------------------------------------------------------
|
||||
const FString FKeyboard::getKeyName (FKey keynum)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
|
||||
if ( keynum > 32 && keynum < 127 )
|
||||
return FString(char(keynum));
|
||||
|
@ -113,7 +94,7 @@ const FString FKeyboard::getKeyName (FKey keynum)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FKeyboard::setTermcapMap (fc::fkeymap* keymap)
|
||||
void FKeyboard::setTermcapMap (fc::FKeyMap* keymap)
|
||||
{
|
||||
key_map = keymap;
|
||||
}
|
||||
|
@ -250,7 +231,7 @@ inline FKey FKeyboard::getTermcapKey()
|
|||
fifo_buf[n] = '\0';
|
||||
|
||||
input_data_pending = bool(fifo_buf[0] != '\0');
|
||||
return fc::Fkey[i].num;
|
||||
return fc::fkey[i].num;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,9 +245,9 @@ 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
|
||||
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
|
||||
|
@ -288,7 +269,7 @@ inline FKey FKeyboard::getMetaKey()
|
|||
fifo_buf[n] = '\0';
|
||||
|
||||
input_data_pending = bool(fifo_buf[0] != '\0');
|
||||
return fc::Fmetakey[i].num;
|
||||
return fc::fmetakey[i].num;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fcolorpair.h"
|
||||
|
@ -267,7 +268,7 @@ void FLabel::onMouseDown (FMouseEvent* ev)
|
|||
{
|
||||
accel_widget->getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +295,7 @@ void FLabel::onAccel (FAccelEvent* ev)
|
|||
{
|
||||
accel_widget->getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -333,25 +334,7 @@ void FLabel::init()
|
|||
//----------------------------------------------------------------------
|
||||
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)) )
|
||||
{
|
||||
addAccelerator (FKey(std::tolower(int(hotkey))));
|
||||
addAccelerator (FKey(std::toupper(int(hotkey))));
|
||||
// Meta + hotkey
|
||||
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
|
||||
}
|
||||
else
|
||||
addAccelerator (hotkey);
|
||||
}
|
||||
else
|
||||
delAccelerator();
|
||||
setHotkeyViaString (this, text);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -423,87 +406,48 @@ void FLabel::drawMultiLine()
|
|||
|
||||
while ( y < text_lines && y < std::size_t(getHeight()) )
|
||||
{
|
||||
wchar_t* label_text{};
|
||||
std::size_t hotkeypos{NOT_SET};
|
||||
std::size_t align_offset{};
|
||||
FString label_text{};
|
||||
hotkeypos = NOT_SET;
|
||||
auto length = multiline_text[y].getLength();
|
||||
auto column_width = getColumnWidth(multiline_text[y]);
|
||||
|
||||
try
|
||||
{
|
||||
label_text = new wchar_t[length + 1]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
auto src = const_cast<wchar_t*>(multiline_text[y].wc_str());
|
||||
auto dest = const_cast<wchar_t*>(label_text);
|
||||
column_width = getColumnWidth(multiline_text[y]);
|
||||
|
||||
if ( ! hotkey_printed )
|
||||
hotkeypos = finalcut::getHotkeyPos(src, dest, length);
|
||||
hotkeypos = finalcut::getHotkeyPos (multiline_text[y], label_text);
|
||||
else
|
||||
std::wcsncpy(dest, src, length);
|
||||
label_text = multiline_text[y];
|
||||
|
||||
print() << FPoint(1, 1 + int(y));
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
{
|
||||
align_offset = getAlignOffset(length - 1);
|
||||
printLine (label_text, length - 1, column_width, hotkeypos, align_offset);
|
||||
hotkey_printed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
align_offset = getAlignOffset(length);
|
||||
printLine (label_text, length, column_width, NOT_SET, align_offset);
|
||||
}
|
||||
|
||||
printLine (std::move(label_text));
|
||||
y++;
|
||||
delete[] label_text;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLabel::drawSingleLine()
|
||||
{
|
||||
wchar_t* label_text{};
|
||||
std::size_t hotkeypos{NOT_SET};
|
||||
auto length = text.getLength();
|
||||
auto column_width = getColumnWidth(text);
|
||||
|
||||
try
|
||||
{
|
||||
label_text = new wchar_t[length + 1]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
hotkeypos = finalcut::getHotkeyPos (text.wc_str(), label_text, length);
|
||||
FString label_text{};
|
||||
column_width = getColumnWidth(text);
|
||||
hotkeypos = finalcut::getHotkeyPos (text, label_text);
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
{
|
||||
length--;
|
||||
column_width--;
|
||||
}
|
||||
|
||||
print() << FPoint(1, 1);
|
||||
auto align_offset = getAlignOffset(column_width);
|
||||
printLine (label_text, length, column_width, hotkeypos, align_offset);
|
||||
delete[] label_text;
|
||||
align_offset = getAlignOffset(column_width);
|
||||
printLine (std::move(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 )
|
||||
void FLabel::printLine (FString&& line)
|
||||
{
|
||||
std::size_t to_char{};
|
||||
std::size_t to_column{};
|
||||
|
@ -514,13 +458,13 @@ void FLabel::printLine ( wchar_t line[]
|
|||
|
||||
if ( column_width <= width )
|
||||
{
|
||||
to_char = length;
|
||||
to_char = line.getLength();
|
||||
to_column = column_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
to_column = width - 2;
|
||||
to_char = getColumnWidthToLength(line, to_column);
|
||||
to_char = getLengthFromColumnWidth(line, to_column);
|
||||
}
|
||||
|
||||
if ( hasReverseMode() )
|
||||
|
@ -530,8 +474,8 @@ void FLabel::printLine ( wchar_t line[]
|
|||
{
|
||||
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 ) )
|
||||
if ( ! isNewFont() && ( line[z] < fc::NF_rev_left_arrow2
|
||||
|| line[z] > fc::NF_check_mark ) )
|
||||
{
|
||||
line[z] = L' ';
|
||||
}
|
||||
|
|
|
@ -596,7 +596,7 @@ void FLineEdit::onAccel (FAccelEvent* ev)
|
|||
{
|
||||
getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -623,7 +623,7 @@ void FLineEdit::onFocusIn (FFocusEvent*)
|
|||
{
|
||||
getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -791,7 +791,7 @@ void FLineEdit::drawInputField()
|
|||
}
|
||||
|
||||
if ( getFlags().shadow )
|
||||
drawShadow ();
|
||||
drawShadow(this);
|
||||
|
||||
// set the cursor to the insert pos.
|
||||
auto cursor_pos_column = getColumnWidth (text, cursor_pos);
|
||||
|
@ -825,7 +825,7 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
|
|||
{
|
||||
if ( char_width == 1 )
|
||||
{
|
||||
if ( pos > 0 && getColumnWidth(text[pos - 1]) == 2 )
|
||||
if ( getColumnWidth(text[pos - 1]) == 2 ) // pos is always > 0
|
||||
{
|
||||
fullwidth_char_offset = 1;
|
||||
break;
|
||||
|
|
174
src/flistbox.cpp
174
src/flistbox.cpp
|
@ -27,7 +27,6 @@
|
|||
#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"
|
||||
|
@ -305,21 +304,16 @@ void FListBox::clear()
|
|||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.list_fg, wc.list_bg);
|
||||
std::size_t size = getWidth() - 2;
|
||||
drawBorder();
|
||||
drawHeadline();
|
||||
|
||||
if ( size == 0 )
|
||||
return;
|
||||
|
||||
char* blank = createBlankArray(size + 1);
|
||||
|
||||
std::memset (blank, ' ', size);
|
||||
blank[size] = '\0';
|
||||
|
||||
for (int y{0}; y < int(getHeight()) - 2; y++)
|
||||
{
|
||||
print() << FPoint(2, 2 + y) << blank;
|
||||
print() << FPoint(2, 2 + y) << FString(size, L' ');
|
||||
}
|
||||
|
||||
destroyBlankArray (blank);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -328,82 +322,7 @@ void FListBox::onKeyPress (FKeyEvent* ev)
|
|||
std::size_t current_before = current;
|
||||
int xoffset_before = xoffset;
|
||||
int yoffset_before = yoffset;
|
||||
FKey key = ev->key();
|
||||
|
||||
switch ( key )
|
||||
{
|
||||
case fc::Fkey_return:
|
||||
case fc::Fkey_enter:
|
||||
acceptSelection();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_up:
|
||||
onePosUp();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_down:
|
||||
onePosDown();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_left:
|
||||
scrollLeft();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
scrollRight();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_ppage:
|
||||
onePageUp();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_npage:
|
||||
onePageDown();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_home:
|
||||
firstPos();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_end:
|
||||
lastPos();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_ic: // insert key
|
||||
if ( changeSelectionAndPosition() )
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_space:
|
||||
if ( spacebarProcessing() )
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_erase:
|
||||
case fc::Fkey_backspace:
|
||||
if ( deletePreviousCharacter() )
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_escape:
|
||||
case fc::Fkey_escape_mintty:
|
||||
if ( skipIncrementalSearch() )
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
default:
|
||||
if ( keyIncSearchInput(key) )
|
||||
ev->accept();
|
||||
}
|
||||
processKeyAction(ev); // Process the keystrokes
|
||||
|
||||
if ( current_before != current )
|
||||
{
|
||||
|
@ -462,7 +381,7 @@ void FListBox::onMouseDown (FMouseEvent* ev)
|
|||
vbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -530,7 +449,7 @@ void FListBox::onMouseMove (FMouseEvent* ev)
|
|||
vbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
// Auto-scrolling when dragging mouse outside the widget
|
||||
|
@ -607,7 +526,7 @@ void FListBox::onTimer (FTimerEvent*)
|
|||
vbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -653,7 +572,7 @@ void FListBox::onWheel (FWheelEvent* ev)
|
|||
vbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -754,8 +673,8 @@ inline FString& FListBox::getString (listBoxItems::iterator iter)
|
|||
//----------------------------------------------------------------------
|
||||
void FListBox::init()
|
||||
{
|
||||
initScrollbar (vbar, fc::vertical, &FListBox::cb_VBarChange);
|
||||
initScrollbar (hbar, fc::horizontal, &FListBox::cb_HBarChange);
|
||||
initScrollbar (vbar, fc::vertical, this, &FListBox::cb_VBarChange);
|
||||
initScrollbar (hbar, fc::horizontal, this, &FListBox::cb_HBarChange);
|
||||
setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
|
@ -765,32 +684,57 @@ void FListBox::init()
|
|||
setLeftPadding(1);
|
||||
setBottomPadding(1);
|
||||
setRightPadding(1 + int(nf_offset));
|
||||
mapKeyFunctions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::initScrollbar ( FScrollbarPtr& bar
|
||||
, fc::orientation o
|
||||
, FListBoxCallback callback )
|
||||
inline void FListBox::mapKeyFunctions()
|
||||
{
|
||||
try
|
||||
{
|
||||
bar = std::make_shared<FScrollbar>(o, this);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
key_map[fc::Fkey_return] = std::bind(&FListBox::acceptSelection, this);
|
||||
key_map[fc::Fkey_enter] = std::bind(&FListBox::acceptSelection, this);
|
||||
key_map[fc::Fkey_up] = std::bind(&FListBox::onePosUp, this);
|
||||
key_map[fc::Fkey_down] = std::bind(&FListBox::onePosDown, this);
|
||||
auto left = static_cast<void(FListBox::*)()>(&FListBox::scrollLeft);
|
||||
key_map[fc::Fkey_left] = std::bind(left, this);
|
||||
auto right = static_cast<void(FListBox::*)()>(&FListBox::scrollRight);
|
||||
key_map[fc::Fkey_right] = std::bind(right, this);
|
||||
key_map[fc::Fkey_ppage] = std::bind(&FListBox::onePageUp, this);
|
||||
key_map[fc::Fkey_npage] = std::bind(&FListBox::onePageDown, this);
|
||||
key_map[fc::Fkey_home] = std::bind(&FListBox::firstPos, this);
|
||||
key_map[fc::Fkey_end] = std::bind(&FListBox::lastPos, this);
|
||||
key_map_result[fc::Fkey_ic] = \
|
||||
std::bind(&FListBox::changeSelectionAndPosition, this);
|
||||
key_map_result[fc::Fkey_space] = \
|
||||
std::bind(&FListBox::spacebarProcessing, this);
|
||||
key_map_result[fc::Fkey_erase] = \
|
||||
std::bind(&FListBox::deletePreviousCharacter, this);
|
||||
key_map_result[fc::Fkey_backspace] = \
|
||||
std::bind(&FListBox::deletePreviousCharacter, this);
|
||||
key_map_result[fc::Fkey_escape] = \
|
||||
std::bind(&FListBox::skipIncrementalSearch, this);
|
||||
key_map_result[fc::Fkey_escape_mintty] = \
|
||||
std::bind(&FListBox::skipIncrementalSearch, this);
|
||||
}
|
||||
|
||||
bar->setMinimum(0);
|
||||
bar->setValue(0);
|
||||
bar->hide();
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::processKeyAction (FKeyEvent* ev)
|
||||
{
|
||||
int idx = int(ev->key());
|
||||
|
||||
bar->addCallback
|
||||
(
|
||||
"change-value",
|
||||
F_METHOD_CALLBACK (this, callback)
|
||||
);
|
||||
if ( key_map.find(idx) != key_map.end() )
|
||||
{
|
||||
key_map[idx]();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key_map_result.find(idx) != key_map_result.end() )
|
||||
{
|
||||
if ( key_map_result[idx]() )
|
||||
ev->accept();
|
||||
}
|
||||
else if ( keyIncSearchInput(ev->key()) )
|
||||
{
|
||||
ev->accept();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1172,7 +1116,7 @@ inline void FListBox::updateDrawing (bool draw_vbar, bool draw_hbar)
|
|||
hbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1802,7 +1746,7 @@ void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
|
|||
if ( conv_type != lazy_convert || ! iter->getText().isNull() )
|
||||
return;
|
||||
|
||||
convertToItem (*iter, source_container, y + yoffset);
|
||||
lazy_inserter (*iter, source_container, y + yoffset);
|
||||
std::size_t column_width = getColumnWidth(iter->text);
|
||||
recalculateHorizontalBar (column_width, hasBrackets(iter));
|
||||
|
||||
|
@ -1872,7 +1816,7 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
|
|||
vbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1925,7 +1869,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
|
|||
{
|
||||
drawList();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward )
|
||||
|
@ -1936,7 +1880,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
|
|||
hbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "final/emptyfstring.h"
|
||||
|
@ -32,7 +33,6 @@
|
|||
#include "final/fcolorpair.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/flistview.h"
|
||||
#include "final/fscrollbar.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/fstring.h"
|
||||
#include "final/ftermbuffer.h"
|
||||
|
@ -42,7 +42,7 @@ namespace finalcut
|
|||
{
|
||||
|
||||
// Static class attribute
|
||||
FObject::FObjectIterator FListView::null_iter;
|
||||
FObject::iterator FListView::null_iter;
|
||||
|
||||
// Function prototypes
|
||||
uInt64 firstNumberFromString (const FString&);
|
||||
|
@ -55,14 +55,13 @@ bool sortDescendingByNumber (const FObject*, const FObject*);
|
|||
//----------------------------------------------------------------------
|
||||
uInt64 firstNumberFromString (const FString& str)
|
||||
{
|
||||
auto last = str.end();
|
||||
auto iter = str.begin();
|
||||
|
||||
while ( iter != last )
|
||||
while ( iter != str.end() )
|
||||
{
|
||||
if ( wchar_t(*iter) >= L'0' && wchar_t(*iter) <= L'9' )
|
||||
{
|
||||
if ( wchar_t(*(iter - 1)) == L'-' )
|
||||
if ( iter != str.begin() && wchar_t(*(iter - 1)) == L'-' )
|
||||
--iter;
|
||||
|
||||
break;
|
||||
|
@ -73,10 +72,10 @@ uInt64 firstNumberFromString (const FString& str)
|
|||
|
||||
auto first_pos = iter;
|
||||
|
||||
if ( first_pos == last )
|
||||
if ( first_pos == str.end() )
|
||||
return 0;
|
||||
|
||||
while ( iter != last )
|
||||
while ( iter != str.end() )
|
||||
{
|
||||
if ( wchar_t(*iter) < L'0' || wchar_t(*iter) > L'9' )
|
||||
break;
|
||||
|
@ -86,7 +85,7 @@ uInt64 firstNumberFromString (const FString& str)
|
|||
|
||||
auto last_pos = iter;
|
||||
|
||||
if ( last_pos == last )
|
||||
if ( last_pos == str.end() )
|
||||
return 0;
|
||||
|
||||
uInt64 number;
|
||||
|
@ -186,7 +185,7 @@ FListViewItem::FListViewItem (const FListViewItem& item)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewItem::FListViewItem (FObjectIterator parent_iter)
|
||||
FListViewItem::FListViewItem (iterator parent_iter)
|
||||
: FObject((*parent_iter)->getParent())
|
||||
{
|
||||
insert (this, parent_iter);
|
||||
|
@ -195,7 +194,7 @@ FListViewItem::FListViewItem (FObjectIterator parent_iter)
|
|||
//----------------------------------------------------------------------
|
||||
FListViewItem::FListViewItem ( const FStringList& cols
|
||||
, FDataPtr data
|
||||
, FObjectIterator parent_iter )
|
||||
, iterator parent_iter )
|
||||
: FObject(nullptr)
|
||||
, column_list(cols)
|
||||
, data_pointer(data)
|
||||
|
@ -279,7 +278,7 @@ void FListViewItem::setText (int column, const FString& text)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FObject::FObjectIterator FListViewItem::insert (FListViewItem* child)
|
||||
FObject::iterator FListViewItem::insert (FListViewItem* child)
|
||||
{
|
||||
// Add a FListViewItem as child element
|
||||
if ( ! child )
|
||||
|
@ -289,8 +288,8 @@ FObject::FObjectIterator FListViewItem::insert (FListViewItem* child)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FObject::FObjectIterator FListViewItem::insert ( FListViewItem* child
|
||||
, FObjectIterator parent_iter )
|
||||
FObject::iterator FListViewItem::insert ( FListViewItem* child
|
||||
, iterator parent_iter )
|
||||
{
|
||||
if ( parent_iter == FListView::null_iter )
|
||||
return FListView::null_iter;
|
||||
|
@ -353,7 +352,7 @@ void FListViewItem::sort (Compare cmp)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FObject::FObjectIterator FListViewItem::appendItem (FListViewItem* child)
|
||||
FObject::iterator FListViewItem::appendItem (FListViewItem* child)
|
||||
{
|
||||
expandable = true;
|
||||
resetVisibleLineCounter();
|
||||
|
@ -434,7 +433,7 @@ void FListViewItem::resetVisibleLineCounter()
|
|||
|
||||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator::FListViewIterator (FObjectIterator iter)
|
||||
FListViewIterator::FListViewIterator (iterator iter)
|
||||
: node(iter)
|
||||
{ }
|
||||
|
||||
|
@ -496,7 +495,7 @@ FListViewIterator& FListViewIterator::operator -= (volatile int n)
|
|||
|
||||
// private methods of FListViewIterator
|
||||
//----------------------------------------------------------------------
|
||||
void FListViewIterator::nextElement (FObjectIterator& iter)
|
||||
void FListViewIterator::nextElement (iterator& iter)
|
||||
{
|
||||
auto item = static_cast<FListViewItem*>(*iter);
|
||||
|
||||
|
@ -526,7 +525,7 @@ void FListViewIterator::nextElement (FObjectIterator& iter)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListViewIterator::prevElement (FObjectIterator& iter)
|
||||
void FListViewIterator::prevElement (iterator& iter)
|
||||
{
|
||||
auto start_iter = iter;
|
||||
|
||||
|
@ -713,7 +712,7 @@ void FListView::setColumnSortType (int column, fc::sorting_type type)
|
|||
if ( column < 1 || header.empty() || column > int(header.size()) )
|
||||
return;
|
||||
|
||||
std::size_t size = std::size_t(column + 1);
|
||||
std::size_t size = std::size_t(column) + 1;
|
||||
|
||||
if ( sort_type.empty() || sort_type.size() < size )
|
||||
sort_type.resize(size);
|
||||
|
@ -760,10 +759,10 @@ void FListView::hide()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FObject::FObjectIterator FListView::insert ( FListViewItem* item
|
||||
, FObjectIterator parent_iter )
|
||||
FObject::iterator FListView::insert ( FListViewItem* item
|
||||
, iterator parent_iter )
|
||||
{
|
||||
FObjectIterator item_iter;
|
||||
iterator item_iter;
|
||||
|
||||
if ( parent_iter == FListView::null_iter )
|
||||
return FListView::null_iter;
|
||||
|
@ -799,9 +798,9 @@ FObject::FObjectIterator FListView::insert ( FListViewItem* item
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FObject::FObjectIterator FListView::insert ( const FStringList& cols
|
||||
FObject::iterator FListView::insert ( const FStringList& cols
|
||||
, FDataPtr d
|
||||
, FObjectIterator parent_iter )
|
||||
, iterator parent_iter )
|
||||
{
|
||||
FListViewItem* item;
|
||||
|
||||
|
@ -877,79 +876,11 @@ void FListView::sort()
|
|||
//----------------------------------------------------------------------
|
||||
void FListView::onKeyPress (FKeyEvent* ev)
|
||||
{
|
||||
int position_before = current_iter.getPosition()
|
||||
, xoffset_before = xoffset
|
||||
, first_line_position_before = first_visible_line.getPosition()
|
||||
, pagesize = int(getClientHeight()) - 1;
|
||||
FKey key = ev->key();
|
||||
int position_before = current_iter.getPosition();
|
||||
int xoffset_before = xoffset;
|
||||
first_line_position_before = first_visible_line.getPosition();
|
||||
clicked_expander_pos.setPoint(-1, -1);
|
||||
|
||||
switch ( key )
|
||||
{
|
||||
case fc::Fkey_return:
|
||||
case fc::Fkey_enter:
|
||||
processClick();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_space:
|
||||
toggleCheckbox();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_up:
|
||||
stepBackward();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_down:
|
||||
stepForward();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_left:
|
||||
collapseAndScrollLeft (first_line_position_before);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
expandAndScrollRight (first_line_position_before);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_ppage:
|
||||
stepBackward(pagesize);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_npage:
|
||||
stepForward(pagesize);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_home:
|
||||
firstPos();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_end:
|
||||
lastPos();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case int('+'):
|
||||
if ( expandSubtree() )
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case int('-'):
|
||||
if ( collapseSubtree() )
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
default:
|
||||
ev->ignore();
|
||||
}
|
||||
processKeyAction(ev); // Process the keystrokes
|
||||
|
||||
if ( position_before != current_iter.getPosition() )
|
||||
processChanged();
|
||||
|
@ -984,9 +915,9 @@ void FListView::onMouseDown (FMouseEvent* ev)
|
|||
getStatusBar()->drawMessage();
|
||||
}
|
||||
|
||||
int first_line_position_before = first_visible_line.getPosition()
|
||||
, mouse_x = ev->getX()
|
||||
, mouse_y = ev->getY();
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
first_line_position_before = first_visible_line.getPosition();
|
||||
|
||||
if ( mouse_x > 1 && mouse_x < int(getWidth()) )
|
||||
{
|
||||
|
@ -1037,7 +968,7 @@ void FListView::onMouseDown (FMouseEvent* ev)
|
|||
vbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1121,9 +1052,9 @@ void FListView::onMouseMove (FMouseEvent* ev)
|
|||
return;
|
||||
}
|
||||
|
||||
int first_line_position_before = first_visible_line.getPosition()
|
||||
, mouse_x = ev->getX()
|
||||
, mouse_y = ev->getY();
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
first_line_position_before = first_visible_line.getPosition();
|
||||
|
||||
if ( mouse_x > 1 && mouse_x < int(getWidth())
|
||||
&& mouse_y > 1 && mouse_y < int(getHeight()) )
|
||||
|
@ -1142,7 +1073,7 @@ void FListView::onMouseMove (FMouseEvent* ev)
|
|||
vbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
// auto-scrolling when dragging mouse outside the widget
|
||||
|
@ -1196,8 +1127,8 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
|
|||
//----------------------------------------------------------------------
|
||||
void FListView::onTimer (FTimerEvent*)
|
||||
{
|
||||
int position_before = current_iter.getPosition()
|
||||
, first_line_position_before = first_visible_line.getPosition();
|
||||
int position_before = current_iter.getPosition();
|
||||
first_line_position_before = first_visible_line.getPosition();
|
||||
|
||||
switch ( int(drag_scroll) )
|
||||
{
|
||||
|
@ -1229,15 +1160,15 @@ void FListView::onTimer (FTimerEvent*)
|
|||
vbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::onWheel (FWheelEvent* ev)
|
||||
{
|
||||
int position_before = current_iter.getPosition()
|
||||
, first_line_position_before = first_visible_line.getPosition()
|
||||
, pagesize{4};
|
||||
int position_before = current_iter.getPosition();
|
||||
int pagesize{4};
|
||||
first_line_position_before = first_visible_line.getPosition();
|
||||
|
||||
if ( drag_scroll != fc::noScroll )
|
||||
stopDragScroll();
|
||||
|
@ -1268,7 +1199,7 @@ void FListView::onWheel (FWheelEvent* ev)
|
|||
vbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1379,8 +1310,8 @@ void FListView::adjustSize()
|
|||
//----------------------------------------------------------------------
|
||||
void FListView::init()
|
||||
{
|
||||
initScrollbar (vbar, fc::vertical, &FListView::cb_VBarChange);
|
||||
initScrollbar (hbar, fc::horizontal, &FListView::cb_HBarChange);
|
||||
initScrollbar (vbar, fc::vertical, this, &FListView::cb_VBarChange);
|
||||
initScrollbar (hbar, fc::horizontal, this, &FListView::cb_HBarChange);
|
||||
selflist.push_back(this);
|
||||
root = selflist.begin();
|
||||
null_iter = selflist.end();
|
||||
|
@ -1393,32 +1324,46 @@ void FListView::init()
|
|||
setLeftPadding(1);
|
||||
setBottomPadding(1);
|
||||
setRightPadding(1 + int(nf_offset));
|
||||
mapKeyFunctions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::initScrollbar ( FScrollbarPtr& bar
|
||||
, fc::orientation o
|
||||
, FListViewCallback callback )
|
||||
inline void FListView::mapKeyFunctions()
|
||||
{
|
||||
try
|
||||
{
|
||||
bar = std::make_shared<FScrollbar>(o, this);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
key_map[fc::Fkey_return] = std::bind(&FListView::processClick, this);
|
||||
key_map[fc::Fkey_enter] = std::bind(&FListView::processClick, this);
|
||||
key_map[fc::Fkey_space] = std::bind(&FListView::toggleCheckbox, this);
|
||||
key_map[fc::Fkey_up] = [&] { stepBackward(); };
|
||||
key_map[fc::Fkey_down] = [&] { stepForward(); };
|
||||
key_map[fc::Fkey_left] = std::bind(&FListView::collapseAndScrollLeft, this);
|
||||
key_map[fc::Fkey_right] = std::bind(&FListView::expandAndScrollRight, this);
|
||||
key_map[fc::Fkey_ppage] = [&] { stepBackward(int(getClientHeight()) - 1); };
|
||||
key_map[fc::Fkey_npage] = [&] { stepForward(int(getClientHeight()) - 1); };
|
||||
key_map[fc::Fkey_home] = std::bind(&FListView::firstPos, this);
|
||||
key_map[fc::Fkey_end] = std::bind(&FListView::lastPos, this);
|
||||
key_map_result[FKey('+')] = std::bind(&FListView::expandSubtree, this);
|
||||
key_map_result[FKey('-')] = std::bind(&FListView::collapseSubtree, this);
|
||||
}
|
||||
|
||||
bar->setMinimum(0);
|
||||
bar->setValue(0);
|
||||
bar->hide();
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::processKeyAction (FKeyEvent* ev)
|
||||
{
|
||||
int idx = int(ev->key());
|
||||
|
||||
bar->addCallback
|
||||
(
|
||||
"change-value",
|
||||
F_METHOD_CALLBACK (this, callback)
|
||||
);
|
||||
if ( key_map.find(idx) != key_map.end() )
|
||||
{
|
||||
key_map[idx]();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key_map_result.find(idx) != key_map_result.end() )
|
||||
{
|
||||
if ( key_map_result[idx]() )
|
||||
ev->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
ev->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1648,11 +1593,8 @@ void FListView::drawListLine ( const FListViewItem* item
|
|||
width -= (indent + 1);
|
||||
|
||||
if ( item->isCheckable() )
|
||||
{
|
||||
static constexpr std::size_t checkbox_space = 4;
|
||||
width -= checkbox_space;
|
||||
}
|
||||
}
|
||||
|
||||
// Insert alignment spaces
|
||||
if ( align_offset > 0 )
|
||||
|
@ -1881,7 +1823,7 @@ void FListView::drawBufferedHeadline()
|
|||
std::size_t offset{0};
|
||||
bool left_truncated_fullwidth{false};
|
||||
bool right_truncated_fullwidth{false};
|
||||
std::vector<charData>::const_iterator first{}, last{};
|
||||
std::vector<FChar>::const_iterator first{}, last{};
|
||||
last = headerline.end();
|
||||
|
||||
// Search for the start position
|
||||
|
@ -1992,14 +1934,13 @@ void FListView::updateDrawing (bool draw_vbar, bool draw_hbar)
|
|||
hbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t FListView::determineLineWidth (FListViewItem* item)
|
||||
{
|
||||
static constexpr std::size_t padding_space = 1;
|
||||
static constexpr std::size_t checkbox_space = 4;
|
||||
std::size_t line_width = padding_space; // leading space
|
||||
std::size_t column_idx{0};
|
||||
std::size_t entries = std::size_t(item->column_list.size());
|
||||
|
@ -2109,7 +2050,7 @@ void FListView::recalculateVerticalBar (std::size_t element_count)
|
|||
void FListView::mouseHeaderClicked()
|
||||
{
|
||||
int column{1};
|
||||
int checkbox_offset = ( hasCheckableItems() ) ? 4 : 0;
|
||||
int checkbox_offset = ( hasCheckableItems() ) ? checkbox_space : 0;
|
||||
int header_start = 2 + checkbox_offset;
|
||||
int header_pos = clicked_header_pos.getX() + xoffset;
|
||||
|
||||
|
@ -2287,7 +2228,7 @@ void FListView::stopDragScroll()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FObject::FObjectIterator FListView::appendItem (FListViewItem* item)
|
||||
FObject::iterator FListView::appendItem (FListViewItem* item)
|
||||
{
|
||||
item->root = root;
|
||||
addChild (item);
|
||||
|
@ -2323,7 +2264,7 @@ inline void FListView::toggleCheckbox()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListView::collapseAndScrollLeft (int& first_line_position_before)
|
||||
inline void FListView::collapseAndScrollLeft()
|
||||
{
|
||||
if ( itemlist.empty() )
|
||||
return;
|
||||
|
@ -2380,7 +2321,7 @@ inline void FListView::collapseAndScrollLeft (int& first_line_position_before)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListView::expandAndScrollRight (int& first_line_position_before)
|
||||
inline void FListView::expandAndScrollRight()
|
||||
{
|
||||
if ( itemlist.empty() )
|
||||
return;
|
||||
|
@ -2650,9 +2591,9 @@ void FListView::scrollBy (int dx, int dy)
|
|||
void FListView::cb_VBarChange (FWidget*, FDataPtr)
|
||||
{
|
||||
FScrollbar::sType scrollType = vbar->getScrollType();
|
||||
int distance{1}
|
||||
, pagesize{4}
|
||||
, first_line_position_before = first_visible_line.getPosition();
|
||||
int distance{1};
|
||||
int pagesize{4};
|
||||
first_line_position_before = first_visible_line.getPosition();
|
||||
|
||||
switch ( scrollType )
|
||||
{
|
||||
|
@ -2701,7 +2642,7 @@ void FListView::cb_VBarChange (FWidget*, FDataPtr)
|
|||
vbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2753,7 +2694,7 @@ void FListView::cb_HBarChange (FWidget*, FDataPtr)
|
|||
drawHeadlines();
|
||||
drawList();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward )
|
||||
|
@ -2764,7 +2705,7 @@ void FListView::cb_HBarChange (FWidget*, FDataPtr)
|
|||
hbar->drawBar();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ void FMenu::hide()
|
|||
const auto& t_geometry = getTermGeometryWithShadow();
|
||||
restoreVTerm (t_geometry);
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
|
||||
if ( ! isSubMenu() )
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
|
|||
getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -313,7 +313,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
|||
{
|
||||
closeOpenedSubMenu();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -584,7 +584,7 @@ void FMenu::openSubMenu (FMenu* sub_menu, bool select)
|
|||
getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -696,7 +696,7 @@ void FMenu::mouseDownSubmenu (FMenuItem* m_item)
|
|||
getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -764,7 +764,7 @@ bool FMenu::mouseUpOverList (FPoint mouse_pos)
|
|||
getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1038,7 +1038,7 @@ bool FMenu::selectNextItem()
|
|||
|
||||
redraw();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1088,7 +1088,7 @@ bool FMenu::selectPrevItem()
|
|||
|
||||
redraw();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1151,7 +1151,7 @@ bool FMenu::hotkeyMenu (FKeyEvent* ev)
|
|||
hide();
|
||||
hideSuperMenus();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
ev->accept();
|
||||
item->processClicked();
|
||||
}
|
||||
|
@ -1178,7 +1178,7 @@ void FMenu::draw()
|
|||
clearArea();
|
||||
drawBorder();
|
||||
drawItems();
|
||||
drawShadow();
|
||||
drawShadow(this);
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
@ -1236,8 +1236,6 @@ inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
|
|||
{
|
||||
FString txt(m_item->getText());
|
||||
menuText txtdata{};
|
||||
std::size_t txt_length = txt.getLength();
|
||||
std::size_t to_char = txt_length;
|
||||
std::size_t column_width = getColumnWidth(txt);
|
||||
FKey accel_key = m_item->accel_key;
|
||||
bool is_enabled = m_item->isEnabled();
|
||||
|
@ -1252,25 +1250,11 @@ inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
|
|||
// Print leading blank space
|
||||
print (' ');
|
||||
|
||||
try
|
||||
{
|
||||
txtdata.text = new wchar_t[txt_length + 1]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
hotkeypos = finalcut::getHotkeyPos(txt.wc_str(), txtdata.text, txt_length);
|
||||
hotkeypos = finalcut::getHotkeyPos(txt, txtdata.text);
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
{
|
||||
to_char--;
|
||||
column_width--;
|
||||
}
|
||||
|
||||
txtdata.length = to_char;
|
||||
txtdata.no_underline = m_item->getFlags().no_underline;
|
||||
setCursorToHotkeyPosition (m_item);
|
||||
|
||||
|
@ -1292,8 +1276,6 @@ inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
|
|||
|
||||
if ( isMonochron() && is_enabled && is_selected )
|
||||
setReverse(true);
|
||||
|
||||
delete[] txtdata.text;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1347,13 +1329,13 @@ 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.text.getLength(); z++)
|
||||
{
|
||||
if ( ! std::iswprint(std::wint_t(data.text[z])) )
|
||||
{
|
||||
if ( ! isNewFont()
|
||||
&& ( int(data.text[z]) < fc::NF_rev_left_arrow2
|
||||
|| int(data.text[z]) > fc::NF_check_mark )
|
||||
&& ( data.text[z] < fc::NF_rev_left_arrow2
|
||||
|| data.text[z] > fc::NF_check_mark )
|
||||
&& ! charEncodable(wchar_t(data.text[z])) )
|
||||
{
|
||||
data.text[z] = L' ';
|
||||
|
@ -1512,7 +1494,7 @@ inline void FMenu::selectPrevMenu (FKeyEvent* ev)
|
|||
getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
else
|
||||
keypressMenuBar(ev); // select previous menu
|
||||
|
@ -1585,7 +1567,7 @@ inline void FMenu::closeMenu()
|
|||
getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -64,15 +64,13 @@ 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();
|
||||
char* blank = createBlankArray (screenWidth + 1);
|
||||
print() << FPoint(1, 1) << blank;
|
||||
destroyBlankArray (blank);
|
||||
print() << FPoint(1, 1) << FString(getDesktopWidth(), L' ');
|
||||
updateTerminal();
|
||||
FWindow::hide();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -482,14 +480,13 @@ void FMenuBar::drawItems()
|
|||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
screenWidth = getDesktopWidth();
|
||||
std::size_t x{1};
|
||||
|
||||
for (auto&& item : list)
|
||||
drawItem (item, x);
|
||||
|
||||
// Print spaces to end of line
|
||||
for (; x <= screenWidth; x++)
|
||||
for (; x <= getDesktopWidth(); x++)
|
||||
print (' ');
|
||||
|
||||
if ( isMonochron() )
|
||||
|
@ -503,8 +500,6 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
|
|||
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();
|
||||
|
@ -513,33 +508,14 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
|
|||
setLineAttributes (menuitem);
|
||||
drawLeadingSpace (x);
|
||||
|
||||
try
|
||||
{
|
||||
txtdata.text = new wchar_t[txt_length + 1]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
if ( x - 1 > screenWidth )
|
||||
txt = txt.left(getColumnWidth(txt) - screenWidth - x - 1);
|
||||
|
||||
if ( x - 1 <= screenWidth )
|
||||
to_char = txt_length;
|
||||
else
|
||||
to_char = txt_length - screenWidth - x - 1;
|
||||
|
||||
std::size_t hotkeypos = finalcut::getHotkeyPos ( txt.wc_str()
|
||||
, txtdata.text
|
||||
, txt_length );
|
||||
std::size_t hotkeypos = finalcut::getHotkeyPos(txt, txtdata.text);
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
{
|
||||
txt_length--;
|
||||
column_width--;
|
||||
to_char--;
|
||||
}
|
||||
|
||||
txtdata.length = to_char;
|
||||
x += column_width;
|
||||
|
||||
if ( ! is_enabled || is_selected )
|
||||
|
@ -557,8 +533,6 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
|
|||
|
||||
if ( isMonochron() && is_enabled && is_selected )
|
||||
setReverse(true);
|
||||
|
||||
delete[] txtdata.text;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -617,7 +591,7 @@ 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.text.getLength(); z++)
|
||||
{
|
||||
if ( data.startpos > screenWidth - z )
|
||||
break;
|
||||
|
@ -625,8 +599,8 @@ inline void FMenuBar::drawMenuText (menuText& data)
|
|||
if ( ! std::iswprint(std::wint_t(data.text[z])) )
|
||||
{
|
||||
if ( ! isNewFont()
|
||||
&& ( int(data.text[z]) < fc::NF_rev_left_arrow2
|
||||
|| int(data.text[z]) > fc::NF_check_mark ) )
|
||||
&& ( data.text[z] < fc::NF_rev_left_arrow2
|
||||
|| data.text[z] > fc::NF_check_mark ) )
|
||||
{
|
||||
data.text[z] = L' ';
|
||||
}
|
||||
|
@ -997,7 +971,7 @@ void FMenuBar::leaveMenuBar()
|
|||
getStatusBar()->drawMessage();
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
mouse_down = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ void FMenuItem::setText (const FString& txt)
|
|||
void FMenuItem::addAccelerator (FKey key, FWidget* obj)
|
||||
{
|
||||
auto root = getRootWidget();
|
||||
accelerator accel = { key, obj };
|
||||
FAccelerator accel = { key, obj };
|
||||
|
||||
if ( root && root->getAcceleratorList() )
|
||||
{
|
||||
|
@ -270,7 +270,7 @@ void FMenuItem::openMenu()
|
|||
dd_menu->raiseWindow();
|
||||
dd_menu->redraw();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -567,7 +567,7 @@ void FMenuItem::init (FWidget* parent)
|
|||
addCallback // for this element
|
||||
(
|
||||
"deactivate",
|
||||
F_METHOD_CALLBACK (parent, &FMenuBar::cb_item_deactivated)
|
||||
F_METHOD_CALLBACK (menubar_ptr, &FMenuBar::cb_item_deactivated)
|
||||
);
|
||||
}
|
||||
else if ( isMenu(parent) ) // Parent is menu
|
||||
|
|
|
@ -53,7 +53,7 @@ FMouse::FMouse()
|
|||
|
||||
// public methods of FMouse
|
||||
//----------------------------------------------------------------------
|
||||
const char* FMouse::getClassName() const
|
||||
const FString FMouse::getClassName() const
|
||||
{
|
||||
return "FMouse";
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ void FMouse::clearButtonState()
|
|||
|
||||
// protected methods of FMouse
|
||||
//----------------------------------------------------------------------
|
||||
inline FMouse::button& FMouse::getButtonState()
|
||||
inline FMouse::FMouseButton& FMouse::getButtonState()
|
||||
{
|
||||
return b_state;
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ FMouseGPM::~FMouseGPM() // destructor
|
|||
|
||||
// public methods of FMouseX11
|
||||
//----------------------------------------------------------------------
|
||||
const char* FMouseGPM::getClassName() const
|
||||
const FString FMouseGPM::getClassName() const
|
||||
{
|
||||
return "FMouseGPM";
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ int FMouseGPM::gpmEvent (bool clear)
|
|||
|
||||
// public methods of FMouseX11
|
||||
//----------------------------------------------------------------------
|
||||
const char* FMouseX11::getClassName() const
|
||||
const FString FMouseX11::getClassName() const
|
||||
{
|
||||
return "FMouseX11";
|
||||
}
|
||||
|
@ -733,7 +733,7 @@ void FMouseX11::setButtonState (int btn, struct timeval* time)
|
|||
|
||||
// public methods of FMouseSGR
|
||||
//----------------------------------------------------------------------
|
||||
const char* FMouseSGR::getClassName() const
|
||||
const FString FMouseSGR::getClassName() const
|
||||
{
|
||||
return "FMouseSGR";
|
||||
}
|
||||
|
@ -962,7 +962,7 @@ void FMouseSGR::setReleasedButtonState (int btn)
|
|||
|
||||
// public methods of FMouseUrxvt
|
||||
//----------------------------------------------------------------------
|
||||
const char* FMouseUrxvt::getClassName() const
|
||||
const FString FMouseUrxvt::getClassName() const
|
||||
{
|
||||
return "FMouseUrxvt";
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace finalcut
|
|||
|
||||
// static class attributes
|
||||
bool FObject::timer_modify_lock;
|
||||
FObject::TimerList* FObject::timer_list{nullptr};
|
||||
FObject::FTimerList* FObject::timer_list{nullptr};
|
||||
const FString* fc::emptyFString::empty_string{nullptr};
|
||||
|
||||
|
||||
|
@ -58,7 +58,7 @@ FObject::FObject (FObject* parent)
|
|||
{
|
||||
try
|
||||
{
|
||||
timer_list = new TimerList;
|
||||
timer_list = new FTimerList;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
|
@ -281,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 };
|
||||
FTimerData t{ id, time_interval, timeout, this };
|
||||
|
||||
// insert in list sorted by timeout
|
||||
auto iter = timer_list->begin();
|
||||
|
|
|
@ -450,7 +450,7 @@ void FOptiAttr::set_orig_orig_colors (char cap[])
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FOptiAttr::isNormal (charData*& ch)
|
||||
bool FOptiAttr::isNormal (FChar*& ch)
|
||||
{
|
||||
return hasNoAttribute(ch) && ! hasColor(ch);
|
||||
}
|
||||
|
@ -542,7 +542,7 @@ FColor FOptiAttr::vga2ansi (FColor color)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
char* FOptiAttr::changeAttribute (charData*& term, charData*& next)
|
||||
char* FOptiAttr::changeAttribute (FChar*& term, FChar*& next)
|
||||
{
|
||||
const bool next_has_color = hasColor(next);
|
||||
fake_reverse = false;
|
||||
|
@ -558,7 +558,7 @@ char* FOptiAttr::changeAttribute (charData*& term, charData*& next)
|
|||
|
||||
// Simulate invisible characters
|
||||
if ( ! F_enter_secure_mode.cap && next->attr.bit.invisible )
|
||||
next->encoded_code = ' ';
|
||||
next->encoded_char = ' ';
|
||||
|
||||
// Look for no changes
|
||||
if ( ! (switchOn() || switchOff() || hasColorChanged(term, next)) )
|
||||
|
@ -584,7 +584,7 @@ char* FOptiAttr::changeAttribute (charData*& term, charData*& next)
|
|||
|
||||
// private methods of FOptiAttr
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermBold (charData*& term)
|
||||
inline bool FOptiAttr::setTermBold (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -598,7 +598,7 @@ inline bool FOptiAttr::setTermBold (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermBold (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermBold (FChar*& term)
|
||||
{
|
||||
// Back to normal intensity (turns off bold + dim)
|
||||
|
||||
|
@ -620,7 +620,7 @@ inline bool FOptiAttr::unsetTermBold (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermDim (charData*& term)
|
||||
inline bool FOptiAttr::setTermDim (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -634,7 +634,7 @@ inline bool FOptiAttr::setTermDim (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermDim (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermDim (FChar*& term)
|
||||
{
|
||||
// Back to normal intensity (turns off bold + dim)
|
||||
|
||||
|
@ -656,7 +656,7 @@ inline bool FOptiAttr::unsetTermDim (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermItalic (charData*& term)
|
||||
inline bool FOptiAttr::setTermItalic (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -670,7 +670,7 @@ inline bool FOptiAttr::setTermItalic (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermItalic (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermItalic (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -687,7 +687,7 @@ inline bool FOptiAttr::unsetTermItalic (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermUnderline (charData*& term)
|
||||
inline bool FOptiAttr::setTermUnderline (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -701,7 +701,7 @@ inline bool FOptiAttr::setTermUnderline (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermUnderline (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermUnderline (FChar*& term)
|
||||
{
|
||||
// Turns off every underlining
|
||||
|
||||
|
@ -723,7 +723,7 @@ inline bool FOptiAttr::unsetTermUnderline (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermBlink (charData*& term)
|
||||
inline bool FOptiAttr::setTermBlink (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -737,7 +737,7 @@ inline bool FOptiAttr::setTermBlink (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermBlink (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermBlink (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -754,7 +754,7 @@ inline bool FOptiAttr::unsetTermBlink (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermReverse (charData*& term)
|
||||
inline bool FOptiAttr::setTermReverse (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -768,7 +768,7 @@ inline bool FOptiAttr::setTermReverse (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermReverse (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermReverse (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -785,7 +785,7 @@ inline bool FOptiAttr::unsetTermReverse (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermStandout (charData*& term)
|
||||
inline bool FOptiAttr::setTermStandout (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -799,7 +799,7 @@ inline bool FOptiAttr::setTermStandout (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermStandout (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermStandout (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -816,7 +816,7 @@ inline bool FOptiAttr::unsetTermStandout (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermInvisible (charData*& term)
|
||||
inline bool FOptiAttr::setTermInvisible (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -830,7 +830,7 @@ inline bool FOptiAttr::setTermInvisible (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermInvisible (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermInvisible (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -847,7 +847,7 @@ inline bool FOptiAttr::unsetTermInvisible (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermProtected (charData*& term)
|
||||
inline bool FOptiAttr::setTermProtected (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -861,7 +861,7 @@ inline bool FOptiAttr::setTermProtected (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermProtected (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermProtected (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -878,7 +878,7 @@ inline bool FOptiAttr::unsetTermProtected (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermCrossedOut (charData*& term)
|
||||
inline bool FOptiAttr::setTermCrossedOut (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -892,7 +892,7 @@ inline bool FOptiAttr::setTermCrossedOut (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermCrossedOut (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermCrossedOut (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -909,7 +909,7 @@ inline bool FOptiAttr::unsetTermCrossedOut (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermDoubleUnderline (charData*& term)
|
||||
inline bool FOptiAttr::setTermDoubleUnderline (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -923,7 +923,7 @@ inline bool FOptiAttr::setTermDoubleUnderline (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermDoubleUnderline (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermDoubleUnderline (FChar*& term)
|
||||
{
|
||||
// Turns off every underlining
|
||||
|
||||
|
@ -945,7 +945,7 @@ inline bool FOptiAttr::unsetTermDoubleUnderline (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FOptiAttr::setTermAttributes ( charData*& term
|
||||
bool FOptiAttr::setTermAttributes ( FChar*& term
|
||||
, bool p1, bool p2, bool p3
|
||||
, bool p4, bool p5, bool p6
|
||||
, bool p7, bool p8, bool p9 )
|
||||
|
@ -985,7 +985,7 @@ bool FOptiAttr::setTermAttributes ( charData*& term
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermAttributes (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermAttributes (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -999,7 +999,7 @@ inline bool FOptiAttr::unsetTermAttributes (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermAltCharset (charData*& term)
|
||||
inline bool FOptiAttr::setTermAltCharset (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -1016,7 +1016,7 @@ inline bool FOptiAttr::setTermAltCharset (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermAltCharset (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermAltCharset (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -1033,7 +1033,7 @@ inline bool FOptiAttr::unsetTermAltCharset (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::setTermPCcharset (charData*& term)
|
||||
inline bool FOptiAttr::setTermPCcharset (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -1050,7 +1050,7 @@ inline bool FOptiAttr::setTermPCcharset (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::unsetTermPCcharset (charData*& term)
|
||||
inline bool FOptiAttr::unsetTermPCcharset (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -1067,7 +1067,7 @@ inline bool FOptiAttr::unsetTermPCcharset (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FOptiAttr::setTermDefaultColor (charData*& term)
|
||||
bool FOptiAttr::setTermDefaultColor (FChar*& term)
|
||||
{
|
||||
if ( ! term )
|
||||
return false;
|
||||
|
@ -1090,7 +1090,7 @@ bool FOptiAttr::setTermDefaultColor (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FOptiAttr::setAttributesOn (charData*& term)
|
||||
void FOptiAttr::setAttributesOn (FChar*& term)
|
||||
{
|
||||
if ( on.attr.bit.alt_charset )
|
||||
setTermAltCharset(term);
|
||||
|
@ -1133,7 +1133,7 @@ void FOptiAttr::setAttributesOn (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FOptiAttr::setAttributesOff (charData*& term)
|
||||
void FOptiAttr::setAttributesOff (FChar*& term)
|
||||
{
|
||||
if ( off.attr.bit.pc_charset )
|
||||
unsetTermPCcharset(term);
|
||||
|
@ -1176,7 +1176,7 @@ void FOptiAttr::setAttributesOff (charData*& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FOptiAttr::hasColor (charData*& attr)
|
||||
bool FOptiAttr::hasColor (FChar*& attr)
|
||||
{
|
||||
if ( attr
|
||||
&& attr->fg_color == fc::Default
|
||||
|
@ -1187,7 +1187,7 @@ bool FOptiAttr::hasColor (charData*& attr)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FOptiAttr::hasAttribute (charData*& attr)
|
||||
bool FOptiAttr::hasAttribute (FChar*& attr)
|
||||
{
|
||||
if ( attr )
|
||||
{
|
||||
|
@ -1210,13 +1210,13 @@ bool FOptiAttr::hasAttribute (charData*& attr)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FOptiAttr::hasNoAttribute (charData*& attr)
|
||||
bool FOptiAttr::hasNoAttribute (FChar*& attr)
|
||||
{
|
||||
return ! hasAttribute(attr);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiAttr::hasColorChanged (charData*& term, charData*& next)
|
||||
inline bool FOptiAttr::hasColorChanged (FChar*& term, FChar*& next)
|
||||
{
|
||||
if ( term && next )
|
||||
{
|
||||
|
@ -1233,7 +1233,7 @@ inline bool FOptiAttr::hasColorChanged (charData*& term, charData*& next)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::resetColor (charData*& attr)
|
||||
inline void FOptiAttr::resetColor (FChar*& attr)
|
||||
{
|
||||
if ( attr )
|
||||
{
|
||||
|
@ -1243,7 +1243,7 @@ inline void FOptiAttr::resetColor (charData*& attr)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::prevent_no_color_video_attributes ( charData*& attr
|
||||
inline void FOptiAttr::prevent_no_color_video_attributes ( FChar*& attr
|
||||
, bool next_has_color )
|
||||
{
|
||||
// Ignore attributes which can not combined with a color
|
||||
|
@ -1304,8 +1304,8 @@ inline void FOptiAttr::prevent_no_color_video_attributes ( charData*& attr
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::deactivateAttributes ( charData*& term
|
||||
, charData*& next )
|
||||
inline void FOptiAttr::deactivateAttributes ( FChar*& term
|
||||
, FChar*& next )
|
||||
{
|
||||
if ( hasAttribute(term) )
|
||||
{
|
||||
|
@ -1328,8 +1328,8 @@ inline void FOptiAttr::deactivateAttributes ( charData*& term
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::changeAttributeSGR ( charData*& term
|
||||
, charData*& next )
|
||||
inline void FOptiAttr::changeAttributeSGR ( FChar*& term
|
||||
, FChar*& next )
|
||||
{
|
||||
bool pc_charset_usable{true};
|
||||
|
||||
|
@ -1378,8 +1378,8 @@ inline void FOptiAttr::changeAttributeSGR ( charData*& term
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::changeAttributeSeparately ( charData*& term
|
||||
, charData*& next )
|
||||
inline void FOptiAttr::changeAttributeSeparately ( FChar*& term
|
||||
, FChar*& next )
|
||||
{
|
||||
setAttributesOff(term);
|
||||
|
||||
|
@ -1391,7 +1391,7 @@ inline void FOptiAttr::changeAttributeSeparately ( charData*& term
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FOptiAttr::change_color (charData*& term, charData*& next)
|
||||
void FOptiAttr::change_color (FChar*& term, FChar*& next)
|
||||
{
|
||||
if ( ! (term && next) )
|
||||
return;
|
||||
|
@ -1434,8 +1434,8 @@ void FOptiAttr::change_color (charData*& term, charData*& next)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::change_to_default_color ( charData*& term
|
||||
, charData*& next
|
||||
inline void FOptiAttr::change_to_default_color ( FChar*& term
|
||||
, FChar*& next
|
||||
, FColor& fg, FColor& bg )
|
||||
{
|
||||
if ( ansi_default_color )
|
||||
|
@ -1474,7 +1474,7 @@ inline void FOptiAttr::change_to_default_color ( charData*& term
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::change_current_color ( charData*& term
|
||||
inline void FOptiAttr::change_current_color ( FChar*& term
|
||||
, FColor fg, FColor bg )
|
||||
{
|
||||
char* color_str{};
|
||||
|
@ -1522,7 +1522,7 @@ inline void FOptiAttr::change_current_color ( charData*& term
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::resetAttribute (charData*& attr)
|
||||
inline void FOptiAttr::resetAttribute (FChar*& attr)
|
||||
{
|
||||
if ( attr )
|
||||
{
|
||||
|
@ -1532,7 +1532,7 @@ inline void FOptiAttr::resetAttribute (charData*& attr)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::reset (charData*& attr)
|
||||
inline void FOptiAttr::reset (FChar*& attr)
|
||||
{
|
||||
if ( attr )
|
||||
{
|
||||
|
@ -1593,7 +1593,7 @@ inline bool FOptiAttr::hasCharsetEquivalence()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::detectSwitchOn (charData*& term, charData*& next)
|
||||
inline void FOptiAttr::detectSwitchOn (FChar*& term, FChar*& next)
|
||||
{
|
||||
if ( ! (term && next) )
|
||||
return;
|
||||
|
@ -1614,7 +1614,7 @@ inline void FOptiAttr::detectSwitchOn (charData*& term, charData*& next)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::detectSwitchOff (charData*& term, charData*& next)
|
||||
inline void FOptiAttr::detectSwitchOff (FChar*& term, FChar*& next)
|
||||
{
|
||||
if ( ! (term && next) )
|
||||
return;
|
||||
|
|
|
@ -101,7 +101,7 @@ std::ostream& operator << (std::ostream& outstr, const FPoint& p)
|
|||
//----------------------------------------------------------------------
|
||||
std::istream& operator >> (std::istream& instr, FPoint& p)
|
||||
{
|
||||
int x, y;
|
||||
int x{}, y{};
|
||||
instr >> x;
|
||||
instr >> y;
|
||||
p.setPoint (x, y);
|
||||
|
|
|
@ -131,9 +131,9 @@ void FProgressbar::draw()
|
|||
drawProgressBar();
|
||||
|
||||
if ( getFlags().shadow )
|
||||
drawShadow ();
|
||||
drawShadow(this);
|
||||
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -179,7 +179,7 @@ void FProgressbar::drawProgressBar()
|
|||
setReverse(false);
|
||||
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -69,7 +69,7 @@ void FRadioMenuItem::init (FWidget* parent)
|
|||
addCallback // for this element
|
||||
(
|
||||
"toggled",
|
||||
F_METHOD_CALLBACK (parent, &FMenu::cb_menuitem_toggled)
|
||||
F_METHOD_CALLBACK (menu_ptr, &FMenu::cb_menuitem_toggled)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ std::ostream& operator << (std::ostream& outstr, const FRect& r)
|
|||
//----------------------------------------------------------------------
|
||||
std::istream& operator >> (std::istream& instr, FRect& r)
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
int x1{}, y1{}, x2{}, y2{};
|
||||
instr >> x1;
|
||||
instr >> y1;
|
||||
instr >> x2;
|
||||
|
|
|
@ -346,7 +346,7 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
|
|||
|
||||
if ( scroll_type == FScrollbar::scrollJump )
|
||||
{
|
||||
int new_val;
|
||||
int new_val{};
|
||||
|
||||
if ( bar_orientation == fc::vertical )
|
||||
{
|
||||
|
|
|
@ -464,52 +464,12 @@ void FScrollView::drawBorder()
|
|||
//----------------------------------------------------------------------
|
||||
void FScrollView::onKeyPress (FKeyEvent* ev)
|
||||
{
|
||||
int yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||
int idx = int(ev->key());
|
||||
|
||||
switch ( ev->key() )
|
||||
if ( key_map.find(idx) != key_map.end() )
|
||||
{
|
||||
case fc::Fkey_up:
|
||||
scrollBy (0, -1);
|
||||
key_map[idx]();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_down:
|
||||
scrollBy (0, 1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_left:
|
||||
scrollBy (-1, 0);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
scrollBy (1, 0);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_ppage:
|
||||
scrollBy (0, int(-getViewportHeight()));
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_npage:
|
||||
scrollBy (0, int(getViewportHeight()));
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_home:
|
||||
scrollToY (1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_end:
|
||||
scrollToY (1 + yoffset_end);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -629,7 +589,7 @@ void FScrollView::onChildFocusOut (FFocusEvent* out_ev)
|
|||
|
||||
// protected methods of FScrollView
|
||||
//----------------------------------------------------------------------
|
||||
FVTerm::term_area* FScrollView::getPrintArea()
|
||||
FVTerm::FTermArea* FScrollView::getPrintArea()
|
||||
{
|
||||
// returns print area or viewport
|
||||
|
||||
|
@ -715,13 +675,13 @@ void FScrollView::copy2area()
|
|||
|
||||
for (int y{0}; y < y_end; y++) // line loop
|
||||
{
|
||||
charData* vc{}; // viewport character
|
||||
charData* ac{}; // area character
|
||||
FChar* vc{}; // viewport character
|
||||
FChar* ac{}; // area character
|
||||
int v_line_len = viewport->width;
|
||||
int a_line_len = printarea->width + printarea->right_shadow;
|
||||
vc = &viewport->text[(dy + y) * v_line_len + dx];
|
||||
ac = &printarea->text[(ay + y) * a_line_len + ax];
|
||||
std::memcpy (ac, vc, sizeof(charData) * unsigned(x_end));
|
||||
vc = &viewport->data[(dy + y) * v_line_len + dx];
|
||||
ac = &printarea->data[(ay + y) * a_line_len + ax];
|
||||
std::memcpy (ac, vc, sizeof(FChar) * unsigned(x_end));
|
||||
|
||||
if ( int(printarea->changes[ay + y].xmin) > ax )
|
||||
printarea->changes[ay + y].xmin = uInt(ax);
|
||||
|
@ -764,6 +724,7 @@ void FScrollView::init (FWidget* parent)
|
|||
|
||||
initScrollbar (vbar, fc::vertical, &FScrollView::cb_VBarChange);
|
||||
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_HBarChange);
|
||||
mapKeyFunctions();
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
|
@ -798,31 +759,21 @@ void FScrollView::init (FWidget* parent)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::initScrollbar ( FScrollbarPtr& bar
|
||||
, fc::orientation o
|
||||
, FScrollViewCallback callback )
|
||||
inline void FScrollView::mapKeyFunctions()
|
||||
{
|
||||
try
|
||||
key_map[fc::Fkey_up] = [&] { scrollBy (0, -1); };
|
||||
key_map[fc::Fkey_down] = [&] { scrollBy (0, 1); };
|
||||
key_map[fc::Fkey_left] = [&] { scrollBy (-1, 0); };
|
||||
key_map[fc::Fkey_right] = [&] { scrollBy (1, 0); };
|
||||
key_map[fc::Fkey_ppage] = [&] { scrollBy (0, int(-getViewportHeight())); };
|
||||
key_map[fc::Fkey_npage] = [&] { scrollBy (0, int(getViewportHeight())); };
|
||||
key_map[fc::Fkey_home] = [&] { scrollToY (1); };
|
||||
key_map[fc::Fkey_end] = \
|
||||
[&] ()
|
||||
{
|
||||
bar = std::make_shared<FScrollbar>(o, this);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
term_area* area = getPrintArea();
|
||||
bar->setPrintArea(area);
|
||||
bar->setMinimum(0);
|
||||
bar->setValue(0);
|
||||
bar->hide();
|
||||
|
||||
bar->addCallback
|
||||
(
|
||||
"change-value",
|
||||
F_METHOD_CALLBACK (this, callback)
|
||||
);
|
||||
int yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||
scrollToY (1 + yoffset_end);
|
||||
};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -52,10 +52,7 @@ FStartOptions::FStartOptions()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
FStartOptions::~FStartOptions() // destructor
|
||||
{
|
||||
if ( start_options )
|
||||
delete start_options;
|
||||
}
|
||||
{ }
|
||||
|
||||
// public methods of FStartOptions
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -77,6 +74,13 @@ FStartOptions& FStartOptions::getFStartOptions()
|
|||
return *start_options;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FStartOptions::destroyObject()
|
||||
{
|
||||
if ( start_options )
|
||||
delete start_options;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FStartOptions::setDefault()
|
||||
{
|
||||
|
|
|
@ -174,15 +174,13 @@ 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();
|
||||
char* blank = createBlankArray(screenWidth + 1);
|
||||
print() << FPoint(1, 1) << blank;
|
||||
destroyBlankArray (blank);
|
||||
print() << FPoint(1, 1) << FString(getDesktopWidth(), L' ');
|
||||
updateTerminal();
|
||||
FWindow::hide();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -408,10 +406,9 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
|
|||
|
||||
if ( (*iter)->hasMouseFocus() )
|
||||
{
|
||||
int mouse_x, mouse_y;
|
||||
(*iter)->unsetMouseFocus();
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 )
|
||||
(*iter)->setActive();
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
wchar_t FString::null_char{L'\0'};
|
||||
const wchar_t FString::const_null_char{L'\0'};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FString
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -843,7 +847,7 @@ FString& FString::setString (const FString& s)
|
|||
FString& FString::setNumber (sInt64 num)
|
||||
{
|
||||
bool neg{false};
|
||||
wchar_t buf[30];
|
||||
wchar_t buf[30]{};
|
||||
wchar_t* s = &buf[29];
|
||||
|
||||
if ( num < 0 )
|
||||
|
@ -875,7 +879,7 @@ FString& FString::setNumber (sInt64 num)
|
|||
//----------------------------------------------------------------------
|
||||
FString& FString::setNumber (uInt64 num)
|
||||
{
|
||||
wchar_t buf[30];
|
||||
wchar_t buf[30]{};
|
||||
wchar_t* s = &buf[29];
|
||||
*s = '\0';
|
||||
|
||||
|
@ -893,7 +897,7 @@ FString& FString::setNumber (uInt64 num)
|
|||
//----------------------------------------------------------------------
|
||||
FString& FString::setNumber (lDouble f_num, int precision)
|
||||
{
|
||||
wchar_t format[20]; // = "%.<precision>Lg"
|
||||
wchar_t format[20]{}; // = "%.<precision>Lg"
|
||||
wchar_t* s = &format[0];
|
||||
*s++ = L'%';
|
||||
*s++ = L'.';
|
||||
|
@ -926,7 +930,7 @@ FString& FString::setFormatedNumber (sInt64 num, char separator)
|
|||
{
|
||||
bool neg{false};
|
||||
int n{0};
|
||||
wchar_t buf[30];
|
||||
wchar_t buf[30]{};
|
||||
wchar_t* s = &buf[29];
|
||||
|
||||
if ( separator == 0 )
|
||||
|
@ -965,7 +969,7 @@ FString& FString::setFormatedNumber (sInt64 num, char separator)
|
|||
FString& FString::setFormatedNumber (uInt64 num, char separator)
|
||||
{
|
||||
int n{0};
|
||||
wchar_t buf[30];
|
||||
wchar_t buf[30]{};
|
||||
wchar_t* s = &buf[29];
|
||||
*s = L'\0';
|
||||
|
||||
|
@ -1710,8 +1714,17 @@ const FString operator + (const FString& s, const char c)
|
|||
//----------------------------------------------------------------------
|
||||
std::ostream& operator << (std::ostream& outstr, const FString& s)
|
||||
{
|
||||
const std::size_t width = std::size_t(outstr.width());
|
||||
|
||||
if ( s.length > 0 )
|
||||
{
|
||||
outstr << s.wc_to_c_str(s.string);
|
||||
}
|
||||
else if ( width > 0 )
|
||||
{
|
||||
FString fill_str(width, outstr.fill());
|
||||
outstr << s.wc_to_c_str(fill_str.string);
|
||||
}
|
||||
|
||||
return outstr;
|
||||
}
|
||||
|
@ -1735,8 +1748,17 @@ std::istream& operator >> (std::istream& instr, FString& s)
|
|||
//----------------------------------------------------------------------
|
||||
std::wostream& operator << (std::wostream& outstr, const FString& s)
|
||||
{
|
||||
const std::size_t width = std::size_t(outstr.width());
|
||||
|
||||
if ( s.length > 0 )
|
||||
{
|
||||
outstr << s.string;
|
||||
}
|
||||
else if ( width > 0 )
|
||||
{
|
||||
FString fill_str(width, outstr.fill());
|
||||
outstr << fill_str.string;
|
||||
}
|
||||
|
||||
return outstr;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ void FSwitch::draw()
|
|||
drawCheckButton();
|
||||
FToggleButton::draw();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
#include "final/fconfig.h" // need for getpwuid_r and realpath
|
||||
#endif
|
||||
|
||||
#include "final/fsystemimpl.h"
|
||||
|
||||
namespace finalcut
|
||||
|
@ -38,5 +42,19 @@ FSystemImpl::FSystemImpl()
|
|||
FSystemImpl::~FSystemImpl() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FSystemImpl::getpwuid_r ( uid_t uid, struct passwd* pwd
|
||||
, char* buf, size_t buflen
|
||||
, struct passwd** result )
|
||||
{
|
||||
return ::getpwuid_r (uid, pwd, buf, buflen, result);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
char* FSystemImpl::realpath (const char* path, char* resolved_path)
|
||||
{
|
||||
return ::realpath(path, resolved_path);
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
|
365
src/fterm.cpp
365
src/fterm.cpp
|
@ -67,9 +67,6 @@ static FTerm* init_term_object{nullptr};
|
|||
// global init state
|
||||
static bool term_initialized{false};
|
||||
|
||||
// function pointer
|
||||
int (*FTerm::Fputchar)(int);
|
||||
|
||||
// static class attributes
|
||||
FTermData* FTerm::data {nullptr};
|
||||
FSystem* FTerm::fsys {nullptr};
|
||||
|
@ -96,8 +93,6 @@ FMouseControl* FTerm::mouse {nullptr};
|
|||
FTermDebugData* FTerm::debug_data {nullptr};
|
||||
#endif
|
||||
|
||||
// function prototypes
|
||||
uInt env2uint (const char*);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FTerm
|
||||
|
@ -419,7 +414,7 @@ FTermDebugData& FTerm::getFTermDebugData()
|
|||
#endif // DEBUG
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTerm::isNormal (charData*& ch)
|
||||
bool FTerm::isNormal (FChar*& ch)
|
||||
{
|
||||
return opti_attr->isNormal(ch);
|
||||
}
|
||||
|
@ -674,16 +669,16 @@ bool FTerm::setVGAFont()
|
|||
data->setTermEncoding (fc::PC);
|
||||
|
||||
if ( isXTerminal() && data->hasUTF8Console() )
|
||||
Fputchar = &FTerm::putchar_UTF8;
|
||||
putchar() = &FTerm::putchar_UTF8;
|
||||
else
|
||||
Fputchar = &FTerm::putchar_ASCII;
|
||||
putchar() = &FTerm::putchar_ASCII;
|
||||
}
|
||||
#if defined(__linux__)
|
||||
else if ( isLinuxTerm() )
|
||||
{
|
||||
data->setVGAFont(linux->loadVGAFont());
|
||||
data->setTermEncoding (fc::PC);
|
||||
Fputchar = &FTerm::putchar_ASCII;
|
||||
putchar() = &FTerm::putchar_ASCII;
|
||||
}
|
||||
#endif // defined(__linux__)
|
||||
else
|
||||
|
@ -716,16 +711,16 @@ bool FTerm::setNewFont()
|
|||
data->setTermEncoding (fc::PC);
|
||||
|
||||
if ( isXTerminal() && data->hasUTF8Console() )
|
||||
Fputchar = &FTerm::putchar_UTF8;
|
||||
putchar() = &FTerm::putchar_UTF8;
|
||||
else
|
||||
Fputchar = &FTerm::putchar_ASCII;
|
||||
putchar() = &FTerm::putchar_ASCII;
|
||||
}
|
||||
#if defined(__linux__)
|
||||
else if ( isLinuxTerm() )
|
||||
{
|
||||
data->setNewFont(linux->loadNewFont());
|
||||
data->setTermEncoding (fc::PC);
|
||||
Fputchar = &FTerm::putchar_ASCII; // function pointer
|
||||
putchar() = &FTerm::putchar_ASCII; // function pointer
|
||||
}
|
||||
#endif // defined(__linux__)
|
||||
else
|
||||
|
@ -835,7 +830,9 @@ int FTerm::closeConsole()
|
|||
if ( fd < 0 ) // console is already closed
|
||||
return 0;
|
||||
|
||||
if ( fsys )
|
||||
if ( ! fsys )
|
||||
getFSystem();
|
||||
|
||||
ret = fsys->close(fd); // close console
|
||||
|
||||
data->setTTYFileDescriptor(-1);
|
||||
|
@ -900,10 +897,10 @@ void FTerm::detectTermSize()
|
|||
|
||||
do
|
||||
{
|
||||
if ( fsys )
|
||||
if ( ! fsys )
|
||||
getFSystem();
|
||||
|
||||
ret = fsys->ioctl (FTermios::getStdOut(), TIOCGWINSZ, &win_size);
|
||||
else
|
||||
ret = -1;
|
||||
}
|
||||
while (errno == EINTR);
|
||||
|
||||
|
@ -992,12 +989,13 @@ void FTerm::setPalette (FColor index, int r, int g, int b)
|
|||
|
||||
const auto& Ic = TCAP(fc::t_initialize_color);
|
||||
const auto& Ip = TCAP(fc::t_initialize_pair);
|
||||
bool state{false};
|
||||
|
||||
index = FOptiAttr::vga2ansi(index);
|
||||
|
||||
if ( Ic || Ip )
|
||||
{
|
||||
const char* color_str = "";
|
||||
const char* color_str{};
|
||||
|
||||
int rr = (r * 1001) / 256
|
||||
, gg = (g * 1001) / 256
|
||||
|
@ -1008,15 +1006,20 @@ void FTerm::setPalette (FColor index, int r, int g, int b)
|
|||
else if ( Ip )
|
||||
color_str = tparm(Ip, index, 0, 0, 0, rr, gg, bb, 0, 0);
|
||||
|
||||
if ( color_str )
|
||||
{
|
||||
putstring (color_str);
|
||||
state = true;
|
||||
}
|
||||
}
|
||||
#if defined(__linux__)
|
||||
else
|
||||
{
|
||||
linux->setPalette(index, r, g, b);
|
||||
state = linux->setPalette(index, r, g, b);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( state )
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
||||
|
@ -1084,25 +1087,25 @@ void FTerm::setEncoding (fc::encoding enc)
|
|||
|| enc == fc::PC // CP-437
|
||||
|| enc == fc::ASCII );
|
||||
|
||||
// Set the new Fputchar function pointer
|
||||
// Set the new putchar() function pointer
|
||||
switch ( enc )
|
||||
{
|
||||
case fc::UTF8:
|
||||
Fputchar = &FTerm::putchar_UTF8;
|
||||
putchar() = &FTerm::putchar_UTF8;
|
||||
break;
|
||||
|
||||
case fc::VT100:
|
||||
case fc::PC:
|
||||
if ( isXTerminal() && data->hasUTF8Console() )
|
||||
Fputchar = &FTerm::putchar_UTF8;
|
||||
putchar() = &FTerm::putchar_UTF8;
|
||||
else
|
||||
Fputchar = &FTerm::putchar_ASCII;
|
||||
putchar() = &FTerm::putchar_ASCII;
|
||||
break;
|
||||
|
||||
case fc::ASCII:
|
||||
case fc::UNKNOWN:
|
||||
case fc::NUM_OF_ENCODINGS:
|
||||
Fputchar = &FTerm::putchar_ASCII;
|
||||
putchar() = &FTerm::putchar_ASCII;
|
||||
}
|
||||
|
||||
if ( isLinuxTerm() )
|
||||
|
@ -1196,15 +1199,28 @@ bool FTerm::scrollTermReverse()
|
|||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTerm::defaultPutChar& FTerm::putchar()
|
||||
{
|
||||
static defaultPutChar* fputchar = new defaultPutChar();
|
||||
return *fputchar;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::putstring (const char str[], int affcnt)
|
||||
{
|
||||
if ( ! fsys )
|
||||
getFSystem();
|
||||
|
||||
fsys->tputs (str, affcnt, FTerm::putchar_ASCII);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FTerm::putchar_ASCII (int c)
|
||||
{
|
||||
if ( ! fsys )
|
||||
getFSystem();
|
||||
|
||||
if ( fsys->putchar(char(c)) == EOF )
|
||||
return 0;
|
||||
else
|
||||
|
@ -1214,6 +1230,9 @@ int FTerm::putchar_ASCII (int c)
|
|||
//----------------------------------------------------------------------
|
||||
int FTerm::putchar_UTF8 (int c)
|
||||
{
|
||||
if ( ! fsys )
|
||||
getFSystem();
|
||||
|
||||
if ( c < 0x80 )
|
||||
{
|
||||
// 1 Byte (7-bit): 0xxxxxxx
|
||||
|
@ -1269,8 +1288,8 @@ void FTerm::initScreenSettings()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
char* FTerm::changeAttribute ( charData*& term_attr
|
||||
, charData*& next_attr )
|
||||
char* FTerm::changeAttribute ( FChar*& term_attr
|
||||
, FChar*& next_attr )
|
||||
{
|
||||
return opti_attr->changeAttribute (term_attr, next_attr);
|
||||
}
|
||||
|
@ -1708,7 +1727,7 @@ void FTerm::init_locale()
|
|||
//----------------------------------------------------------------------
|
||||
void FTerm::init_encoding()
|
||||
{
|
||||
// detect encoding and set the Fputchar function pointer
|
||||
// detect encoding and set the putchar() function pointer
|
||||
|
||||
bool force_vt100{false}; // VT100 line drawing (G1 character set)
|
||||
init_encoding_set();
|
||||
|
@ -1752,12 +1771,15 @@ void FTerm::init_term_encoding()
|
|||
int stdout_no = FTermios::getStdOut();
|
||||
const char* termtype = data->getTermType();
|
||||
|
||||
if ( ! fsys )
|
||||
getFSystem();
|
||||
|
||||
if ( fsys->isTTY(stdout_no)
|
||||
&& ! std::strcmp(nl_langinfo(CODESET), "UTF-8") )
|
||||
{
|
||||
data->setUTF8Console(true);
|
||||
data->setTermEncoding (fc::UTF8);
|
||||
Fputchar = &FTerm::putchar_UTF8; // function pointer
|
||||
putchar() = &FTerm::putchar_UTF8; // function pointer
|
||||
data->setUTF8(true);
|
||||
setUTF8(true);
|
||||
keyboard->enableUTF8();
|
||||
|
@ -1768,13 +1790,13 @@ void FTerm::init_term_encoding()
|
|||
{
|
||||
data->setVT100Console (true);
|
||||
data->setTermEncoding (fc::VT100);
|
||||
Fputchar = &FTerm::putchar_ASCII; // function pointer
|
||||
putchar() = &FTerm::putchar_ASCII; // function pointer
|
||||
}
|
||||
else
|
||||
{
|
||||
data->setASCIIConsole (true);
|
||||
data->setTermEncoding (fc::ASCII);
|
||||
Fputchar = &FTerm::putchar_ASCII; // function pointer
|
||||
putchar() = &FTerm::putchar_ASCII; // function pointer
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1786,12 +1808,12 @@ void FTerm::init_individual_term_encoding()
|
|||
|| (isTeraTerm() && ! data->isUTF8()) )
|
||||
{
|
||||
data->setTermEncoding (fc::PC);
|
||||
Fputchar = &FTerm::putchar_ASCII; // function pointer
|
||||
putchar() = &FTerm::putchar_ASCII; // function pointer
|
||||
|
||||
if ( hasUTF8() && getStartOptions().encoding == fc::UNKNOWN )
|
||||
{
|
||||
if ( isXTerminal() )
|
||||
Fputchar = &FTerm::putchar_UTF8; // function pointer
|
||||
putchar() = &FTerm::putchar_UTF8; // function pointer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1801,7 +1823,7 @@ void FTerm::init_force_vt100_encoding()
|
|||
{
|
||||
data->setVT100Console(true);
|
||||
data->setTermEncoding (fc::VT100);
|
||||
Fputchar = &FTerm::putchar_ASCII; // function pointer
|
||||
putchar() = &FTerm::putchar_ASCII; // function pointer
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1815,7 +1837,7 @@ void FTerm::init_utf8_without_alt_charset()
|
|||
{
|
||||
data->setASCIIConsole(true);
|
||||
data->setTermEncoding (fc::ASCII);
|
||||
Fputchar = &FTerm::putchar_ASCII; // function pointer
|
||||
putchar() = &FTerm::putchar_ASCII; // function pointer
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1841,14 +1863,14 @@ void FTerm::init_captureFontAndTitle()
|
|||
// Save the used xterm font and window title
|
||||
|
||||
xterm->captureFontAndTitle();
|
||||
const auto font = xterm->getFont();
|
||||
const auto title = xterm->getTitle();
|
||||
const auto& font = xterm->getFont();
|
||||
const auto& title = xterm->getTitle();
|
||||
|
||||
if ( font )
|
||||
data->setXtermFont(*font);
|
||||
if ( ! font.isEmpty() )
|
||||
data->setXtermFont(font);
|
||||
|
||||
if ( title )
|
||||
data->setXtermTitle(*title);
|
||||
if ( ! title.isEmpty() )
|
||||
data->setXtermTitle(title);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -2126,6 +2148,7 @@ void FTerm::useNormalScreenBuffer()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FTerm::allocationValues()
|
||||
{
|
||||
FStartOptions::getFStartOptions();
|
||||
getFTermData();
|
||||
getFSystem();
|
||||
getFOptiMove();
|
||||
|
@ -2146,7 +2169,6 @@ inline void FTerm::allocationValues()
|
|||
#if DEBUG
|
||||
getFTermDebugData();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -2191,6 +2213,10 @@ inline void FTerm::deallocationValues()
|
|||
|
||||
if ( data )
|
||||
delete data;
|
||||
|
||||
defaultPutChar* putchar_ptr = &(putchar());
|
||||
delete putchar_ptr;
|
||||
FStartOptions::destroyObject();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -2240,7 +2266,7 @@ void FTerm::init (bool disable_alt_screen)
|
|||
init_alt_charset();
|
||||
|
||||
// Pass the terminal capabilities to the keyboard object
|
||||
keyboard->setTermcapMap (fc::Fkey);
|
||||
keyboard->setTermcapMap (fc::fkey);
|
||||
|
||||
// Initializes locale information
|
||||
init_locale();
|
||||
|
@ -2357,6 +2383,9 @@ void FTerm::initBaudRate()
|
|||
uInt baud = FTermios::getBaudRate();
|
||||
data->setBaudrate(baud);
|
||||
|
||||
if ( ! fsys )
|
||||
getFSystem();
|
||||
|
||||
if ( fsys->isTTY(stdout_no) )
|
||||
opti_move->setBaudRate(int(baud));
|
||||
}
|
||||
|
@ -2501,259 +2530,11 @@ void FTerm::signal_handler (int signum)
|
|||
init_term_object->finish();
|
||||
std::fflush (stderr);
|
||||
std::fflush (stdout);
|
||||
std::fprintf ( stderr
|
||||
, "\nProgram stopped: signal %d (%s)\n"
|
||||
, signum
|
||||
, strsignal(signum) );
|
||||
std::cerr << "\nProgram stopped: signal "
|
||||
<< signum
|
||||
<< " (" << strsignal(signum) << ")" << std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
}
|
||||
|
||||
// FTerm non-member functions
|
||||
//----------------------------------------------------------------------
|
||||
uInt env2uint (const char* env)
|
||||
{
|
||||
FString str(getenv(env));
|
||||
|
||||
if ( str.isEmpty() )
|
||||
return 0;
|
||||
|
||||
try
|
||||
{
|
||||
return str.toUInt();
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
wchar_t cp437_to_unicode (uChar c)
|
||||
{
|
||||
constexpr std::size_t CP437 = 0;
|
||||
constexpr std::size_t UNICODE = 1;
|
||||
wchar_t ucs(c);
|
||||
|
||||
for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
|
||||
{
|
||||
if ( fc::cp437_to_ucs[i][CP437] == c ) // found
|
||||
{
|
||||
ucs = fc::cp437_to_ucs[i][UNICODE];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ucs;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
uChar unicode_to_cp437 (wchar_t ucs)
|
||||
{
|
||||
constexpr std::size_t CP437 = 0;
|
||||
constexpr std::size_t UNICODE = 1;
|
||||
uChar c{'?'};
|
||||
|
||||
for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
|
||||
{
|
||||
if ( fc::cp437_to_ucs[i][UNICODE] == ucs ) // found
|
||||
{
|
||||
c = uChar(fc::cp437_to_ucs[i][CP437]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString getFullWidth (const FString& str)
|
||||
{
|
||||
// Converts half-width to full-width characters
|
||||
|
||||
FString s(str);
|
||||
constexpr std::size_t HALF = 0;
|
||||
constexpr std::size_t FULL = 1;
|
||||
|
||||
for (auto&& c : s)
|
||||
{
|
||||
if ( c > L'\x20' && c < L'\x7f' ) // half-width ASCII
|
||||
{
|
||||
c += 0xfee0;
|
||||
}
|
||||
else for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
|
||||
{
|
||||
if ( fc::halfWidth_fullWidth[i][HALF] == c ) // found
|
||||
{
|
||||
c = fc::halfWidth_fullWidth[i][FULL];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString getHalfWidth (const FString& str)
|
||||
{
|
||||
// Converts full-width to half-width characters
|
||||
|
||||
FString s(str);
|
||||
constexpr std::size_t HALF = 0;
|
||||
constexpr std::size_t FULL = 1;
|
||||
|
||||
for (auto&& c : s)
|
||||
{
|
||||
if ( c > L'\xff00' && c < L'\xff5f' ) // full-width ASCII
|
||||
{
|
||||
c -= 0xfee0;
|
||||
}
|
||||
else for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
|
||||
{
|
||||
if ( fc::halfWidth_fullWidth[i][FULL] == c ) // found
|
||||
{
|
||||
c = fc::halfWidth_fullWidth[i][HALF];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidthToLength ( const FString& str
|
||||
, std::size_t col_len )
|
||||
{
|
||||
std::size_t column_width{0}, length{0};
|
||||
|
||||
for (auto&& ch : str)
|
||||
{
|
||||
if ( column_width < col_len )
|
||||
{
|
||||
column_width += getColumnWidth(ch);
|
||||
length++;
|
||||
}
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString getColumnSubString ( const FString& str
|
||||
, std::size_t col_pos, std::size_t col_len )
|
||||
{
|
||||
FString s(str);
|
||||
std::size_t col_first{1}, col_num{0}, first{1}, num{0};
|
||||
|
||||
if ( col_len == 0 || s.isEmpty() )
|
||||
return FString(L"");
|
||||
|
||||
if ( col_pos == 0 )
|
||||
col_pos = 1;
|
||||
|
||||
for (auto&& ch : s)
|
||||
{
|
||||
std::size_t width = getColumnWidth(ch);
|
||||
|
||||
if ( col_first < col_pos )
|
||||
{
|
||||
if ( col_first + width <= col_pos )
|
||||
{
|
||||
col_first += width;
|
||||
first++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = fc::SingleLeftAngleQuotationMark; // ‹
|
||||
num = col_num = 1;
|
||||
col_pos = col_first;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( col_num + width <= col_len )
|
||||
{
|
||||
col_num += width;
|
||||
num++;
|
||||
}
|
||||
else if ( col_num < col_len )
|
||||
{
|
||||
ch = fc::SingleRightAngleQuotationMark; // ›
|
||||
num++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( col_first < col_pos ) // String length < col_pos
|
||||
return FString(L"");
|
||||
|
||||
return s.mid(first, num);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (const FString& s, std::size_t pos)
|
||||
{
|
||||
if ( s.isEmpty() )
|
||||
return 0;
|
||||
|
||||
std::size_t column_width{0};
|
||||
auto length = s.getLength();
|
||||
|
||||
if ( pos > length )
|
||||
pos = length;
|
||||
|
||||
for (std::size_t i{0}; i < pos; i++)
|
||||
column_width += getColumnWidth(s[i]);
|
||||
|
||||
return column_width;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (const FString& s)
|
||||
{
|
||||
if ( s.isEmpty() )
|
||||
return 0;
|
||||
|
||||
const wchar_t* str = s.wc_str();
|
||||
size_t len = std::wcslen(str);
|
||||
int column_width = wcswidth (str, len);
|
||||
return ( column_width == -1 ) ? 0 : std::size_t(column_width);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (const wchar_t wchar)
|
||||
{
|
||||
int column_width = wcwidth (wchar);
|
||||
return ( column_width == -1 ) ? 0 : std::size_t(column_width);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (charData& term_char)
|
||||
{
|
||||
int column_width = wcwidth (term_char.code);
|
||||
std::size_t char_width = ( column_width == -1 ) ? 0 : std::size_t(column_width);
|
||||
|
||||
if ( char_width == 2 && FTerm::getEncoding() != fc::UTF8 )
|
||||
{
|
||||
term_char.code = '.';
|
||||
term_char.attr.bit.char_width = 1;
|
||||
}
|
||||
else
|
||||
term_char.attr.bit.char_width = char_width & 0x03;
|
||||
|
||||
return char_width;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (const FTermBuffer& termbuffer)
|
||||
{
|
||||
std::size_t column_width{0};
|
||||
|
||||
for (auto&& tc : termbuffer)
|
||||
column_width += tc.attr.bit.char_width;
|
||||
|
||||
return column_width;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
|
|
@ -0,0 +1,430 @@
|
|||
/***********************************************************************
|
||||
* fterm_functions.cpp - FTerm helper functions *
|
||||
* *
|
||||
* 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/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
#include "final/fconfig.h" // includes _GNU_SOURCE for wcwidth()
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "final/fcharmap.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermbuffer.h"
|
||||
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// Function prototypes
|
||||
bool hasAmbiguousWidth (wchar_t);
|
||||
|
||||
// Data array
|
||||
const wchar_t ambiguous_width_list[] =
|
||||
{
|
||||
0x00a1, 0x00a4, 0x00a7, 0x00a8, 0x00aa, 0x00ad, 0x00ae, 0x00b0,
|
||||
0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b6, 0x00b7, 0x00b8, 0x00b9,
|
||||
0x00ba, 0x00bc, 0x00bd, 0x00be, 0x00bf, 0x00c6, 0x00d0, 0x00d7,
|
||||
0x00d8, 0x00de, 0x00df, 0x00e0, 0x00e1, 0x00e6, 0x00e8, 0x00e9,
|
||||
0x00ea, 0x00ec, 0x00ed, 0x00f0, 0x00f2, 0x00f3, 0x00f7, 0x00f8,
|
||||
0x00f9, 0x00fa, 0x00fc, 0x00fe, 0x0101, 0x0111, 0x0113, 0x011b,
|
||||
0x0126, 0x0127, 0x012b, 0x0131, 0x0132, 0x0133, 0x0138, 0x013f,
|
||||
0x0140, 0x0141, 0x0142, 0x0144, 0x0148, 0x0149, 0x014a, 0x014b,
|
||||
0x014d, 0x0152, 0x0153, 0x0166, 0x0167, 0x016b, 0x01ce, 0x01d0,
|
||||
0x01d2, 0x01d4, 0x01d6, 0x01d8, 0x01da, 0x01dc, 0x0251, 0x0261,
|
||||
0x02c4, 0x02c7, 0x02c9, 0x02ca, 0x02cb, 0x02cd, 0x02d0, 0x02d8,
|
||||
0x02d9, 0x02da, 0x02db, 0x02dd, 0x02df, 0x0300, 0x0301, 0x0302,
|
||||
0x0303, 0x0304, 0x0305, 0x0306, 0x0307, 0x0308, 0x0309, 0x030a,
|
||||
0x030b, 0x030c, 0x030d, 0x030f, 0x0310, 0x0311, 0x0312, 0x0313,
|
||||
0x0314, 0x0315, 0x0316, 0x0317, 0x0318, 0x0319, 0x031a, 0x031b,
|
||||
0x031c, 0x031d, 0x031e, 0x031f, 0x0320, 0x0321, 0x0322, 0x0323,
|
||||
0x0324, 0x0325, 0x0326, 0x0327, 0x0328, 0x0329, 0x032a, 0x032b,
|
||||
0x032c, 0x032d, 0x032e, 0x032f, 0x0330, 0x0331, 0x0332, 0x0333,
|
||||
0x0334, 0x0335, 0x0336, 0x0337, 0x0338, 0x0339, 0x033a, 0x033b,
|
||||
0x033c, 0x033d, 0x033e, 0x033f, 0x0340, 0x0341, 0x0342, 0x0343,
|
||||
0x0344, 0x0345, 0x0346, 0x0347, 0x0348, 0x0349, 0x034a, 0x034b,
|
||||
0x034c, 0x034d, 0x034e, 0x034f, 0x0350, 0x0351, 0x0352, 0x0353,
|
||||
0x0354, 0x0355, 0x0356, 0x0357, 0x0358, 0x0359, 0x035a, 0x035b,
|
||||
0x035c, 0x035d, 0x035e, 0x035f, 0x0360, 0x0361, 0x0362, 0x0363,
|
||||
0x0364, 0x0365, 0x0366, 0x0367, 0x0368, 0x0369, 0x036a, 0x036b,
|
||||
0x036c, 0x036d, 0x036e, 0x036f, 0x0391, 0x0392, 0x0393, 0x0394,
|
||||
0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c,
|
||||
0x039d, 0x039e, 0x039f, 0x03a0, 0x03a1, 0x03a3, 0x03a4, 0x03a5,
|
||||
0x03a6, 0x03a7, 0x03a8, 0x03a9, 0x03b1, 0x03b2, 0x03b3, 0x03b4,
|
||||
0x03b5, 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc,
|
||||
0x03bd, 0x03be, 0x03bf, 0x03c0, 0x03c1, 0x03c3, 0x03c4, 0x03c5,
|
||||
0x03c6, 0x03c7, 0x03c8, 0x03c9, 0x0401, 0x0410, 0x0411, 0x0412,
|
||||
0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041a,
|
||||
0x041b, 0x041c, 0x041d, 0x041e, 0x041f, 0x0420, 0x0421, 0x0422,
|
||||
0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042a,
|
||||
0x042b, 0x042c, 0x042d, 0x042e, 0x042f, 0x0430, 0x0431, 0x0432,
|
||||
0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043a,
|
||||
0x043b, 0x043c, 0x043d, 0x043e, 0x043f, 0x0440, 0x0441, 0x0442,
|
||||
0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044a,
|
||||
0x044b, 0x044c, 0x044d, 0x044e, 0x044f, 0x0451, 0x2010, 0x2013,
|
||||
0x2014, 0x2015, 0x2016, 0x2018, 0x2019, 0x201c, 0x201d, 0x2020,
|
||||
0x2021, 0x2022, 0x2024, 0x2025, 0x2026, 0x2027, 0x2030, 0x2032,
|
||||
0x2033, 0x2035, 0x203b, 0x203e, 0x2074, 0x207f, 0x2081, 0x2082,
|
||||
0x2083, 0x2084, 0x20ac, 0x2103, 0x2105, 0x2109, 0x2113, 0x2116,
|
||||
0x2121, 0x2122, 0x2126, 0x212b, 0x2153, 0x2154, 0x215b, 0x215c,
|
||||
0x215d, 0x215e, 0x2160, 0x2162, 0x2162, 0x2163, 0x2164, 0x2165,
|
||||
0x2166, 0x2167, 0x2168, 0x2169, 0x216a, 0x216b, 0x2170, 0x2171,
|
||||
0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179,
|
||||
0x2190, 0x2191, 0x2192, 0x2193, 0x2194, 0x2195, 0x2196, 0x2197,
|
||||
0x2198, 0x2199, 0x21b8, 0x21b9, 0x21d2, 0x21d4, 0x21e7, 0x2200,
|
||||
0x2202, 0x2203, 0x2207, 0x2208, 0x220b, 0x220f, 0x2211, 0x2215,
|
||||
0x221a, 0x221d, 0x221e, 0x221f, 0x2220, 0x2223, 0x2225, 0x2227,
|
||||
0x2228, 0x2229, 0x222a, 0x222b, 0x222c, 0x222e, 0x2234, 0x2235,
|
||||
0x2236, 0x2237, 0x223c, 0x223d, 0x2248, 0x224c, 0x2252, 0x2260,
|
||||
0x2261, 0x2264, 0x2265, 0x2266, 0x2267, 0x226a, 0x226b, 0x226e,
|
||||
0x226f, 0x2282, 0x2283, 0x2286, 0x2287, 0x2295, 0x2299, 0x22a5,
|
||||
0x22bf, 0x2312, 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465,
|
||||
0x2466, 0x2467, 0x2468, 0x2469, 0x246a, 0x246b, 0x246c, 0x246d,
|
||||
0x246e, 0x246f, 0x2470, 0x2471, 0x2472, 0x2473, 0x2474, 0x2475,
|
||||
0x2476, 0x2477, 0x2478, 0x2479, 0x247a, 0x247b, 0x247c, 0x247d,
|
||||
0x247e, 0x247f, 0x2480, 0x2481, 0x2482, 0x2483, 0x2484, 0x2485,
|
||||
0x2486, 0x2487, 0x2488, 0x2489, 0x248a, 0x248b, 0x248c, 0x248d,
|
||||
0x248e, 0x248f, 0x2490, 0x2491, 0x2492, 0x2493, 0x2494, 0x2495,
|
||||
0x2496, 0x2497, 0x2498, 0x2499, 0x249a, 0x249b, 0x249c, 0x249d,
|
||||
0x249e, 0x249f, 0x24a0, 0x24a1, 0x24a2, 0x24a3, 0x24a4, 0x24a5,
|
||||
0x24a6, 0x24a7, 0x24a8, 0x24a9, 0x24aa, 0x24ab, 0x24ac, 0x24ad,
|
||||
0x24ae, 0x24af, 0x24b0, 0x24b1, 0x24b2, 0x24b3, 0x24b4, 0x24b5,
|
||||
0x24b6, 0x24b7, 0x24b8, 0x24b9, 0x24ba, 0x24bb, 0x24bc, 0x24bd,
|
||||
0x24be, 0x24bf, 0x24c0, 0x24c1, 0x24c2, 0x24c3, 0x24c4, 0x24c5,
|
||||
0x24c6, 0x24c7, 0x24c8, 0x24c9, 0x24ca, 0x24cb, 0x24cc, 0x24cd,
|
||||
0x24ce, 0x24cf, 0x24d0, 0x24d1, 0x24d2, 0x24d3, 0x24d4, 0x24d5,
|
||||
0x24d6, 0x24d7, 0x24d8, 0x24d9, 0x24da, 0x24db, 0x24dc, 0x24dd,
|
||||
0x24de, 0x24df, 0x24e0, 0x24e1, 0x24e2, 0x24e3, 0x24e4, 0x24e5,
|
||||
0x24e6, 0x24e7, 0x24e8, 0x24e9, 0x24eb, 0x24ec, 0x24ed, 0x24ee,
|
||||
0x24ef, 0x24f0, 0x24f1, 0x24f2, 0x24f3, 0x24f4, 0x24f5, 0x24f6,
|
||||
0x24f7, 0x24f8, 0x24f9, 0x24fa, 0x24fb, 0x24fc, 0x24fd, 0x24fe,
|
||||
0x2500, 0x2501, 0x2502, 0x2503, 0x2504, 0x2505, 0x2506, 0x2507,
|
||||
0x2508, 0x2509, 0x250a, 0x250b, 0x250c, 0x250d, 0x250e, 0x250f,
|
||||
0x2510, 0x2511, 0x2512, 0x2513, 0x2514, 0x2515, 0x2516, 0x2517,
|
||||
0x2518, 0x2519, 0x251a, 0x251b, 0x251c, 0x251d, 0x251e, 0x251f,
|
||||
0x2520, 0x2521, 0x2522, 0x2523, 0x2524, 0x2525, 0x2526, 0x2527,
|
||||
0x2528, 0x2529, 0x252a, 0x252b, 0x252c, 0x252d, 0x252e, 0x252f,
|
||||
0x2530, 0x2531, 0x2532, 0x2533, 0x2534, 0x2535, 0x2536, 0x2537,
|
||||
0x2538, 0x2539, 0x253a, 0x253b, 0x253c, 0x253d, 0x253e, 0x253f,
|
||||
0x2540, 0x2541, 0x2542, 0x2543, 0x2544, 0x2545, 0x2546, 0x2547,
|
||||
0x2548, 0x2549, 0x254a, 0x254b, 0x2550, 0x2551, 0x2552, 0x2553,
|
||||
0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255a, 0x255b,
|
||||
0x255c, 0x255d, 0x255e, 0x255f, 0x2560, 0x2561, 0x2562, 0x2563,
|
||||
0x2564, 0x2565, 0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x256b,
|
||||
0x256c, 0x256d, 0x256e, 0x256f, 0x2570, 0x2571, 0x2572, 0x2573,
|
||||
0x2580, 0x2581, 0x2582, 0x2583, 0x2584, 0x2585, 0x2586, 0x2587,
|
||||
0x2588, 0x2589, 0x258a, 0x258b, 0x258c, 0x258d, 0x258e, 0x258f,
|
||||
0x2590, 0x2592, 0x2593, 0x2594, 0x2595, 0x25a0, 0x25a1, 0x25a3,
|
||||
0x25a4, 0x25a5, 0x25a6, 0x25a7, 0x25a8, 0x25a9, 0x25ac, 0x25ae,
|
||||
0x25b2, 0x25b3, 0x25b6, 0x25b7, 0x25ba, 0x25bc, 0x25bd, 0x25c0,
|
||||
0x25c1, 0x25c4, 0x25c6, 0x25c7, 0x25c8, 0x25cb, 0x25ce, 0x25cf,
|
||||
0x25d0, 0x25d1, 0x25d8, 0x25d9, 0x25e2, 0x25e3, 0x25e4, 0x25e5,
|
||||
0x25ef, 0x2605, 0x2606, 0x2609, 0x260e, 0x260f, 0x2614, 0x2615,
|
||||
0x261c, 0x261e, 0x2640, 0x2642, 0x2660, 0x2661, 0x2663, 0x2664,
|
||||
0x2665, 0x2667, 0x2668, 0x2669, 0x266a, 0x266c, 0x266d, 0x266f,
|
||||
0x273d, 0x2776, 0x2777, 0x2778, 0x2779, 0x277a, 0x277b, 0x277c,
|
||||
0x277d, 0x277e, 0x277f, 0xfe00, 0xfe01, 0xfe02, 0xfe03, 0xfe04,
|
||||
0xfe05, 0xfe07, 0xfe09, 0xfe0a, 0xfe0b, 0xfe0c, 0xfe0d, 0xfe0e,
|
||||
0xfe0f, 0xfffd
|
||||
#if !defined(__CYGWIN__)
|
||||
, 0xe0100, 0xe0101, 0xe0102, 0xe0103, 0xe0104, 0xe0105, 0xe0106,
|
||||
0xe0107, 0xe0108, 0xe0109, 0xe010a, 0xe01ef
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
// FTerm non-member functions
|
||||
//----------------------------------------------------------------------
|
||||
uInt env2uint (const char* env)
|
||||
{
|
||||
FString str(getenv(env));
|
||||
|
||||
if ( str.isEmpty() )
|
||||
return 0;
|
||||
|
||||
try
|
||||
{
|
||||
return str.toUInt();
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool hasAmbiguousWidth (wchar_t wchar)
|
||||
{
|
||||
const auto& begin = std::begin(ambiguous_width_list);
|
||||
const auto& end = std::end(ambiguous_width_list);
|
||||
|
||||
if ( std::find(begin, end, wchar) != end ) // found
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
wchar_t cp437_to_unicode (uChar c)
|
||||
{
|
||||
constexpr std::size_t CP437 = 0;
|
||||
constexpr std::size_t UNICODE = 1;
|
||||
wchar_t ucs = c;
|
||||
|
||||
for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
|
||||
{
|
||||
if ( fc::cp437_ucs[i][CP437] == c ) // found
|
||||
{
|
||||
ucs = fc::cp437_ucs[i][UNICODE];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ucs;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
uChar unicode_to_cp437 (wchar_t ucs)
|
||||
{
|
||||
constexpr std::size_t CP437 = 0;
|
||||
constexpr std::size_t UNICODE = 1;
|
||||
uChar c{'?'};
|
||||
|
||||
for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
|
||||
{
|
||||
if ( fc::cp437_ucs[i][UNICODE] == ucs ) // found
|
||||
{
|
||||
c = uChar(fc::cp437_ucs[i][CP437]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString getFullWidth (const FString& str)
|
||||
{
|
||||
// Converts half-width to full-width characters
|
||||
|
||||
FString s(str);
|
||||
constexpr std::size_t HALF = 0;
|
||||
constexpr std::size_t FULL = 1;
|
||||
|
||||
for (auto&& c : s)
|
||||
{
|
||||
if ( c > L'\x20' && c < L'\x7f' ) // half-width ASCII
|
||||
{
|
||||
c += 0xfee0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
|
||||
{
|
||||
if ( fc::halfWidth_fullWidth[i][HALF] == c ) // found
|
||||
c = fc::halfWidth_fullWidth[i][FULL];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString getHalfWidth (const FString& str)
|
||||
{
|
||||
// Converts full-width to half-width characters
|
||||
|
||||
FString s(str);
|
||||
constexpr std::size_t HALF = 0;
|
||||
constexpr std::size_t FULL = 1;
|
||||
|
||||
for (auto&& c : s)
|
||||
{
|
||||
if ( c > L'\xff00' && c < L'\xff5f' ) // full-width ASCII
|
||||
{
|
||||
c -= 0xfee0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
|
||||
{
|
||||
if ( fc::halfWidth_fullWidth[i][FULL] == c ) // found
|
||||
c = fc::halfWidth_fullWidth[i][HALF];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString getColumnSubString ( const FString& str
|
||||
, std::size_t col_pos, std::size_t col_len )
|
||||
{
|
||||
FString s(str);
|
||||
std::size_t col_first{1}, col_num{0}, first{1}, num{0};
|
||||
|
||||
if ( col_len == 0 || s.isEmpty() )
|
||||
return FString(L"");
|
||||
|
||||
if ( col_pos == 0 )
|
||||
col_pos = 1;
|
||||
|
||||
for (auto&& ch : s)
|
||||
{
|
||||
std::size_t width = getColumnWidth(ch);
|
||||
|
||||
if ( col_first < col_pos )
|
||||
{
|
||||
if ( col_first + width <= col_pos )
|
||||
{
|
||||
col_first += width;
|
||||
first++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = fc::SingleLeftAngleQuotationMark; // ‹
|
||||
num = col_num = 1;
|
||||
col_pos = col_first;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( col_num + width <= col_len )
|
||||
{
|
||||
col_num += width;
|
||||
num++;
|
||||
}
|
||||
else if ( col_num < col_len )
|
||||
{
|
||||
ch = fc::SingleRightAngleQuotationMark; // ›
|
||||
num++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( col_first < col_pos ) // String length < col_pos
|
||||
return FString(L"");
|
||||
|
||||
return s.mid(first, num);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getLengthFromColumnWidth ( const FString& str
|
||||
, std::size_t col_len )
|
||||
{
|
||||
std::size_t column_width{0}, length{0};
|
||||
|
||||
for (auto&& ch : str)
|
||||
{
|
||||
if ( column_width < col_len )
|
||||
{
|
||||
column_width += getColumnWidth(ch);
|
||||
length++;
|
||||
}
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (const FString& s, std::size_t pos)
|
||||
{
|
||||
if ( s.isEmpty() )
|
||||
return 0;
|
||||
|
||||
std::size_t column_width{0};
|
||||
auto length = s.getLength();
|
||||
|
||||
if ( pos > length )
|
||||
pos = length;
|
||||
|
||||
for (std::size_t i{0}; i < pos; i++)
|
||||
column_width += getColumnWidth(s[i]);
|
||||
|
||||
return column_width;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (const FString& s)
|
||||
{
|
||||
int column_width{0};
|
||||
|
||||
if ( s.isEmpty() )
|
||||
return 0;
|
||||
|
||||
for (const auto& wchar : s)
|
||||
column_width += getColumnWidth(wchar);
|
||||
|
||||
return ( column_width == -1 ) ? 0 : std::size_t(column_width);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (const wchar_t wchar)
|
||||
{
|
||||
int column_width{};
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) \
|
||||
|| defined(__FreeBSD__) || defined(__DragonFly__) \
|
||||
|| defined(__sun) && defined(__SVR4)
|
||||
if ( hasAmbiguousWidth(wchar) )
|
||||
column_width = 1;
|
||||
else
|
||||
#endif
|
||||
|
||||
if ( wchar >= fc::NF_rev_left_arrow2 && wchar <= fc::NF_check_mark )
|
||||
column_width = 1;
|
||||
else
|
||||
column_width = wcwidth(wchar);
|
||||
|
||||
return ( column_width == -1 ) ? 0 : std::size_t(column_width);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (FChar& term_char)
|
||||
{
|
||||
std::size_t char_width = getColumnWidth(term_char.ch);
|
||||
|
||||
if ( char_width == 2 && FTerm::getEncoding() != fc::UTF8 )
|
||||
{
|
||||
term_char.ch = '.';
|
||||
term_char.attr.bit.char_width = 1;
|
||||
}
|
||||
else
|
||||
term_char.attr.bit.char_width = char_width & 0x03;
|
||||
|
||||
return char_width;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (const FTermBuffer& termbuffer)
|
||||
{
|
||||
std::size_t column_width{0};
|
||||
|
||||
for (auto&& tc : termbuffer)
|
||||
column_width += tc.attr.bit.char_width;
|
||||
|
||||
return column_width;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
|
@ -46,8 +46,8 @@ const FString FTermBuffer::toString() const
|
|||
std::wstring wide_string{};
|
||||
wide_string.reserve(data.size());
|
||||
|
||||
for (auto&& tc : data)
|
||||
wide_string.push_back(tc.code);
|
||||
for (auto&& fchar : data)
|
||||
wide_string.push_back(fchar.ch);
|
||||
|
||||
return FString(wide_string);
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ int FTermBuffer::write (const FString& string)
|
|||
|
||||
for (auto&& c : string)
|
||||
{
|
||||
charData nc; // next character
|
||||
FChar nc; // next character
|
||||
nc = FVTerm::getAttribute();
|
||||
nc.code = c;
|
||||
nc.ch = c;
|
||||
getColumnWidth(nc); // add column width
|
||||
nc.attr.bit.no_changes = false;
|
||||
nc.attr.bit.printed = false;
|
||||
|
@ -75,8 +75,8 @@ int FTermBuffer::write (const FString& string)
|
|||
//----------------------------------------------------------------------
|
||||
int FTermBuffer::write (wchar_t ch)
|
||||
{
|
||||
charData nc = FVTerm::getAttribute(); // next character
|
||||
nc.code = ch;
|
||||
FChar nc = FVTerm::getAttribute(); // next character
|
||||
nc.ch = ch;
|
||||
getColumnWidth(nc); // add column width
|
||||
nc.attr.bit.no_changes = false;
|
||||
nc.attr.bit.printed = false;
|
||||
|
@ -94,7 +94,7 @@ void FTermBuffer::write (const FColorPair& pair)
|
|||
|
||||
// FTermBuffer non-member operators
|
||||
//----------------------------------------------------------------------
|
||||
FTermBuffer::charDataVector& operator << ( FTermBuffer::charDataVector& termString
|
||||
FTermBuffer::FCharVector& operator << ( FTermBuffer::FCharVector& termString
|
||||
, const FTermBuffer& buf )
|
||||
{
|
||||
if ( ! buf.data.empty() )
|
||||
|
|
|
@ -230,48 +230,48 @@ 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);
|
||||
fc::fkey[i].string = tgetstr(fc::fkey[i].tname, &buffer);
|
||||
|
||||
// Fallback for rxvt with TERM=xterm
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "khx", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "7~"); // Home key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "khx", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "7~"); // Home key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "@7x", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "8~"); // End key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "@7x", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "8~"); // End key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k1x", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "11~"); // F1
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k1x", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "11~"); // F1
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k2x", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "12~"); // F2
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k2x", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "12~"); // F2
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k3x", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "13~"); // F3
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k3x", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "13~"); // F3
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k4x", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "14~"); // F4
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k4x", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "14~"); // F4
|
||||
|
||||
// Fallback for TERM=ansi
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "@7X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "K"); // End key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "@7X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "K"); // End key
|
||||
|
||||
// Keypad keys
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "@8x", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OM"); // Enter key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "@8x", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OM"); // Enter key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "KP1", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "Oo"); // Keypad slash
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP1", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "Oo"); // Keypad slash
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "KP2", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "Oj"); // Keypad asterisk
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP2", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "Oj"); // Keypad asterisk
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "KP3", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "Om"); // Keypad minus sign
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP3", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "Om"); // Keypad minus sign
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "KP4", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "Ok"); // Keypad plus sign
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP4", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "Ok"); // Keypad plus sign
|
||||
}
|
||||
|
||||
// VT100 key codes for the arrow and function keys
|
||||
|
@ -290,31 +290,31 @@ void FTermcap::termcapKeysVt100 (char*& buffer)
|
|||
|| ( 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
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kux", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "A"); // Key up
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kdx", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "B"); // Key down
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kdx", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "B"); // Key down
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "krx", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "C"); // Key right
|
||||
if ( std::strncmp(fc::fkey[i].tname, "krx", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "C"); // Key right
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "klx", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "D"); // Key left
|
||||
if ( std::strncmp(fc::fkey[i].tname, "klx", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "D"); // Key left
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k1X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OP"); // PF1
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k1X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OP"); // PF1
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k2X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OQ"); // PF2
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k2X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OQ"); // PF2
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k3X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OR"); // PF3
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k3X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OR"); // PF3
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k4X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OS"); // PF4
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k4X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OS"); // PF4
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -402,71 +402,71 @@ 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
|
||||
if ( std::strncmp(fc::fkey[i].tname, "K2", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "218z"); // center of keypad
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kb", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR("\b"); // backspace key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kb", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR("\b"); // backspace key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kD", 2) == 0
|
||||
&& std::strlen(fc::Fkey[i].tname) == 2 )
|
||||
fc::Fkey[i].string = C_STR("\177"); // delete-character key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kD", 2) == 0
|
||||
&& std::strlen(fc::fkey[i].tname) == 2 )
|
||||
fc::fkey[i].string = C_STR("\177"); // delete-character key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "@7", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "220z"); // end key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "@7", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "220z"); // end key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k;", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "233z"); // F10 function key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k;", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "233z"); // F10 function key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "F1", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "234z"); // F11 function key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "F1", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "234z"); // F11 function key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "F2", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "235z"); // F12 function key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "F2", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "235z"); // F12 function key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kh", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "214z"); // home key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kh", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "214z"); // home key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kI", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "247z"); // insert-character key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kI", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "247z"); // insert-character key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kN", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "222z"); // next-page key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kN", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "222z"); // next-page key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "%7", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "194z"); // options key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "%7", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "194z"); // options key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kP", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "216z"); // prev-page key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kP", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "216z"); // prev-page key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "&5", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "193z"); // resume key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "&5", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "193z"); // resume key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "&8", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "195z"); // undo key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "&8", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "195z"); // undo key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "K2", 2) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "218z"); // center of keypad
|
||||
if ( std::strncmp(fc::fkey[i].tname, "K2", 2) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "218z"); // center of keypad
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kDx", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "249z"); // keypad delete
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kDx", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "249z"); // keypad delete
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "@8x", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "250z"); // enter/send key
|
||||
if ( std::strncmp(fc::fkey[i].tname, "@8x", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "250z"); // enter/send key
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "KP1", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "212z"); // keypad slash
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP1", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "212z"); // keypad slash
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "KP2", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "213z"); // keypad asterisk
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP2", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "213z"); // keypad asterisk
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "KP3", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "254z"); // keypad minus sign
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP3", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "254z"); // keypad minus sign
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "KP4", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "253z"); // keypad plus sign
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP4", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "253z"); // keypad plus sign
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "final/emptyfstring.h"
|
||||
#include "final/fc.h"
|
||||
#include "final/fconfig.h"
|
||||
#include "final/fsystem.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermdata.h"
|
||||
|
@ -46,7 +45,7 @@ namespace finalcut
|
|||
{
|
||||
|
||||
// static class attributes
|
||||
FTermDetection::terminalType FTermDetection::terminal_type{};
|
||||
FTermDetection::FTerminalType FTermDetection::terminal_type{};
|
||||
FTermDetection::colorEnv FTermDetection::color_env{};
|
||||
FTermDetection::secondaryDA FTermDetection::secondary_da{};
|
||||
FTermData* FTermDetection::fterm_data{nullptr};
|
||||
|
@ -546,10 +545,11 @@ const FString FTermDetection::getXTermColorName (FColor color)
|
|||
struct timeval tv{};
|
||||
int stdin_no = FTermios::getStdIn();
|
||||
|
||||
char temp[512]{};
|
||||
std::fprintf (stdout, OSC "4;%hu;?" BEL, color); // get color
|
||||
// get color
|
||||
std::fprintf (stdout, OSC "4;%hu;?" BEL, color);
|
||||
std::fflush (stdout);
|
||||
|
||||
char temp[512]{};
|
||||
FD_ZERO(&ifds);
|
||||
FD_SET(stdin_no, &ifds);
|
||||
tv.tv_sec = 0;
|
||||
|
|
|
@ -41,26 +41,6 @@
|
|||
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{};
|
||||
|
||||
bool FTermLinux::new_font{false};
|
||||
bool FTermLinux::vga_font{false};
|
||||
bool FTermLinux::has_saved_palette{false};
|
||||
|
||||
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__)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FTermLinux
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -134,7 +114,7 @@ void FTermLinux::setUTF8 (bool enable)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
||||
#if defined(ISA_SYSCTL_SUPPORT)
|
||||
bool FTermLinux::setPalette (FColor index, int r, int g, int b)
|
||||
{
|
||||
if ( ! FTerm::isLinuxTerm() )
|
||||
|
@ -183,7 +163,10 @@ void FTermLinux::init()
|
|||
screen_font.data = nullptr;
|
||||
fterm_data->supportShadowCharacter (true);
|
||||
fterm_data->supportHalfBlockCharacter (true);
|
||||
|
||||
#if defined(ISA_SYSCTL_SUPPORT)
|
||||
getVGAPalette();
|
||||
#endif
|
||||
|
||||
if ( FTerm::openConsole() == 0 )
|
||||
{
|
||||
|
@ -194,7 +177,7 @@ void FTermLinux::init()
|
|||
getUnicodeMap();
|
||||
getScreenFont();
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
||||
#if defined(ISA_SYSCTL_SUPPORT)
|
||||
// Enable 16 background colors
|
||||
if ( setBlinkAsIntensity(true) == 0 )
|
||||
FTermcap::max_color = 16;
|
||||
|
@ -266,7 +249,7 @@ void FTermLinux::finish()
|
|||
{
|
||||
if ( FTerm::isLinuxTerm() )
|
||||
{
|
||||
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
||||
#if defined(ISA_SYSCTL_SUPPORT)
|
||||
setBlinkAsIntensity (false);
|
||||
#endif
|
||||
setLinuxCursorStyle (fc::default_cursor);
|
||||
|
@ -403,7 +386,7 @@ bool FTermLinux::saveColorMap()
|
|||
if ( ! FTerm::isLinuxTerm() )
|
||||
return false;
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
||||
#if defined(ISA_SYSCTL_SUPPORT)
|
||||
return saveVGAPalette();
|
||||
#else
|
||||
return false;
|
||||
|
@ -416,7 +399,7 @@ bool FTermLinux::resetColorMap()
|
|||
if ( ! FTerm::isLinuxTerm() )
|
||||
return false;
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
||||
#if defined(ISA_SYSCTL_SUPPORT)
|
||||
return resetVGAPalette();
|
||||
#else
|
||||
return false;
|
||||
|
@ -772,7 +755,7 @@ void FTermLinux::setLinuxCursorStyle (CursorStyle style)
|
|||
FTerm::putstringf (CSI "?%dc", style);
|
||||
}
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
||||
#if defined(ISA_SYSCTL_SUPPORT)
|
||||
//----------------------------------------------------------------------
|
||||
inline uInt16 FTermLinux::getInputStatusRegisterOne()
|
||||
{
|
||||
|
@ -976,7 +959,7 @@ bool FTermLinux::resetVGAPalette()
|
|||
|
||||
return true;
|
||||
}
|
||||
#endif // defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
||||
#endif // defined(ISA_SYSCTL_SUPPORT)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FKey FTermLinux::shiftKeyCorrection (const FKey& key_id)
|
||||
|
|
|
@ -39,6 +39,11 @@ namespace finalcut
|
|||
// class FTermOpenBSD
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FTermOpenBSD::~FTermOpenBSD() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of FTermOpenBSD
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
|
|
|
@ -39,21 +39,7 @@ namespace finalcut
|
|||
|
||||
// static class attributes
|
||||
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};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -70,31 +56,7 @@ FTermXTerminal::FTermXTerminal()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
FTermXTerminal::~FTermXTerminal() // destructor
|
||||
{
|
||||
if ( highlight_background_color )
|
||||
delete highlight_background_color;
|
||||
|
||||
if ( mouse_background_color )
|
||||
delete mouse_background_color;
|
||||
|
||||
if ( mouse_foreground_color )
|
||||
delete mouse_foreground_color;
|
||||
|
||||
if ( cursor_color )
|
||||
delete cursor_color;
|
||||
|
||||
if ( background_color )
|
||||
delete background_color;
|
||||
|
||||
if ( foreground_color )
|
||||
delete foreground_color;
|
||||
|
||||
if ( xterm_title )
|
||||
delete xterm_title;
|
||||
|
||||
if ( xterm_font )
|
||||
delete xterm_font;
|
||||
}
|
||||
{ }
|
||||
|
||||
|
||||
// public methods of FTermXTerminal
|
||||
|
@ -112,10 +74,7 @@ void FTermXTerminal::setFont (const FString& fontname)
|
|||
{
|
||||
// Change the XTerm font (needs the allowFontOps resource)
|
||||
|
||||
if ( xterm_font )
|
||||
delete xterm_font;
|
||||
|
||||
xterm_font = new FString(fontname);
|
||||
xterm_font = fontname;
|
||||
setXTermFont();
|
||||
}
|
||||
|
||||
|
@ -124,10 +83,7 @@ void FTermXTerminal::setTitle (const FString& title)
|
|||
{
|
||||
// Set the xterm title
|
||||
|
||||
if ( xterm_title )
|
||||
delete xterm_title;
|
||||
|
||||
xterm_title = new FString(title);
|
||||
xterm_title = title;
|
||||
setXTermTitle();
|
||||
}
|
||||
|
||||
|
@ -146,10 +102,7 @@ void FTermXTerminal::setForeground (const FString& fg)
|
|||
{
|
||||
// Set the XTerm text foreground color
|
||||
|
||||
if ( foreground_color )
|
||||
delete foreground_color;
|
||||
|
||||
foreground_color = new FString(fg);
|
||||
foreground_color = fg;
|
||||
setXTermForeground();
|
||||
}
|
||||
|
||||
|
@ -158,10 +111,7 @@ void FTermXTerminal::setBackground (const FString& bg)
|
|||
{
|
||||
// Set the XTerm text background color
|
||||
|
||||
if ( background_color )
|
||||
delete background_color;
|
||||
|
||||
background_color = new FString(bg);
|
||||
background_color = bg;
|
||||
setXTermBackground();
|
||||
}
|
||||
|
||||
|
@ -170,10 +120,7 @@ void FTermXTerminal::setCursorColor (const FString& cc)
|
|||
{
|
||||
// Set the text cursor color
|
||||
|
||||
if ( cursor_color )
|
||||
delete cursor_color;
|
||||
|
||||
cursor_color = new FString(cc);
|
||||
cursor_color = cc;
|
||||
setXTermCursorColor();
|
||||
}
|
||||
|
||||
|
@ -182,10 +129,7 @@ void FTermXTerminal::setMouseForeground (const FString& mfg)
|
|||
{
|
||||
// Set the mouse foreground color
|
||||
|
||||
if ( mouse_foreground_color )
|
||||
delete mouse_foreground_color;
|
||||
|
||||
mouse_foreground_color = new FString(mfg);
|
||||
mouse_foreground_color = mfg;
|
||||
setXTermMouseForeground();
|
||||
}
|
||||
|
||||
|
@ -194,10 +138,7 @@ void FTermXTerminal::setMouseBackground (const FString& mbg)
|
|||
{
|
||||
// Set the mouse background color
|
||||
|
||||
if ( mouse_background_color )
|
||||
delete mouse_background_color;
|
||||
|
||||
mouse_background_color = new FString(mbg);
|
||||
mouse_background_color = mbg;
|
||||
setXTermMouseBackground();
|
||||
}
|
||||
|
||||
|
@ -206,10 +147,7 @@ void FTermXTerminal::setHighlightBackground (const FString& hbg)
|
|||
{
|
||||
// Set the highlight background color
|
||||
|
||||
if ( highlight_background_color )
|
||||
delete highlight_background_color;
|
||||
|
||||
highlight_background_color = new FString(hbg);
|
||||
highlight_background_color = hbg;
|
||||
setXTermHighlightBackground();
|
||||
}
|
||||
|
||||
|
@ -266,10 +204,7 @@ void FTermXTerminal::resetForeground()
|
|||
{
|
||||
// Reset the XTerm text foreground color
|
||||
|
||||
if ( foreground_color )
|
||||
delete foreground_color;
|
||||
|
||||
foreground_color = nullptr;
|
||||
foreground_color.clear();
|
||||
resetXTermForeground();
|
||||
}
|
||||
|
||||
|
@ -278,10 +213,7 @@ void FTermXTerminal::resetBackground()
|
|||
{
|
||||
// Reset the XTerm text background color
|
||||
|
||||
if ( background_color )
|
||||
delete background_color;
|
||||
|
||||
background_color = nullptr;
|
||||
background_color.clear();
|
||||
resetXTermBackground();
|
||||
}
|
||||
|
||||
|
@ -290,10 +222,7 @@ void FTermXTerminal::resetCursorColor()
|
|||
{
|
||||
// Reset the text cursor color
|
||||
|
||||
if ( cursor_color )
|
||||
delete cursor_color;
|
||||
|
||||
cursor_color = nullptr;
|
||||
cursor_color.clear();
|
||||
resetXTermCursorColor();
|
||||
}
|
||||
|
||||
|
@ -302,10 +231,7 @@ void FTermXTerminal::resetMouseForeground()
|
|||
{
|
||||
// Reset the mouse foreground color
|
||||
|
||||
if ( mouse_foreground_color )
|
||||
delete mouse_foreground_color;
|
||||
|
||||
mouse_foreground_color = nullptr;
|
||||
mouse_foreground_color.clear();
|
||||
resetXTermMouseForeground();
|
||||
}
|
||||
|
||||
|
@ -314,10 +240,7 @@ void FTermXTerminal::resetMouseBackground()
|
|||
{
|
||||
// Reset the mouse background color
|
||||
|
||||
if ( mouse_background_color )
|
||||
delete mouse_background_color;
|
||||
|
||||
mouse_background_color = nullptr;
|
||||
mouse_background_color.clear();
|
||||
resetXTermMouseBackground();
|
||||
}
|
||||
|
||||
|
@ -326,10 +249,7 @@ void FTermXTerminal::resetHighlightBackground()
|
|||
{
|
||||
// Reset the highlight background color
|
||||
|
||||
if ( highlight_background_color )
|
||||
delete highlight_background_color;
|
||||
|
||||
highlight_background_color = nullptr;
|
||||
highlight_background_color.clear();
|
||||
resetXTermHighlightBackground();
|
||||
}
|
||||
|
||||
|
@ -364,12 +284,6 @@ void FTermXTerminal::captureFontAndTitle()
|
|||
|| term_detection->isUrxvtTerminal() )
|
||||
&& ! term_detection->isRxvtTerminal() )
|
||||
{
|
||||
if ( xterm_font )
|
||||
delete xterm_font;
|
||||
|
||||
if ( xterm_title )
|
||||
delete xterm_title;
|
||||
|
||||
FTermios::setCaptureSendCharacters();
|
||||
xterm_font = captureXTermFont();
|
||||
xterm_title = captureXTermTitle();
|
||||
|
@ -420,7 +334,7 @@ void FTermXTerminal::setXTermTitle()
|
|||
|| FTermcap::osc_support )
|
||||
{
|
||||
oscPrefix();
|
||||
FTerm::putstringf (OSC "0;%s" BEL, xterm_title->c_str());
|
||||
FTerm::putstringf (OSC "0;%s" BEL, xterm_title.c_str());
|
||||
oscPostfix();
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
@ -449,7 +363,7 @@ void FTermXTerminal::setXTermFont()
|
|||
|| FTermcap::osc_support )
|
||||
{
|
||||
oscPrefix();
|
||||
FTerm::putstringf (OSC "50;%s" BEL, xterm_font->c_str() );
|
||||
FTerm::putstringf (OSC "50;%s" BEL, xterm_font.c_str() );
|
||||
oscPostfix();
|
||||
}
|
||||
}
|
||||
|
@ -466,7 +380,7 @@ void FTermXTerminal::setXTermForeground()
|
|||
|| FTermcap::osc_support )
|
||||
{
|
||||
oscPrefix();
|
||||
FTerm::putstringf (OSC "10;%s" BEL, foreground_color->c_str());
|
||||
FTerm::putstringf (OSC "10;%s" BEL, foreground_color.c_str());
|
||||
oscPostfix();
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
@ -484,7 +398,7 @@ void FTermXTerminal::setXTermBackground()
|
|||
|| FTermcap::osc_support )
|
||||
{
|
||||
oscPrefix();
|
||||
FTerm::putstringf (OSC "11;%s" BEL, background_color->c_str());
|
||||
FTerm::putstringf (OSC "11;%s" BEL, background_color.c_str());
|
||||
oscPostfix();
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
@ -502,7 +416,7 @@ void FTermXTerminal::setXTermCursorColor()
|
|||
|| FTermcap::osc_support )
|
||||
{
|
||||
oscPrefix();
|
||||
FTerm::putstringf (OSC "12;%s" BEL, cursor_color->c_str());
|
||||
FTerm::putstringf (OSC "12;%s" BEL, cursor_color.c_str());
|
||||
oscPostfix();
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
@ -519,7 +433,7 @@ void FTermXTerminal::setXTermMouseForeground()
|
|||
|| FTermcap::osc_support )
|
||||
{
|
||||
oscPrefix();
|
||||
FTerm::putstringf (OSC "13;%s" BEL, mouse_foreground_color->c_str());
|
||||
FTerm::putstringf (OSC "13;%s" BEL, mouse_foreground_color.c_str());
|
||||
oscPostfix();
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
@ -535,7 +449,7 @@ void FTermXTerminal::setXTermMouseBackground()
|
|||
|| FTermcap::osc_support )
|
||||
{
|
||||
oscPrefix();
|
||||
FTerm::putstringf (OSC "14;%s" BEL, mouse_background_color->c_str());
|
||||
FTerm::putstringf (OSC "14;%s" BEL, mouse_background_color.c_str());
|
||||
oscPostfix();
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
@ -552,7 +466,7 @@ void FTermXTerminal::setXTermHighlightBackground()
|
|||
|| FTermcap::osc_support )
|
||||
{
|
||||
oscPrefix();
|
||||
FTerm::putstringf (OSC "17;%s" BEL, highlight_background_color->c_str());
|
||||
FTerm::putstringf (OSC "17;%s" BEL, highlight_background_color.c_str());
|
||||
oscPostfix();
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
@ -769,7 +683,7 @@ void FTermXTerminal::oscPostfix()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString* FTermXTerminal::captureXTermFont()
|
||||
const FString FTermXTerminal::captureXTermFont()
|
||||
{
|
||||
if ( term_detection->isXTerminal()
|
||||
|| term_detection->isScreenTerm()
|
||||
|
@ -796,36 +710,25 @@ const FString* FTermXTerminal::captureXTermFont()
|
|||
|
||||
if ( std::scanf("\033]50;%148[^\n]s", temp) == 1 )
|
||||
{
|
||||
FString* xtermfont;
|
||||
std::size_t n = std::strlen(temp);
|
||||
|
||||
// BEL + '\0' = string terminator
|
||||
if ( n >= 5 && temp[n - 1] == BEL[0] && temp[n] == '\0' )
|
||||
temp[n - 1] = '\0';
|
||||
|
||||
try
|
||||
{
|
||||
xtermfont = new FString(temp);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return xtermfont;
|
||||
return FString(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return FString{};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString* FTermXTerminal::captureXTermTitle()
|
||||
const FString FTermXTerminal::captureXTermTitle()
|
||||
{
|
||||
if ( term_detection->isKdeTerminal() )
|
||||
return 0;
|
||||
return FString{};
|
||||
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
|
@ -851,29 +754,16 @@ const FString* FTermXTerminal::captureXTermTitle()
|
|||
// Esc + \ = OSC string terminator
|
||||
if ( n >= 2 && temp[n - 2] == ESC[0] && temp[n - 1] == '\\' )
|
||||
{
|
||||
FString* xtermtitle;
|
||||
|
||||
if ( n < 4 )
|
||||
return 0;
|
||||
return FString{};
|
||||
|
||||
temp[n - 2] = '\0';
|
||||
|
||||
try
|
||||
{
|
||||
xtermtitle = new FString(temp);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return xtermtitle;
|
||||
return FString{temp};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return FString{};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -882,7 +772,7 @@ void FTermXTerminal::enableXTermMouse()
|
|||
// Activate the xterm mouse support
|
||||
|
||||
if ( mouse_support )
|
||||
return;
|
||||
return; // The mouse is already activated
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
@ -902,7 +792,7 @@ void FTermXTerminal::disableXTermMouse()
|
|||
// Deactivate the xterm mouse support
|
||||
|
||||
if ( ! mouse_support )
|
||||
return;
|
||||
return; // The mouse was already deactivated
|
||||
|
||||
FTerm::putstring (CSI "?1006l" // disable SGR mouse mode
|
||||
CSI "?1015l" // disable urxvt mouse mode
|
||||
|
|
|
@ -20,11 +20,6 @@
|
|||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
#include "final/fconfig.h" // includes _GNU_SOURCE for wcwidth()
|
||||
#endif
|
||||
|
||||
#include <wchar.h>
|
||||
#include <memory>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
|
@ -65,30 +60,28 @@ const FString FTextView::getText() const
|
|||
return FString("");
|
||||
|
||||
std::size_t len{0};
|
||||
std::size_t rows = getRows();
|
||||
|
||||
for (std::size_t i{0} ; i < rows; i++)
|
||||
len += data[i].getLength() + 1;
|
||||
for (auto&& line : data)
|
||||
len += line.getLength() + 1; // String length + '\n'
|
||||
|
||||
FString s(len + 1);
|
||||
std::size_t idx{0};
|
||||
FString s(len); // Reserves storage
|
||||
auto iter = s.begin();
|
||||
|
||||
for (std::size_t i{0}; i < rows; i++)
|
||||
for (auto&& line : data)
|
||||
{
|
||||
const wchar_t* p = data[i].wc_str();
|
||||
|
||||
if ( p )
|
||||
if ( ! line.isEmpty() )
|
||||
{
|
||||
while ( (s[idx++] = *p++) != 0 );
|
||||
s[idx - 1] = '\n';
|
||||
if ( iter != s.begin() )
|
||||
{
|
||||
*iter = '\n';
|
||||
++iter;
|
||||
}
|
||||
else
|
||||
{
|
||||
s[idx++] = '\n';
|
||||
|
||||
std::copy (line.begin(), line.end(), iter);
|
||||
iter += std::distance(line.begin(), line.end());
|
||||
}
|
||||
}
|
||||
|
||||
s[idx - 1] = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -241,7 +234,7 @@ void FTextView::insert (const FString& str, int pos)
|
|||
hbar->setPageSize (int(maxLineWidth), int(getTextWidth()));
|
||||
hbar->calculateSliderValues();
|
||||
|
||||
if ( isShown() && ! hbar->isShown() )
|
||||
if ( isShown() && isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
}
|
||||
}
|
||||
|
@ -256,10 +249,10 @@ void FTextView::insert (const FString& str, int pos)
|
|||
vbar->setPageSize (int(getRows()), int(getTextHeight()));
|
||||
vbar->calculateSliderValues();
|
||||
|
||||
if ( isShown() && ! vbar->isShown() && getRows() > getTextHeight() )
|
||||
if ( isShown() && ! vbar->isShown() && isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
|
||||
if ( isShown() && vbar->isShown() && getRows() <= getTextHeight() )
|
||||
if ( isShown() && vbar->isShown() && ! isVerticallyScrollable() )
|
||||
vbar->hide();
|
||||
|
||||
processChanged();
|
||||
|
@ -297,69 +290,42 @@ void FTextView::clear()
|
|||
|
||||
// clear list from screen
|
||||
setColor();
|
||||
|
||||
|
||||
if ( useFDialogBorder() )
|
||||
{
|
||||
auto parent = getParentWidget();
|
||||
|
||||
if ( parent )
|
||||
static_cast<FDialog*>(parent)->redraw();
|
||||
}
|
||||
else
|
||||
drawBorder();
|
||||
|
||||
std::size_t size = getWidth() - 2;
|
||||
|
||||
if ( size == 0 )
|
||||
return;
|
||||
|
||||
char* blank = createBlankArray(size + 1);
|
||||
|
||||
for (int y{0}; y < int(getTextHeight()); y++)
|
||||
{
|
||||
print() << FPoint(2, 2 - nf_offset + y) << blank;
|
||||
print() << FPoint(2, 2 - nf_offset + y)
|
||||
<< FString(size, L' ');
|
||||
}
|
||||
|
||||
destroyBlankArray (blank);
|
||||
updateTerminal();
|
||||
processChanged();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::onKeyPress (FKeyEvent* ev)
|
||||
{
|
||||
switch ( ev->key() )
|
||||
int idx = int(ev->key());
|
||||
|
||||
if ( key_map.find(idx) != key_map.end() )
|
||||
{
|
||||
case fc::Fkey_up:
|
||||
scrollBy (0, -1);
|
||||
key_map[idx]();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_down:
|
||||
scrollBy (0, 1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_left:
|
||||
scrollBy (-1, 0);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
scrollBy (1, 0);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_ppage:
|
||||
scrollBy (0, int(-getTextHeight()));
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_npage:
|
||||
scrollBy (0, int(getTextHeight()));
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_home:
|
||||
scrollToY (0);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_end:
|
||||
scrollToY (int(getRows() - getTextHeight()));
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -566,15 +532,15 @@ void FTextView::adjustSize()
|
|||
|
||||
if ( isShown() )
|
||||
{
|
||||
if ( last_line < int(height) + nf_offset - 1 )
|
||||
vbar->hide();
|
||||
else
|
||||
vbar->show();
|
||||
|
||||
if ( max_width < int(width) - nf_offset - 1 )
|
||||
hbar->hide();
|
||||
else
|
||||
if ( isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
else
|
||||
hbar->hide();
|
||||
|
||||
if ( isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
else
|
||||
vbar->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -595,8 +561,8 @@ std::size_t FTextView::getTextWidth()
|
|||
//----------------------------------------------------------------------
|
||||
void FTextView::init()
|
||||
{
|
||||
initScrollbar (vbar, fc::vertical, &FTextView::cb_VBarChange);
|
||||
initScrollbar (hbar, fc::horizontal, &FTextView::cb_HBarChange);
|
||||
initScrollbar (vbar, fc::vertical, this, &FTextView::cb_VBarChange);
|
||||
initScrollbar (hbar, fc::horizontal, this, &FTextView::cb_HBarChange);
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
|
@ -605,75 +571,28 @@ void FTextView::init()
|
|||
setLeftPadding(1);
|
||||
setBottomPadding(1);
|
||||
setRightPadding(1 + nf_offset);
|
||||
mapKeyFunctions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::initScrollbar ( FScrollbarPtr& bar
|
||||
, fc::orientation o
|
||||
, FTextViewCallback callback )
|
||||
inline void FTextView::mapKeyFunctions()
|
||||
{
|
||||
try
|
||||
{
|
||||
bar = std::make_shared<FScrollbar>(o, this);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
bar->setMinimum(0);
|
||||
bar->setValue(0);
|
||||
bar->hide();
|
||||
|
||||
bar->addCallback
|
||||
(
|
||||
"change-value",
|
||||
F_METHOD_CALLBACK (this, callback)
|
||||
);
|
||||
key_map[fc::Fkey_up] = [&] { scrollBy (0, -1); };
|
||||
key_map[fc::Fkey_down] = [&] { scrollBy (0, 1); };
|
||||
key_map[fc::Fkey_left] = [&] { scrollBy (-1, 0); };
|
||||
key_map[fc::Fkey_right] = [&] { scrollBy (1, 0); };
|
||||
key_map[fc::Fkey_ppage] = [&] { scrollBy (0, int(-getTextHeight())); };
|
||||
key_map[fc::Fkey_npage] = [&] { scrollBy (0, int(getTextHeight())); };
|
||||
key_map[fc::Fkey_home] = [&] { scrollToY (0); };
|
||||
key_map[fc::Fkey_end] = [&] { scrollToY (int(getRows() - getTextHeight())); };
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::draw()
|
||||
{
|
||||
auto parent = getParentWidget();
|
||||
bool is_text_dialog;
|
||||
setColor();
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( parent
|
||||
&& parent->isDialogWidget()
|
||||
&& isPaddingIgnored()
|
||||
&& getGeometry() == FRect ( 1
|
||||
, 2
|
||||
, parent->getWidth()
|
||||
, parent->getHeight() - 1) )
|
||||
{
|
||||
is_text_dialog = true;
|
||||
}
|
||||
else
|
||||
is_text_dialog = false;
|
||||
|
||||
if ( ! (is_text_dialog || isNewFont()) )
|
||||
drawBorder();
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
if ( ! isShown() ) // first drawing
|
||||
{
|
||||
vbar->show();
|
||||
hbar->show();
|
||||
}
|
||||
|
||||
if ( vbar->isShown() )
|
||||
vbar->redraw();
|
||||
|
||||
if ( hbar->isShown() )
|
||||
hbar->redraw();
|
||||
|
||||
drawScrollbars();
|
||||
drawText();
|
||||
|
||||
if ( hasFocus() && getStatusBar() )
|
||||
|
@ -690,7 +609,36 @@ void FTextView::draw()
|
|||
|
||||
setCursorPos (FPoint(int(getWidth()), int(getHeight())));
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::drawBorder()
|
||||
{
|
||||
if ( ! useFDialogBorder() )
|
||||
{
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
FWidget::drawBorder();
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::drawScrollbars()
|
||||
{
|
||||
if ( ! hbar->isShown() && isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
else
|
||||
vbar->redraw();
|
||||
|
||||
if ( ! vbar->isShown() && isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
else
|
||||
hbar->redraw();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -721,7 +669,9 @@ void FTextView::drawText()
|
|||
|
||||
for (auto&& ch : line) // Column loop
|
||||
{
|
||||
if ( isPrintable(ch) )
|
||||
if ( getColumnWidth(ch) == 0 )
|
||||
continue;
|
||||
else if ( isPrintable(ch) )
|
||||
print (ch);
|
||||
else
|
||||
print ('.');
|
||||
|
@ -737,6 +687,26 @@ void FTextView::drawText()
|
|||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTextView::useFDialogBorder()
|
||||
{
|
||||
auto parent = getParentWidget();
|
||||
bool use_fdialog_border{false};
|
||||
|
||||
if ( parent
|
||||
&& parent->isDialogWidget()
|
||||
&& isPaddingIgnored()
|
||||
&& getGeometry() == FRect ( 1
|
||||
, 2
|
||||
, parent->getWidth()
|
||||
, parent->getHeight() - 1) )
|
||||
{
|
||||
use_fdialog_border = true;
|
||||
}
|
||||
|
||||
return use_fdialog_border;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTextView::isPrintable (wchar_t ch)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fbuttongroup.h"
|
||||
#include "final/fevent.h"
|
||||
|
@ -233,7 +235,7 @@ void FToggleButton::onMouseDown (FMouseEvent* ev)
|
|||
{
|
||||
getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,7 +312,7 @@ void FToggleButton::onAccel (FAccelEvent* ev)
|
|||
{
|
||||
getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
processClick();
|
||||
|
@ -370,25 +372,7 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev)
|
|||
//----------------------------------------------------------------------
|
||||
void FToggleButton::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)) )
|
||||
{
|
||||
addAccelerator (FKey(std::tolower(int(hotkey))));
|
||||
addAccelerator (FKey(std::toupper(int(hotkey))));
|
||||
// Meta + hotkey
|
||||
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
|
||||
}
|
||||
else
|
||||
addAccelerator (hotkey);
|
||||
}
|
||||
else
|
||||
delAccelerator();
|
||||
setHotkeyViaString (this, text);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -429,34 +413,14 @@ void FToggleButton::draw()
|
|||
//----------------------------------------------------------------------
|
||||
void FToggleButton::drawLabel()
|
||||
{
|
||||
wchar_t* LabelText;
|
||||
|
||||
if ( text.isNull() || text.isEmpty() )
|
||||
return;
|
||||
|
||||
std::size_t length = text.getLength();
|
||||
|
||||
try
|
||||
{
|
||||
LabelText = new wchar_t[length + 1]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
FString txt(text);
|
||||
wchar_t* src = const_cast<wchar_t*>(txt.wc_str());
|
||||
wchar_t* dest = const_cast<wchar_t*>(LabelText);
|
||||
auto hotkeypos = finalcut::getHotkeyPos(src, dest, length);
|
||||
|
||||
if ( hotkeypos != NOT_SET )
|
||||
length--;
|
||||
|
||||
FString label_text{};
|
||||
auto hotkeypos = finalcut::getHotkeyPos(txt, label_text);
|
||||
print() << FPoint(1 + int(label_offset_pos), 1);
|
||||
drawText (LabelText, hotkeypos, length);
|
||||
delete[] LabelText;
|
||||
drawText (std::move(label_text), hotkeypos);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -561,9 +525,7 @@ void FToggleButton::init()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FToggleButton::drawText ( wchar_t LabelText[]
|
||||
, std::size_t hotkeypos
|
||||
, std::size_t length )
|
||||
void FToggleButton::drawText (FString&& label_text, std::size_t hotkeypos)
|
||||
{
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
@ -575,7 +537,7 @@ void FToggleButton::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 < label_text.getLength(); z++)
|
||||
{
|
||||
if ( (z == hotkeypos) && flags.active )
|
||||
{
|
||||
|
@ -584,7 +546,7 @@ void FToggleButton::drawText ( wchar_t LabelText[]
|
|||
if ( ! flags.no_underline )
|
||||
setUnderline();
|
||||
|
||||
print ( LabelText[z] );
|
||||
print ( label_text[z] );
|
||||
|
||||
if ( ! flags.no_underline )
|
||||
unsetUnderline();
|
||||
|
@ -592,7 +554,7 @@ void FToggleButton::drawText ( wchar_t LabelText[]
|
|||
setColor (wc.label_fg, wc.label_bg);
|
||||
}
|
||||
else
|
||||
print (LabelText[z]);
|
||||
print (label_text[z]);
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
|
|
|
@ -80,10 +80,6 @@ void FToolTip::draw()
|
|||
{
|
||||
int y{0};
|
||||
setColor();
|
||||
|
||||
if ( getMaxColor() < 16 )
|
||||
setBold();
|
||||
|
||||
clearArea();
|
||||
drawBorder();
|
||||
|
||||
|
@ -92,8 +88,6 @@ void FToolTip::draw()
|
|||
print() << FPoint(3, 2 + y) << line;
|
||||
y++;
|
||||
}
|
||||
|
||||
unsetBold();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
1711
src/fvterm.cpp
1711
src/fvterm.cpp
File diff suppressed because it is too large
Load Diff
700
src/fwidget.cpp
700
src/fwidget.cpp
|
@ -43,10 +43,10 @@ FStatusBar* FWidget::statusbar{nullptr};
|
|||
FMenuBar* FWidget::menubar{nullptr};
|
||||
FWidget* FWidget::show_root_widget{nullptr};
|
||||
FWidget* FWidget::redraw_root_widget{nullptr};
|
||||
FWidget::widgetList* FWidget::window_list{nullptr};
|
||||
FWidget::widgetList* FWidget::dialog_list{nullptr};
|
||||
FWidget::widgetList* FWidget::always_on_top_list{nullptr};
|
||||
FWidget::widgetList* FWidget::close_widget{nullptr};
|
||||
FWidget::FWidgetList* FWidget::window_list{nullptr};
|
||||
FWidget::FWidgetList* FWidget::dialog_list{nullptr};
|
||||
FWidget::FWidgetList* FWidget::always_on_top_list{nullptr};
|
||||
FWidget::FWidgetList* FWidget::close_widget{nullptr};
|
||||
FWidgetColors FWidget::wcolors{};
|
||||
bool FWidget::init_desktop{false};
|
||||
bool FWidget::hideable{false};
|
||||
|
@ -170,9 +170,8 @@ FWidget* FWidget::getFirstFocusableWidget (FObjectList list)
|
|||
return 0;
|
||||
|
||||
auto iter = list.begin();
|
||||
auto last = list.end();
|
||||
|
||||
while ( iter != last )
|
||||
while ( iter != list.end() )
|
||||
{
|
||||
if ( (*iter)->isWidget() )
|
||||
{
|
||||
|
@ -194,7 +193,6 @@ FWidget* FWidget::getLastFocusableWidget (FObjectList list)
|
|||
if ( list.empty() )
|
||||
return 0;
|
||||
|
||||
auto first = list.begin();
|
||||
auto iter = list.end();
|
||||
|
||||
do
|
||||
|
@ -209,19 +207,11 @@ FWidget* FWidget::getLastFocusableWidget (FObjectList list)
|
|||
if ( child->isEnabled() && child->acceptFocus() )
|
||||
return child;
|
||||
}
|
||||
while ( iter != first );
|
||||
while ( iter != list.begin() );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FPoint FWidget::getPrintPos()
|
||||
{
|
||||
const auto cur = getPrintCursor();
|
||||
return FPoint ( cur.getX() - woffset.getX1() - getX() + 1
|
||||
, cur.getY() - woffset.getY1() - getY() + 1 );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::vector<bool>& FWidget::doubleFlatLine_ref (fc::sides side)
|
||||
{
|
||||
|
@ -248,6 +238,14 @@ std::vector<bool>& FWidget::doubleFlatLine_ref (fc::sides side)
|
|||
return double_flatline_mask.left;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FPoint FWidget::getPrintPos()
|
||||
{
|
||||
const auto cur = getPrintCursor();
|
||||
return FPoint ( cur.getX() - woffset.getX1() - getX() + 1
|
||||
, cur.getY() - woffset.getY1() - getY() + 1 );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::setMainWidget (FWidget* obj)
|
||||
{
|
||||
|
@ -757,33 +755,25 @@ void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FWidget* FWidget::childWidgetAt (FWidget* p, const FPoint& pos)
|
||||
FWidget* FWidget::childWidgetAt (const FPoint& pos)
|
||||
{
|
||||
if ( p && p->hasChildren() )
|
||||
{
|
||||
auto iter = p->begin();
|
||||
auto last = p->end();
|
||||
if ( ! hasChildren() )
|
||||
return 0;
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& child : getChildren())
|
||||
{
|
||||
if ( ! (*iter)->isWidget() )
|
||||
{
|
||||
++iter;
|
||||
if ( ! child->isWidget() )
|
||||
continue;
|
||||
}
|
||||
|
||||
auto widget = static_cast<FWidget*>(*iter);
|
||||
auto widget = static_cast<FWidget*>(child);
|
||||
|
||||
if ( widget->isEnabled()
|
||||
&& widget->isShown()
|
||||
&& ! widget->isWindowWidget()
|
||||
&& widget->getTermGeometry().contains(pos) )
|
||||
{
|
||||
auto child = childWidgetAt(widget, pos);
|
||||
return ( child != 0 ) ? child : widget;
|
||||
}
|
||||
|
||||
++iter;
|
||||
auto sub_child = widget->childWidgetAt(pos);
|
||||
return ( sub_child != 0 ) ? sub_child : widget;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -797,22 +787,18 @@ int FWidget::numOfFocusableChildren()
|
|||
return 0;
|
||||
|
||||
int num{0};
|
||||
auto iter = FObject::begin();
|
||||
auto last = FObject::end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& child : getChildren())
|
||||
{
|
||||
if ( (*iter)->isWidget() )
|
||||
if ( child->isWidget() )
|
||||
{
|
||||
auto widget = static_cast<FWidget*>(*iter);
|
||||
auto widget = static_cast<FWidget*>(child);
|
||||
|
||||
if ( widget->isShown()
|
||||
&& widget->acceptFocus()
|
||||
&& ! widget->isWindowWidget() )
|
||||
num++;
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
return num;
|
||||
|
@ -821,6 +807,8 @@ int FWidget::numOfFocusableChildren()
|
|||
//----------------------------------------------------------------------
|
||||
bool FWidget::close()
|
||||
{
|
||||
// Sends a close event and quits the application on acceptance
|
||||
|
||||
FCloseEvent ev(fc::Close_Event);
|
||||
FApplication::sendEvent(this, &ev);
|
||||
|
||||
|
@ -844,29 +832,31 @@ bool FWidget::close()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::addCallback ( const FString& cb_signal
|
||||
, FCallback cb_handler
|
||||
, FCallback cb_function
|
||||
, FDataPtr data )
|
||||
{
|
||||
// add a (normal) function pointer as callback
|
||||
callback_data obj{ cb_signal, cb_handler, data };
|
||||
// Add a (normal) function pointer as callback
|
||||
|
||||
FCallbackData obj{ cb_signal, nullptr, cb_function, data };
|
||||
callback_objects.push_back(obj);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::addCallback ( const FString& cb_signal
|
||||
, FWidget* cb_instance
|
||||
, FMemberCallback cb_handler
|
||||
, FCallback cb_function
|
||||
, FDataPtr data )
|
||||
{
|
||||
// add a member function pointer as callback
|
||||
member_callback_data obj{ cb_signal, cb_instance, cb_handler, data };
|
||||
member_callback_objects.push_back(obj);
|
||||
// Add a member function pointer as callback
|
||||
|
||||
FCallbackData obj{ cb_signal, cb_instance, cb_function, data };
|
||||
callback_objects.push_back(obj);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::delCallback (FCallback cb_handler)
|
||||
void FWidget::delCallback (FCallback cb_function)
|
||||
{
|
||||
// delete a cb_handler function pointer
|
||||
// Delete cb_function form callback list
|
||||
|
||||
if ( callback_objects.empty() )
|
||||
return;
|
||||
|
@ -875,7 +865,7 @@ void FWidget::delCallback (FCallback cb_handler)
|
|||
|
||||
while ( iter != callback_objects.end() )
|
||||
{
|
||||
if ( iter->cb_handler == cb_handler )
|
||||
if ( getCallbackPtr(iter->cb_function) == getCallbackPtr(cb_function) )
|
||||
iter = callback_objects.erase(iter);
|
||||
else
|
||||
++iter;
|
||||
|
@ -885,17 +875,17 @@ void FWidget::delCallback (FCallback cb_handler)
|
|||
//----------------------------------------------------------------------
|
||||
void FWidget::delCallback (FWidget* cb_instance)
|
||||
{
|
||||
// delete all member function pointer from cb_instance
|
||||
// Delete all member function pointer from cb_instance
|
||||
|
||||
if ( member_callback_objects.empty() )
|
||||
if ( callback_objects.empty() )
|
||||
return;
|
||||
|
||||
auto iter = member_callback_objects.begin();
|
||||
auto iter = callback_objects.begin();
|
||||
|
||||
while ( iter != member_callback_objects.end() )
|
||||
while ( iter != callback_objects.end() )
|
||||
{
|
||||
if ( iter->cb_instance == cb_instance )
|
||||
iter = member_callback_objects.erase(iter);
|
||||
iter = callback_objects.erase(iter);
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
|
@ -904,51 +894,26 @@ void FWidget::delCallback (FWidget* cb_instance)
|
|||
//----------------------------------------------------------------------
|
||||
void FWidget::delCallbacks()
|
||||
{
|
||||
// delete all callbacks from this widget
|
||||
// Delete all callbacks from this widget
|
||||
|
||||
member_callback_objects.clear(); // member function pointer
|
||||
callback_objects.clear(); // function pointer
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::emitCallback (const FString& emit_signal)
|
||||
{
|
||||
// member function pointer
|
||||
// Initiate callback for the given signal
|
||||
|
||||
if ( ! member_callback_objects.empty() )
|
||||
{
|
||||
auto m_iter = member_callback_objects.begin();
|
||||
auto m_end = member_callback_objects.end();
|
||||
if ( callback_objects.empty() )
|
||||
return;
|
||||
|
||||
while ( m_iter != m_end )
|
||||
for (auto&& cback : callback_objects)
|
||||
{
|
||||
if ( m_iter->cb_signal == emit_signal )
|
||||
if ( cback.cb_signal == emit_signal )
|
||||
{
|
||||
auto callback = m_iter->cb_handler;
|
||||
// call the member function pointer
|
||||
(m_iter->cb_instance->*callback) (this, m_iter->data);
|
||||
}
|
||||
|
||||
++m_iter;
|
||||
}
|
||||
}
|
||||
|
||||
// function pointer
|
||||
if ( ! callback_objects.empty() )
|
||||
{
|
||||
auto iter = callback_objects.begin();
|
||||
auto last = callback_objects.end();
|
||||
|
||||
while ( iter != last )
|
||||
{
|
||||
if ( iter->cb_signal == emit_signal )
|
||||
{
|
||||
auto callback = iter->cb_handler;
|
||||
// call the function pointer
|
||||
callback (this, iter->data);
|
||||
}
|
||||
|
||||
++iter;
|
||||
// Calling the stored function pointer
|
||||
auto callback = cback.cb_function;
|
||||
callback (this, cback.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -956,8 +921,10 @@ void FWidget::emitCallback (const FString& emit_signal)
|
|||
//----------------------------------------------------------------------
|
||||
void FWidget::addAccelerator (FKey key, FWidget* obj)
|
||||
{
|
||||
// Adding a keyboard accelerator for the given widget
|
||||
|
||||
auto widget = static_cast<FWidget*>(FWindow::getWindowWidget(obj));
|
||||
accelerator accel = { key, obj };
|
||||
FAccelerator accel = { key, obj };
|
||||
|
||||
if ( ! widget || widget == statusbar || widget == menubar )
|
||||
widget = getRootWidget();
|
||||
|
@ -969,6 +936,8 @@ void FWidget::addAccelerator (FKey key, FWidget* obj)
|
|||
//----------------------------------------------------------------------
|
||||
void FWidget::delAccelerator (FWidget* obj)
|
||||
{
|
||||
// Deletes all accelerators of the given widget
|
||||
|
||||
auto widget = static_cast<FWidget*>(FWindow::getWindowWidget(this));
|
||||
|
||||
if ( ! widget || widget == statusbar || widget == menubar )
|
||||
|
@ -993,6 +962,8 @@ void FWidget::delAccelerator (FWidget* obj)
|
|||
//----------------------------------------------------------------------
|
||||
void FWidget::redraw()
|
||||
{
|
||||
// Redraw the widget immediately unless it is hidden.
|
||||
|
||||
if ( ! redraw_root_widget )
|
||||
redraw_root_widget = this;
|
||||
|
||||
|
@ -1019,7 +990,7 @@ void FWidget::redraw()
|
|||
if ( redraw_root_widget == this )
|
||||
{
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
redraw_root_widget = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -1054,6 +1025,8 @@ void FWidget::resize()
|
|||
//----------------------------------------------------------------------
|
||||
void FWidget::show()
|
||||
{
|
||||
// Make the widget visible and draw it
|
||||
|
||||
if ( ! isVisible() )
|
||||
return;
|
||||
|
||||
|
@ -1081,20 +1054,15 @@ void FWidget::show()
|
|||
|
||||
if ( hasChildren() )
|
||||
{
|
||||
auto iter = FObject::begin();
|
||||
auto last = FObject::end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& child : getChildren())
|
||||
{
|
||||
if ( (*iter)->isWidget() )
|
||||
if ( child->isWidget() )
|
||||
{
|
||||
auto widget = static_cast<FWidget*>(*iter);
|
||||
auto widget = static_cast<FWidget*>(child);
|
||||
|
||||
if ( ! widget->flags.hidden )
|
||||
widget->show();
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1102,7 +1070,7 @@ void FWidget::show()
|
|||
{
|
||||
finishTerminalUpdate();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
show_root_widget = nullptr;
|
||||
}
|
||||
|
||||
|
@ -1113,6 +1081,8 @@ void FWidget::show()
|
|||
//----------------------------------------------------------------------
|
||||
void FWidget::hide()
|
||||
{
|
||||
// Hide the widget
|
||||
|
||||
flags.hidden = true;
|
||||
|
||||
if ( isVisible() )
|
||||
|
@ -1214,22 +1184,6 @@ bool FWidget::focusLastChild()
|
|||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::detectTermSize()
|
||||
{
|
||||
auto r = rootObject;
|
||||
FTerm::detectTermSize();
|
||||
r->adjust_wsize.setRect (1, 1, getDesktopWidth(), getDesktopHeight());
|
||||
r->woffset.setRect (0, 0, getDesktopWidth(), getDesktopHeight());
|
||||
r->wclient_offset.setCoordinates
|
||||
(
|
||||
r->padding.left,
|
||||
r->padding.top,
|
||||
int(getDesktopWidth()) - 1 - r->padding.right,
|
||||
int(getDesktopHeight()) - 1 - r->padding.bottom
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::move (const FPoint& pos)
|
||||
{
|
||||
|
@ -1237,201 +1191,6 @@ void FWidget::move (const FPoint& pos)
|
|||
adjust_wsize.move(pos);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::drawShadow()
|
||||
{
|
||||
if ( isMonochron() && ! flags.trans_shadow )
|
||||
return;
|
||||
|
||||
if ( (getEncoding() == fc::VT100 && ! flags.trans_shadow)
|
||||
|| (getEncoding() == fc::ASCII && ! flags.trans_shadow) )
|
||||
{
|
||||
clearShadow();
|
||||
return;
|
||||
}
|
||||
|
||||
int x1 = 1;
|
||||
int x2 = int(getWidth());
|
||||
int y1 = 1;
|
||||
int y2 = int(getHeight());
|
||||
|
||||
if ( flags.trans_shadow )
|
||||
{
|
||||
// transparent shadow
|
||||
drawTransparentShadow (x1, y1, x2, y2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// non-transparent shadow
|
||||
drawBlockShadow (x1, y1, x2, y2);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::clearShadow()
|
||||
{
|
||||
if ( isMonochron() )
|
||||
return;
|
||||
|
||||
int w = int(getWidth());
|
||||
int h = int(getHeight());
|
||||
|
||||
if ( isWindowWidget() )
|
||||
{
|
||||
setColor (wcolors.shadow_fg, wcolors.shadow_bg);
|
||||
setInheritBackground(); // current background color will be ignored
|
||||
}
|
||||
else if ( auto p = getParentWidget() )
|
||||
setColor (wcolors.shadow_fg, p->getBackgroundColor());
|
||||
|
||||
if ( w <= woffset.getX2() )
|
||||
{
|
||||
for (std::size_t y{1}; y <= getHeight(); y++)
|
||||
{
|
||||
print() << FPoint(w + 1, int(y)) << ' '; // clear █
|
||||
}
|
||||
}
|
||||
|
||||
if ( h <= woffset.getY2() )
|
||||
{
|
||||
print() << FPoint(2, h + 1);
|
||||
|
||||
for (std::size_t i{1}; i <= getWidth(); i++)
|
||||
print (' '); // clear ▀
|
||||
}
|
||||
|
||||
if ( isWindowWidget() )
|
||||
unsetInheritBackground();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::drawFlatBorder()
|
||||
{
|
||||
if ( ! isNewFont() )
|
||||
return;
|
||||
|
||||
int x1 = 1;
|
||||
int x2 = int(getWidth() + 1);
|
||||
int y1 = 0;
|
||||
int y2 = int(getHeight() + 1);
|
||||
|
||||
if ( auto p = getParentWidget() )
|
||||
setColor (wcolors.dialog_fg, p->getBackgroundColor());
|
||||
else
|
||||
setColor (wcolors.dialog_fg, wcolors.dialog_bg);
|
||||
|
||||
for (std::size_t y{0}; y < getHeight(); y++)
|
||||
{
|
||||
print() << FPoint(x1 - 1, y1 + int(y) + 1);
|
||||
|
||||
if ( double_flatline_mask.left[uLong(y)] )
|
||||
// left+right line (on left side)
|
||||
print (fc::NF_rev_border_line_right_and_left);
|
||||
else
|
||||
// right line (on left side)
|
||||
print (fc::NF_rev_border_line_right);
|
||||
}
|
||||
|
||||
print() << FPoint(x2, y1 + 1);
|
||||
|
||||
for (std::size_t y{0}; y < getHeight(); y++)
|
||||
{
|
||||
if ( double_flatline_mask.right[y] )
|
||||
// left+right line (on right side)
|
||||
print (fc::NF_rev_border_line_right_and_left);
|
||||
else
|
||||
// left line (on right side)
|
||||
print (fc::NF_border_line_left);
|
||||
|
||||
print() << FPoint(x2, y1 + int(y) + 2);
|
||||
}
|
||||
|
||||
print() << FPoint(x1, y1);
|
||||
|
||||
for (std::size_t x{0}; x < getWidth(); x++)
|
||||
{
|
||||
if ( double_flatline_mask.top[x] )
|
||||
// top+bottom line (at top)
|
||||
print (fc::NF_border_line_up_and_down);
|
||||
else
|
||||
// bottom line (at top)
|
||||
print (fc::NF_border_line_bottom);
|
||||
}
|
||||
|
||||
print() << FPoint(x1, y2);
|
||||
|
||||
for (std::size_t x{0}; x < getWidth(); x++)
|
||||
{
|
||||
if ( double_flatline_mask.bottom[x] )
|
||||
// top+bottom line (at bottom)
|
||||
print (fc::NF_border_line_up_and_down);
|
||||
else
|
||||
// top line (at bottom)
|
||||
print (fc::NF_border_line_upper);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::clearFlatBorder()
|
||||
{
|
||||
if ( ! isNewFont() )
|
||||
return;
|
||||
|
||||
int x1 = 1;
|
||||
int x2 = int(getWidth() + 1);
|
||||
int y1 = 0;
|
||||
int y2 = int(getHeight() + 1);
|
||||
|
||||
if ( auto p = getParentWidget() )
|
||||
setColor (wcolors.dialog_fg, p->getBackgroundColor());
|
||||
else
|
||||
setColor (wcolors.dialog_fg, wcolors.dialog_bg);
|
||||
|
||||
// clear on left side
|
||||
for (std::size_t y{0}; y < getHeight(); y++)
|
||||
{
|
||||
print() << FPoint(x1 - 1, y1 + int(y) + 1);
|
||||
|
||||
if ( double_flatline_mask.left[y] )
|
||||
print (fc::NF_border_line_left);
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
|
||||
// clear on right side
|
||||
for (std::size_t y{0}; y < getHeight(); y++)
|
||||
{
|
||||
print() << FPoint(x2, y1 + int(y) + 1);
|
||||
|
||||
if ( double_flatline_mask.right[y] )
|
||||
print (fc::NF_rev_border_line_right);
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
|
||||
// clear at top
|
||||
print() << FPoint(x1, y1);
|
||||
|
||||
for (std::size_t x{0}; x < getWidth(); x++)
|
||||
{
|
||||
if ( double_flatline_mask.top[x] )
|
||||
print (fc::NF_border_line_upper);
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
|
||||
// clear at bottom
|
||||
print() << FPoint(x1, y2);
|
||||
|
||||
for (std::size_t x{0}; x < getWidth(); x++)
|
||||
{
|
||||
if ( double_flatline_mask.bottom[x] )
|
||||
print (fc::NF_border_line_bottom);
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::quit()
|
||||
{
|
||||
|
@ -1442,7 +1201,7 @@ void FWidget::quit()
|
|||
|
||||
// protected methods of FWidget
|
||||
//----------------------------------------------------------------------
|
||||
FVTerm::term_area* FWidget::getPrintArea()
|
||||
FVTerm::FTermArea* FWidget::getPrintArea()
|
||||
{
|
||||
// returns the print area of this object
|
||||
|
||||
|
@ -1477,12 +1236,12 @@ FVTerm::term_area* FWidget::getPrintArea()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::addPreprocessingHandler ( FVTerm* instance
|
||||
, FPreprocessingHandler handler )
|
||||
, FPreprocessingFunction function )
|
||||
{
|
||||
if ( ! getCurrentPrintArea() )
|
||||
FWidget::getPrintArea();
|
||||
|
||||
FVTerm::addPreprocessingHandler (instance, handler);
|
||||
FVTerm::addPreprocessingHandler (instance, function);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1572,19 +1331,15 @@ void FWidget::adjustSize()
|
|||
|
||||
if ( hasChildren() )
|
||||
{
|
||||
auto iter = FObject::begin();
|
||||
auto last = FObject::end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& child : getChildren())
|
||||
{
|
||||
if ( (*iter)->isWidget() )
|
||||
if ( child->isWidget() )
|
||||
{
|
||||
auto widget = static_cast<FWidget*>(*iter);
|
||||
auto widget = static_cast<FWidget*>(child);
|
||||
|
||||
if ( ! widget->isWindowWidget() )
|
||||
widget->adjustSize();
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1626,18 +1381,16 @@ void FWidget::hideArea (const FSize& size)
|
|||
}
|
||||
|
||||
setColor (fg, bg);
|
||||
char* blank = createBlankArray(size.getWidth());
|
||||
|
||||
if ( blank == 0 )
|
||||
if ( size.getWidth() == 0 )
|
||||
return;
|
||||
|
||||
for (int y{0}; y < int(size.getHeight()); y++)
|
||||
{
|
||||
print() << FPoint(1, 1 + y) << blank;
|
||||
print() << FPoint(1, 1 + y) << FString(size.getWidth(), L' ');
|
||||
}
|
||||
|
||||
destroyBlankArray (blank);
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1647,7 +1400,7 @@ void FWidget::createWidgetAcceleratorList()
|
|||
{
|
||||
try
|
||||
{
|
||||
accelerator_list = new Accelerators();
|
||||
accelerator_list = new FAcceleratorList();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
|
@ -1948,10 +1701,10 @@ void FWidget::init()
|
|||
try
|
||||
{
|
||||
// Initialize widget lists
|
||||
window_list = new widgetList();
|
||||
dialog_list = new widgetList();
|
||||
always_on_top_list = new widgetList();
|
||||
close_widget = new widgetList();
|
||||
window_list = new FWidgetList();
|
||||
dialog_list = new FWidgetList();
|
||||
always_on_top_list = new FWidgetList();
|
||||
close_widget = new FWidgetList();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
|
@ -2118,6 +1871,12 @@ void FWidget::KeyDownEvent (FKeyEvent* kev)
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FWidget::FCallbackPtr FWidget::getCallbackPtr (FCallback cb_function)
|
||||
{
|
||||
return *cb_function.template target<FCallbackPtr>();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FWidget::changeFocus ( FWidget* follower, FWidget* parent
|
||||
, fc::FocusTypes ft )
|
||||
|
@ -2152,7 +1911,7 @@ bool FWidget::changeFocus ( FWidget* follower, FWidget* parent
|
|||
redraw();
|
||||
follower->redraw();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
flushOutputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2167,8 +1926,8 @@ void FWidget::draw()
|
|||
void FWidget::drawWindows()
|
||||
{
|
||||
// redraw windows
|
||||
charData default_char{};
|
||||
default_char.code = ' ';
|
||||
FChar default_char{};
|
||||
default_char.ch = ' ';
|
||||
default_char.fg_color = fc::Black;
|
||||
default_char.bg_color = fc::Black;
|
||||
default_char.attr.byte[0] = 0;
|
||||
|
@ -2177,22 +1936,16 @@ void FWidget::drawWindows()
|
|||
if ( ! window_list || window_list->empty() )
|
||||
return;
|
||||
|
||||
auto iter = window_list->begin();
|
||||
auto last = window_list->end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& window : *window_list)
|
||||
{
|
||||
if ( (*iter)->isShown() )
|
||||
if ( window->isShown() )
|
||||
{
|
||||
auto win = (*iter)->getVWin();
|
||||
int w = win->width + win->right_shadow;
|
||||
int h = win->height + win->bottom_shadow;
|
||||
std::fill_n (win->text, w * h, default_char);
|
||||
|
||||
(*iter)->redraw();
|
||||
auto v_win = window->getVWin();
|
||||
int w = v_win->width + v_win->right_shadow;
|
||||
int h = v_win->height + v_win->bottom_shadow;
|
||||
std::fill_n (v_win->data, w * h, default_char);
|
||||
window->redraw();
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2203,99 +1956,18 @@ void FWidget::drawChildren()
|
|||
if ( ! hasChildren() )
|
||||
return;
|
||||
|
||||
auto iter = FObject::begin();
|
||||
auto last = FObject::end();
|
||||
|
||||
while ( iter != last )
|
||||
for (auto&& child : getChildren())
|
||||
{
|
||||
if ( (*iter)->isWidget() )
|
||||
if ( child->isWidget() )
|
||||
{
|
||||
auto widget = static_cast<FWidget*>(*iter);
|
||||
auto widget = static_cast<FWidget*>(child);
|
||||
|
||||
if ( widget->isShown() && ! widget->isWindowWidget() )
|
||||
widget->redraw();
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
|
||||
{
|
||||
// transparent shadow
|
||||
|
||||
setTransparent();
|
||||
print() << FPoint(x2 + 1, y1) << " ";
|
||||
unsetTransparent();
|
||||
|
||||
setColor (wcolors.shadow_bg, wcolors.shadow_fg);
|
||||
setTransShadow();
|
||||
|
||||
for (std::size_t y{1}; y < getHeight(); y++)
|
||||
{
|
||||
print() << FPoint(x2 + 1, y1 + int(y)) << " ";
|
||||
}
|
||||
|
||||
unsetTransShadow();
|
||||
setTransparent();
|
||||
print() << FPoint(x1, y2 + 1) << " ";
|
||||
unsetTransparent();
|
||||
|
||||
setColor (wcolors.shadow_bg, wcolors.shadow_fg);
|
||||
setTransShadow();
|
||||
|
||||
for (std::size_t x{2}; x <= getWidth() + 1; x++)
|
||||
print (' ');
|
||||
|
||||
unsetTransShadow();
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
|
||||
{
|
||||
// non-transparent shadow
|
||||
wchar_t block;
|
||||
|
||||
if ( ! hasShadowCharacter() )
|
||||
return;
|
||||
|
||||
print() << FPoint(x2 + 1, y1);
|
||||
|
||||
if ( isWindowWidget() )
|
||||
{
|
||||
setColor (wcolors.shadow_fg, wcolors.shadow_bg);
|
||||
setInheritBackground(); // current background color will be ignored
|
||||
}
|
||||
else if ( auto p = getParentWidget() )
|
||||
setColor (wcolors.shadow_fg, p->getBackgroundColor());
|
||||
|
||||
block = fc::FullBlock; // █
|
||||
print (fc::LowerHalfBlock); // ▄
|
||||
|
||||
if ( isWindowWidget() )
|
||||
unsetInheritBackground();
|
||||
|
||||
for (std::size_t y{1}; y < getHeight(); y++)
|
||||
{
|
||||
print() << FPoint(x2 + 1, y1 + int(y)) << block; // █
|
||||
}
|
||||
|
||||
print() << FPoint(x1 + 1, y2 + 1);
|
||||
|
||||
if ( isWindowWidget() )
|
||||
setInheritBackground();
|
||||
|
||||
for (std::size_t x{1}; x <= getWidth(); x++)
|
||||
print (fc::UpperHalfBlock); // ▀
|
||||
|
||||
if ( isWindowWidget() )
|
||||
unsetInheritBackground();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::setColorTheme()
|
||||
{
|
||||
|
@ -2310,163 +1982,19 @@ void FWidget::setColorTheme()
|
|||
|
||||
// non-member functions
|
||||
//----------------------------------------------------------------------
|
||||
char* createBlankArray (std::size_t size)
|
||||
void detectTermSize()
|
||||
{
|
||||
char* blank;
|
||||
|
||||
if ( size == 0 )
|
||||
return 0;
|
||||
|
||||
try
|
||||
{
|
||||
blank = new char[size + 1];
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::memset(blank, ' ', size);
|
||||
blank[size] = '\0';
|
||||
return blank;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void destroyBlankArray (char blank[])
|
||||
{
|
||||
delete[] blank;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FKey getHotkey (const FString& text)
|
||||
{
|
||||
if ( text.isEmpty() )
|
||||
return 0;
|
||||
|
||||
std::size_t length = text.getLength();
|
||||
|
||||
for (std::size_t i{0}; i < length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( i + 1 < length && text[i] == '&' )
|
||||
return FKey(text[++i]);
|
||||
}
|
||||
catch (const std::out_of_range&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getHotkeyPos (wchar_t src[], wchar_t dest[], std::size_t length)
|
||||
{
|
||||
// Find hotkey position in string
|
||||
// + generate a new string without the '&'-sign
|
||||
const wchar_t* txt = src;
|
||||
constexpr std::size_t NOT_SET = static_cast<std::size_t>(-1);
|
||||
std::size_t hotkeypos{NOT_SET};
|
||||
|
||||
for (std::size_t i{0}; i < length; i++)
|
||||
{
|
||||
if ( txt[i] == L'&' && hotkeypos == NOT_SET )
|
||||
{
|
||||
hotkeypos = i;
|
||||
i++;
|
||||
src++;
|
||||
}
|
||||
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
return hotkeypos;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void drawBox (FWidget* w, const FRect& r)
|
||||
{
|
||||
// Use box-drawing characters to draw a border
|
||||
|
||||
w->print() << r.getUpperLeftPos() << fc::BoxDrawingsDownAndRight; // ┌
|
||||
|
||||
for (int x = r.getX1() + 1; x < r.getX2(); x++)
|
||||
w->print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
w->print (fc::BoxDrawingsDownAndLeft); // ┐
|
||||
|
||||
for (int y = r.getY1() + 1; y < r.getY2(); y++)
|
||||
{
|
||||
w->print() << FPoint(r.getX1(), y)
|
||||
<< fc::BoxDrawingsVertical // │
|
||||
<< FPoint(r.getX2(), y)
|
||||
<< fc::BoxDrawingsVertical; // │
|
||||
}
|
||||
|
||||
w->print() << r.getLowerLeftPos() << fc::BoxDrawingsUpAndRight; // └
|
||||
|
||||
for (int x = r.getX1() + 1; x < r.getX2(); x++)
|
||||
w->print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
w->print (fc::BoxDrawingsUpAndLeft); // ┘
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void drawNewFontBox (FWidget* w, const FRect& r)
|
||||
{
|
||||
// Use new graphical font characters to draw a border
|
||||
|
||||
w->print() << r.getUpperLeftPos()
|
||||
<< fc::NF_border_corner_middle_upper_left; // ┌
|
||||
for (int x = r.getX1() + 1; x < r.getX2(); x++)
|
||||
w->print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
w->print (fc::NF_border_corner_middle_upper_right); // ┐
|
||||
|
||||
for (int y = r.getY1() + 1; y < r.getY2(); y++)
|
||||
{
|
||||
w->print() << FPoint(r.getX1(), y)
|
||||
<< fc::NF_border_line_left // border left ⎸
|
||||
<< FPoint(r.getX2(), y)
|
||||
<< fc::NF_rev_border_line_right; // border right⎹
|
||||
}
|
||||
|
||||
w->print() << r.getLowerLeftPos()
|
||||
<< fc::NF_border_corner_middle_lower_left; // └
|
||||
|
||||
for (int x = r.getX1() + 1; x < r.getX2(); x++)
|
||||
w->print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
w->print (fc::NF_border_corner_middle_lower_right); // ┘
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void drawBorder (FWidget* w, FRect r)
|
||||
{
|
||||
if ( r.x1_ref() > r.x2_ref() )
|
||||
std::swap (r.x1_ref(), r.x2_ref());
|
||||
|
||||
if ( r.y1_ref() > r.y2_ref() )
|
||||
std::swap (r.y1_ref(), r.y2_ref());
|
||||
|
||||
if ( r.x1_ref() < 1 )
|
||||
r.x1_ref() = 1;
|
||||
|
||||
if ( r.y1_ref() < 1 )
|
||||
r.y1_ref() = 1;
|
||||
|
||||
if ( r.x2_ref() > int(w->getWidth()) )
|
||||
r.x2_ref() = int(w->getWidth());
|
||||
|
||||
if ( r.y2_ref() > int(w->getHeight()) )
|
||||
r.y2_ref() = int(w->getHeight());
|
||||
|
||||
if ( w->isNewFont() )
|
||||
drawNewFontBox (w, r);
|
||||
else
|
||||
drawBox (w, r);
|
||||
auto r = rootObject;
|
||||
FTerm::detectTermSize();
|
||||
r->adjust_wsize.setRect (1, 1, r->getDesktopWidth(), r->getDesktopHeight());
|
||||
r->woffset.setRect (0, 0, r->getDesktopWidth(), r->getDesktopHeight());
|
||||
r->wclient_offset.setCoordinates
|
||||
(
|
||||
r->padding.left,
|
||||
r->padding.top,
|
||||
int(r->getDesktopWidth()) - 1 - r->padding.right,
|
||||
int(r->getDesktopHeight()) - 1 - r->padding.bottom
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
|
|
@ -0,0 +1,428 @@
|
|||
/***********************************************************************
|
||||
* fwidget_functions.cpp - FWidget helper functions *
|
||||
* *
|
||||
* 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/fwidget.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// FWidget non-member functions
|
||||
//----------------------------------------------------------------------
|
||||
FKey getHotkey (const FString& text)
|
||||
{
|
||||
// Returns the hotkey character from a string
|
||||
// e.g. "E&xit" returns 'x'
|
||||
|
||||
if ( text.isEmpty() )
|
||||
return 0;
|
||||
|
||||
std::size_t length = text.getLength();
|
||||
|
||||
for (std::size_t i{0}; i < length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( i + 1 < length && text[i] == '&' )
|
||||
return FKey(text[++i]);
|
||||
}
|
||||
catch (const std::out_of_range&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getHotkeyPos (const FString& src, FString& dest)
|
||||
{
|
||||
// Find hotkey position in string
|
||||
// + generate a new string without the '&'-sign
|
||||
|
||||
constexpr std::size_t NOT_SET = static_cast<std::size_t>(-1);
|
||||
std::size_t hotkeypos{NOT_SET};
|
||||
std::size_t i{0};
|
||||
|
||||
for (auto&& ch : src)
|
||||
{
|
||||
if ( ch == L'&' && hotkeypos == NOT_SET && src.getLength() != i + 1 )
|
||||
hotkeypos = i;
|
||||
else
|
||||
dest += ch;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return hotkeypos;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void setHotkeyViaString (FWidget* w, const FString& text)
|
||||
{
|
||||
// Set hotkey accelerator via string
|
||||
|
||||
if ( ! w )
|
||||
return;
|
||||
|
||||
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)) )
|
||||
{
|
||||
w->addAccelerator (FKey(std::tolower(int(hotkey))));
|
||||
w->addAccelerator (FKey(std::toupper(int(hotkey))));
|
||||
// Meta + hotkey
|
||||
w->addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
|
||||
}
|
||||
else
|
||||
w->addAccelerator (hotkey);
|
||||
}
|
||||
else
|
||||
w->delAccelerator();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void drawShadow (FWidget* w)
|
||||
{
|
||||
if ( w->isMonochron() && ! w->flags.trans_shadow )
|
||||
return;
|
||||
|
||||
if ( (w->getEncoding() == fc::VT100 && ! w->flags.trans_shadow)
|
||||
|| (w->getEncoding() == fc::ASCII && ! w->flags.trans_shadow) )
|
||||
{
|
||||
clearShadow(w);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( w->flags.trans_shadow )
|
||||
drawTransparentShadow (w); // transparent shadow
|
||||
else
|
||||
drawBlockShadow (w); // non-transparent shadow
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void drawTransparentShadow (FWidget* w)
|
||||
{
|
||||
// transparent shadow
|
||||
|
||||
std::size_t width = w->getWidth();
|
||||
std::size_t height = w->getHeight();
|
||||
w->setTransparent();
|
||||
w->print() << FPoint(int(width) + 1, 1) << " ";
|
||||
w->unsetTransparent();
|
||||
w->setColor (w->wcolors.shadow_bg, w->wcolors.shadow_fg);
|
||||
w->setTransShadow();
|
||||
|
||||
for (std::size_t y{1}; y < height; y++)
|
||||
{
|
||||
w->print() << FPoint(int(width) + 1, int(y) + 1) << " ";
|
||||
}
|
||||
|
||||
w->unsetTransShadow();
|
||||
w->setTransparent();
|
||||
w->print() << FPoint(1, int(height) + 1) << " ";
|
||||
w->unsetTransparent();
|
||||
w->setColor (w->wcolors.shadow_bg, w->wcolors.shadow_fg);
|
||||
w->setTransShadow();
|
||||
w->print() << FString(width, L' ');
|
||||
|
||||
w->unsetTransShadow();
|
||||
|
||||
if ( w->isMonochron() )
|
||||
w->setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void drawBlockShadow (FWidget* w)
|
||||
{
|
||||
// non-transparent shadow
|
||||
|
||||
if ( ! w->hasShadowCharacter() )
|
||||
return;
|
||||
|
||||
std::size_t width = w->getWidth();
|
||||
std::size_t height = w->getHeight();
|
||||
w->print() << FPoint(int(width) + 1, 1);
|
||||
|
||||
if ( w->isWindowWidget() )
|
||||
{
|
||||
w->setColor (w->wcolors.shadow_fg, w->wcolors.shadow_bg);
|
||||
w->setInheritBackground(); // current background color will be ignored
|
||||
}
|
||||
else if ( auto p = w->getParentWidget() )
|
||||
w->setColor (w->wcolors.shadow_fg, p->getBackgroundColor());
|
||||
|
||||
w->print (fc::LowerHalfBlock); // ▄
|
||||
|
||||
if ( w->isWindowWidget() )
|
||||
w->unsetInheritBackground();
|
||||
|
||||
for (std::size_t y{1}; y < height; y++)
|
||||
{
|
||||
w->print() << FPoint(int(width) + 1, int(y) + 1) << fc::FullBlock; // █
|
||||
}
|
||||
|
||||
w->print() << FPoint(2, int(height) + 1);
|
||||
|
||||
if ( w->isWindowWidget() )
|
||||
w->setInheritBackground();
|
||||
|
||||
w->print() << FString(width, fc::UpperHalfBlock); // ▀
|
||||
|
||||
if ( w->isWindowWidget() )
|
||||
w->unsetInheritBackground();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void clearShadow (FWidget* w)
|
||||
{
|
||||
if ( w->isMonochron() )
|
||||
return;
|
||||
|
||||
std::size_t width = w->getWidth();
|
||||
std::size_t height = w->getHeight();
|
||||
|
||||
if ( w->isWindowWidget() )
|
||||
{
|
||||
w->setColor (w->wcolors.shadow_fg, w->wcolors.shadow_bg);
|
||||
w->setInheritBackground(); // current background color will be ignored
|
||||
}
|
||||
else if ( auto p = w->getParentWidget() )
|
||||
w->setColor (w->wcolors.shadow_fg, p->getBackgroundColor());
|
||||
|
||||
if ( int(width) <= w->woffset.getX2() )
|
||||
{
|
||||
for (std::size_t y{1}; y <= height; y++)
|
||||
{
|
||||
w->print() << FPoint(int(width) + 1, int(y)) << ' '; // clear █
|
||||
}
|
||||
}
|
||||
|
||||
if ( int(height) <= w->woffset.getY2() )
|
||||
{
|
||||
w->print() << FPoint(2, int(height) + 1)
|
||||
<< FString(width, L' '); // clear ▀
|
||||
}
|
||||
|
||||
if ( w->isWindowWidget() )
|
||||
w->unsetInheritBackground();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void drawFlatBorder (FWidget* w)
|
||||
{
|
||||
if ( ! w->isNewFont() )
|
||||
return;
|
||||
|
||||
if ( auto p = w->getParentWidget() )
|
||||
w->setColor (w->wcolors.dialog_fg, p->getBackgroundColor());
|
||||
else
|
||||
w->setColor (w->wcolors.dialog_fg, w->wcolors.dialog_bg);
|
||||
|
||||
std::size_t width = w->getWidth();
|
||||
std::size_t height = w->getHeight();
|
||||
|
||||
for (std::size_t y{0}; y < height; y++)
|
||||
{
|
||||
w->print() << FPoint(0, int(y) + 1);
|
||||
|
||||
if ( w->double_flatline_mask.left[uLong(y)] )
|
||||
// left+right line (on left side)
|
||||
w->print (fc::NF_rev_border_line_right_and_left);
|
||||
else
|
||||
// right line (on left side)
|
||||
w->print (fc::NF_rev_border_line_right);
|
||||
|
||||
w->print() << FPoint(int(width) + 1, int(y) + 1);
|
||||
|
||||
if ( w->double_flatline_mask.right[y] )
|
||||
// left+right line (on right side)
|
||||
w->print (fc::NF_rev_border_line_right_and_left);
|
||||
else
|
||||
// left line (on right side)
|
||||
w->print (fc::NF_border_line_left);
|
||||
}
|
||||
|
||||
w->print() << FPoint(1, 0);
|
||||
|
||||
for (std::size_t x{0}; x < width; x++)
|
||||
{
|
||||
if ( w->double_flatline_mask.top[x] )
|
||||
// top+bottom line (at top)
|
||||
w->print (fc::NF_border_line_up_and_down);
|
||||
else
|
||||
// bottom line (at top)
|
||||
w->print (fc::NF_border_line_bottom);
|
||||
}
|
||||
|
||||
w->print() << FPoint(1, int(height) + 1);
|
||||
|
||||
for (std::size_t x{0}; x < width; x++)
|
||||
{
|
||||
if ( w->double_flatline_mask.bottom[x] )
|
||||
// top+bottom line (at bottom)
|
||||
w->print (fc::NF_border_line_up_and_down);
|
||||
else
|
||||
// top line (at bottom)
|
||||
w->print (fc::NF_border_line_upper);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void clearFlatBorder (FWidget* w)
|
||||
{
|
||||
if ( ! w->isNewFont() )
|
||||
return;
|
||||
|
||||
if ( auto p = w->getParentWidget() )
|
||||
w->setColor (w->wcolors.dialog_fg, p->getBackgroundColor());
|
||||
else
|
||||
w->setColor (w->wcolors.dialog_fg, w->wcolors.dialog_bg);
|
||||
|
||||
std::size_t width = w->getWidth();
|
||||
std::size_t height = w->getHeight();
|
||||
|
||||
for (std::size_t y{0}; y < height; y++)
|
||||
{
|
||||
// clear on left side
|
||||
w->print() << FPoint(0, int(y) + 1);
|
||||
|
||||
if ( w->double_flatline_mask.left[y] )
|
||||
w->print (fc::NF_border_line_left);
|
||||
else
|
||||
w->print (' ');
|
||||
|
||||
// clear on right side
|
||||
w->print() << FPoint(int(width) + 1, int(y) + 1);
|
||||
|
||||
if ( w->double_flatline_mask.right[y] )
|
||||
w->print (fc::NF_rev_border_line_right);
|
||||
else
|
||||
w->print (' ');
|
||||
}
|
||||
|
||||
// clear at top
|
||||
w->print() << FPoint(1, 0);
|
||||
|
||||
for (std::size_t x{0}; x < width; x++)
|
||||
{
|
||||
if ( w->double_flatline_mask.top[x] )
|
||||
w->print (fc::NF_border_line_upper);
|
||||
else
|
||||
w->print (' ');
|
||||
}
|
||||
|
||||
// clear at bottom
|
||||
w->print() << FPoint(1, int(height) + 1);
|
||||
|
||||
for (std::size_t x{0}; x < width; x++)
|
||||
{
|
||||
if ( w->double_flatline_mask.bottom[x] )
|
||||
w->print (fc::NF_border_line_bottom);
|
||||
else
|
||||
w->print (' ');
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void drawBorder (FWidget* w, FRect r)
|
||||
{
|
||||
if ( r.x1_ref() > r.x2_ref() )
|
||||
std::swap (r.x1_ref(), r.x2_ref());
|
||||
|
||||
if ( r.y1_ref() > r.y2_ref() )
|
||||
std::swap (r.y1_ref(), r.y2_ref());
|
||||
|
||||
if ( r.x1_ref() < 1 )
|
||||
r.x1_ref() = 1;
|
||||
|
||||
if ( r.y1_ref() < 1 )
|
||||
r.y1_ref() = 1;
|
||||
|
||||
if ( r.x2_ref() > int(w->getWidth()) )
|
||||
r.x2_ref() = int(w->getWidth());
|
||||
|
||||
if ( r.y2_ref() > int(w->getHeight()) )
|
||||
r.y2_ref() = int(w->getHeight());
|
||||
|
||||
if ( w->isNewFont() )
|
||||
drawNewFontBox (w, r);
|
||||
else
|
||||
drawBox (w, r);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void drawBox (FWidget* w, const FRect& r)
|
||||
{
|
||||
// Use box-drawing characters to draw a border
|
||||
|
||||
if ( ! w )
|
||||
return;
|
||||
|
||||
w->print() << r.getUpperLeftPos()
|
||||
<< fc::BoxDrawingsDownAndRight // ┌
|
||||
<< FString(r.getWidth() - 2, fc::BoxDrawingsHorizontal) // ─
|
||||
<< fc::BoxDrawingsDownAndLeft; // ┐
|
||||
|
||||
for (int y = r.getY1() + 1; y < r.getY2(); y++)
|
||||
{
|
||||
w->print() << FPoint(r.getX1(), y)
|
||||
<< fc::BoxDrawingsVertical // │
|
||||
<< FPoint(r.getX2(), y)
|
||||
<< fc::BoxDrawingsVertical; // │
|
||||
}
|
||||
|
||||
w->print() << r.getLowerLeftPos()
|
||||
<< fc::BoxDrawingsUpAndRight // └
|
||||
<< FString(r.getWidth() - 2, fc::BoxDrawingsHorizontal) // ─
|
||||
<< fc::BoxDrawingsUpAndLeft; // ┘
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void drawNewFontBox (FWidget* w, const FRect& r)
|
||||
{
|
||||
// Use new graphical font characters to draw a border
|
||||
|
||||
w->print() << r.getUpperLeftPos()
|
||||
<< fc::NF_border_corner_middle_upper_left // ┌
|
||||
<< FString(r.getWidth() - 2, fc::BoxDrawingsHorizontal) // ─
|
||||
<< fc::NF_border_corner_middle_upper_right; // ┐
|
||||
|
||||
for (int y = r.getY1() + 1; y < r.getY2(); y++)
|
||||
{
|
||||
w->print() << FPoint(r.getX1(), y)
|
||||
<< fc::NF_border_line_left // border left ⎸
|
||||
<< FPoint(r.getX2(), y)
|
||||
<< fc::NF_rev_border_line_right; // border right⎹
|
||||
}
|
||||
|
||||
w->print() << r.getLowerLeftPos()
|
||||
<< fc::NF_border_corner_middle_lower_left // └
|
||||
<< FString(r.getWidth() - 2, fc::BoxDrawingsHorizontal) // ─
|
||||
<< fc::NF_border_corner_middle_lower_right; // ┘
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
|
@ -48,7 +48,7 @@ void FWidgetColors::set8ColorTheme()
|
|||
error_box_fg = fc::Black;
|
||||
error_box_emphasis_fg = fc::Red;
|
||||
error_box_bg = fc::LightGray;
|
||||
tooltip_fg = fc::LightGray;
|
||||
tooltip_fg = fc::Black;
|
||||
tooltip_bg = fc::Cyan;
|
||||
shadow_fg = fc::Black;
|
||||
shadow_bg = fc::LightGray; // only for transparent shadow
|
||||
|
@ -75,8 +75,8 @@ void FWidgetColors::set8ColorTheme()
|
|||
inputfield_active_bg = fc::Cyan;
|
||||
inputfield_inactive_fg = fc::Black;
|
||||
inputfield_inactive_bg = fc::LightGray;
|
||||
toggle_button_active_focus_fg = fc::LightGray;
|
||||
toggle_button_active_focus_bg = fc::Red;
|
||||
toggle_button_active_focus_fg = fc::Black;
|
||||
toggle_button_active_focus_bg = fc::Cyan;
|
||||
toggle_button_active_fg = fc::Black;
|
||||
toggle_button_active_bg = fc::LightGray;
|
||||
toggle_button_inactive_fg = fc::Cyan;
|
||||
|
|
|
@ -107,18 +107,12 @@ void FWindow::setActiveWindow (FWindow* window)
|
|||
{
|
||||
// activate FWindow object window
|
||||
|
||||
if ( ! getWindowList() )
|
||||
if ( ! getWindowList() || getWindowList()->empty() )
|
||||
return;
|
||||
|
||||
if ( getWindowList()->empty() )
|
||||
return;
|
||||
|
||||
auto iter = getWindowList()->begin();
|
||||
auto end = getWindowList()->end();
|
||||
|
||||
while ( iter != end )
|
||||
for (auto&& win : *getWindowList())
|
||||
{
|
||||
if ( *iter == window )
|
||||
if ( win == window )
|
||||
{
|
||||
if ( ! window->isWindowActive() )
|
||||
{
|
||||
|
@ -129,17 +123,15 @@ void FWindow::setActiveWindow (FWindow* window)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto w = static_cast<FWindow*>(*iter);
|
||||
auto w = static_cast<FWindow*>(win);
|
||||
|
||||
if ( w->isWindowActive() )
|
||||
{
|
||||
w->deactivateWindow();
|
||||
FEvent ev(fc::WindowInactive_Event);
|
||||
FApplication::sendEvent(*iter, &ev);
|
||||
FApplication::sendEvent(win, &ev);
|
||||
}
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,11 +243,9 @@ void FWindow::drawBorder()
|
|||
{
|
||||
FRect r(FPoint(1, 1), getSize());
|
||||
print() << r.getUpperLeftPos()
|
||||
<< fc::NF_border_corner_upper_left; // ⎡
|
||||
for (int x = r.getX1() + 1; x < r.getX2(); x++)
|
||||
print (fc::NF_border_line_upper); // ¯
|
||||
|
||||
print (fc::NF_rev_border_corner_upper_right); // ⎤
|
||||
<< fc::NF_border_corner_upper_left // ⎡
|
||||
<< FString(r.getWidth() - 2, fc::NF_border_line_upper) // ¯
|
||||
<< fc::NF_rev_border_corner_upper_right; // ⎤
|
||||
|
||||
for (int y = r.getY1() + 1; y < r.getY2(); y++)
|
||||
{
|
||||
|
@ -265,14 +255,10 @@ void FWindow::drawBorder()
|
|||
<< fc::NF_rev_border_line_right; // border right⎹
|
||||
}
|
||||
|
||||
print() << r.getLowerLeftPos() // lower left corner border ⎣
|
||||
<< fc::NF_border_corner_lower_left;
|
||||
|
||||
for (int x = r.getX1() + 1; x < r.getX2(); x++)
|
||||
print (fc::NF_border_line_bottom); // low line _
|
||||
|
||||
// lower right corner border ⎦
|
||||
print (fc::NF_rev_border_corner_lower_right);
|
||||
print() << r.getLowerLeftPos()
|
||||
<< fc::NF_border_corner_lower_left // ⎣
|
||||
<< FString(r.getWidth() - 2, fc::NF_border_line_bottom) // _
|
||||
<< fc::NF_rev_border_corner_lower_right; // ⎦
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -107,7 +107,7 @@ class FApplication : public FWidget
|
|||
FApplication& operator = (const FApplication&) = delete;
|
||||
|
||||
// Accessors
|
||||
const char* getClassName() const override;
|
||||
const FString getClassName() const override;
|
||||
int getArgc() const;
|
||||
char** getArgv() const;
|
||||
static FApplication* getApplicationObject();
|
||||
|
@ -117,8 +117,8 @@ class FApplication : public FWidget
|
|||
|
||||
// Methods
|
||||
int exec(); // run
|
||||
int enter_loop();
|
||||
void exit_loop();
|
||||
int enterLoop();
|
||||
void exitLoop();
|
||||
static void exit (int = 0);
|
||||
void quit();
|
||||
static bool sendEvent (const FObject*, const FEvent*);
|
||||
|
@ -203,7 +203,7 @@ class FApplication : public FWidget
|
|||
|
||||
// FApplication inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FApplication::getClassName() const
|
||||
inline const FString FApplication::getClassName() const
|
||||
{ return "FApplication"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -82,7 +82,7 @@ class FButton : public FWidget
|
|||
FButton& operator = (const FString&);
|
||||
|
||||
// Accessors
|
||||
const char* getClassName() const override;
|
||||
const FString getClassName() const override;
|
||||
FString& getText();
|
||||
|
||||
// Mutators
|
||||
|
@ -149,7 +149,7 @@ class FButton : public FWidget
|
|||
void drawMarginLeft();
|
||||
void drawMarginRight();
|
||||
void drawTopBottomBackground();
|
||||
void drawButtonTextLine (wchar_t[]);
|
||||
void drawButtonTextLine (const FString&);
|
||||
void draw() override;
|
||||
void updateStatusBar();
|
||||
void updateButtonColor();
|
||||
|
@ -178,7 +178,7 @@ class FButton : public FWidget
|
|||
|
||||
// FButton inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FButton::getClassName() const
|
||||
inline const FString FButton::getClassName() const
|
||||
{ return "FButton"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -83,7 +83,7 @@ class FButtonGroup : public FScrollView
|
|||
FButtonGroup& operator = (const FButtonGroup&) = delete;
|
||||
|
||||
// Accessor
|
||||
const char* getClassName() const override;
|
||||
const FString getClassName() const override;
|
||||
FToggleButton* getFirstButton();
|
||||
FToggleButton* getLastButton();
|
||||
FToggleButton* getButton (int) const;
|
||||
|
@ -131,7 +131,7 @@ class FButtonGroup : public FScrollView
|
|||
|
||||
// Methods
|
||||
void init();
|
||||
void drawText (wchar_t[], std::size_t, std::size_t);
|
||||
void drawText (const FString&, std::size_t);
|
||||
void directFocus();
|
||||
|
||||
// Callback method
|
||||
|
@ -144,7 +144,7 @@ class FButtonGroup : public FScrollView
|
|||
|
||||
// FButtonGroup inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FButtonGroup::getClassName() const
|
||||
inline const FString FButtonGroup::getClassName() const
|
||||
{ return "FButtonGroup"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -42,10 +42,10 @@ extern const std::size_t lastCharItem;
|
|||
extern int vt100_key_to_utf8[][2];
|
||||
extern const std::size_t lastKeyItem;
|
||||
|
||||
extern wchar_t cp437_to_ucs[][2];
|
||||
extern wchar_t cp437_ucs[][2];
|
||||
extern const std::size_t lastCP437Item;
|
||||
|
||||
extern wchar_t halfWidth_fullWidth[][2];
|
||||
extern const wchar_t halfWidth_fullWidth[][2];
|
||||
extern const std::size_t lastHalfWidthItem;
|
||||
|
||||
} // namespace fc
|
||||
|
|
|
@ -83,7 +83,7 @@ class FCheckBox : public FToggleButton
|
|||
FCheckBox& operator = (const FCheckBox&) = delete;
|
||||
|
||||
// Accessor
|
||||
const char* getClassName() const override;
|
||||
const FString getClassName() const override;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
|
@ -96,7 +96,7 @@ class FCheckBox : public FToggleButton
|
|||
|
||||
// FCheckBox inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FCheckBox::getClassName() const
|
||||
inline const FString FCheckBox::getClassName() const
|
||||
{ return "FCheckBox"; }
|
||||
|
||||
} // namespace finalcut
|
||||
|
|
|
@ -83,7 +83,7 @@ class FCheckMenuItem : public FMenuItem
|
|||
FCheckMenuItem& operator = (const FCheckMenuItem&) = delete;
|
||||
|
||||
// Accessor
|
||||
const char* getClassName() const override;
|
||||
const FString getClassName() const override;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
|
@ -94,7 +94,7 @@ class FCheckMenuItem : public FMenuItem
|
|||
|
||||
// FCheckMenuItem inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FCheckMenuItem::getClassName() const
|
||||
inline const FString FCheckMenuItem::getClassName() const
|
||||
{ return "FCheckMenuItem"; }
|
||||
|
||||
} // namespace finalcut
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue