Internal redesign of the callback call

This commit is contained in:
Markus Gans 2019-10-05 23:20:07 +02:00
parent 298755a0fe
commit a279a0981a
109 changed files with 1240 additions and 1290 deletions

View File

@ -1,3 +1,8 @@
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> 2019-10-01 Markus Gans <guru.mail@muenster.de>
* Replacing null-terminated wide strings with FString objects * Replacing null-terminated wide strings with FString objects
* Fix for getColumnWidth() with newfont character * Fix for getColumnWidth() with newfont character

View File

@ -1,5 +1,4 @@
![FINAL CUT](logo/svg/finalcut-logo.svg) ![FINAL CUT](logo/svg/finalcut-logo.svg)
============================================
# Library for creating terminal applications with text-based widgets # Library for creating terminal applications with text-based widgets
The FINAL CUT is a C++ class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen. The 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. 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 ## Building and code analysis
*Latest release:*<br /> | | Badge |
&#160;&#160;&#160;&#160;&#160;[![Latest Release](https://img.shields.io/github/release/gansm/finalcut.svg)](https://github.com/gansm/finalcut/releases) <br /> |-------------------:|:------|
*License:*<br /> | *Latest release* | [![Latest Release](https://img.shields.io/github/release/gansm/finalcut.svg)](https://github.com/gansm/finalcut/releases) |
&#160;&#160;&#160;&#160;&#160;[![license](https://img.shields.io/github/license/gansm/finalcut.svg?colorA=#333)](COPYING) <br /> | *License* | [![license](https://img.shields.io/github/license/gansm/finalcut.svg?colorA=#333)](COPYING) |
*Travis CI:*<br /> | *Class Reference* | [![documented](https://codedocs.xyz/gansm/finalcut.svg)](https://codedocs.xyz/gansm/finalcut/hierarchy.html) |
&#160;&#160;&#160;&#160;&#160;[![Build Status](https://travis-ci.org/gansm/finalcut.svg?branch=master)](https://travis-ci.org/gansm/finalcut) <br /> | *Travis CI* | [![Build Status](https://travis-ci.org/gansm/finalcut.svg?branch=master)](https://travis-ci.org/gansm/finalcut)
*Coverity Scan:*<br /> |*Coverity Scan* | [![Coverity Scan Status](https://img.shields.io/coverity/scan/6508.svg)](https://scan.coverity.com/projects/6508 )|
&#160;&#160;&#160;&#160;&#160;[![Coverity Scan Status](https://img.shields.io/coverity/scan/6508.svg)](https://scan.coverity.com/projects/6508) <br /> | *LGTM* | [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/gansm/finalcut.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/gansm/finalcut/context:cpp) |
*LGTM:*<br /> | *CodeFactor* | [![CodeFactor](https://www.codefactor.io/repository/github/gansm/finalcut/badge)](https://www.codefactor.io/repository/github/gansm/finalcut) |
&#160;&#160;&#160;&#160;&#160;[![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 />
&#160;&#160;&#160;&#160;&#160;[![documented](https://codedocs.xyz/gansm/finalcut.svg)](https://codedocs.xyz/gansm/finalcut/hierarchy.html)
## Installation ## Installation
```bash ```bash
@ -40,7 +36,7 @@ The structure of the Qt framework was originally the inspiration for the C++ cla
* Solaris * Solaris
## First steps ## 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 ## Some screenshots

11
debian/40-finalcut-newfont.conf vendored Normal file
View File

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

3
debian/control vendored
View File

@ -19,7 +19,8 @@ Architecture: any
Pre-Depends: ${misc:Pre-Depends} Pre-Depends: ${misc:Pre-Depends}
Multi-Arch: same Multi-Arch: same
Depends: Depends:
${shlibs:Depends} xfonts-utils
, ${shlibs:Depends}
, ${misc:Depends} , ${misc:Depends}
Suggests: Suggests:
coreutils coreutils

View File

@ -30,3 +30,4 @@ doc/vt100_line_drawing_graphics.png
doc/virtual-terminal.txt doc/virtual-terminal.txt
doc/xterm.txt doc/xterm.txt
doc/xgraphics doc/xgraphics
fonts/newfont.txt

View File

@ -1,6 +1,5 @@
usr/lib/*/lib*.so usr/lib/*/lib*.so
usr/lib/*/lib*.so.* usr/lib/*/lib*.so.*
fonts/8x16graph.pcf.gz /usr/share/fonts/X11/misc/finalcut/ fonts/8x16graph.pcf.gz /usr/share/fonts/X11/misc/
fonts/fonts.alias /usr/share/fonts/X11/misc/finalcut/ fonts/xfonts-finalcut-newfont.alias /etc/X11/fonts/misc/
fonts/fonts.dir /usr/share/fonts/X11/misc/finalcut/ debian/40-finalcut-newfont.conf etc/fonts/conf.avail
fonts/newfont.txt /usr/share/fonts/X11/misc/finalcut/

1
debian/libfinal0.links vendored Normal file
View File

@ -0,0 +1 @@
etc/fonts/conf.avail/40-finalcut-newfont.conf etc/fonts/conf.d/40-finalcut-newfont.conf

1
debian/rules vendored
View File

@ -20,6 +20,7 @@ include /usr/share/dpkg/default.mk
# main packaging script based on dh7 syntax # main packaging script based on dh7 syntax
%: %:
sed -i 's/doc\///g' README.md sed -i 's/doc\///g' README.md
test -f fonts/fonts.alias && mv fonts/fonts.alias fonts/xfonts-finalcut-newfont.alias || true
dh $@ --with autotools-dev dh $@ --with autotools-dev
# debmake generated override targets # debmake generated override targets

View File

@ -116,7 +116,6 @@ class FClassName
// Data members // Data members
// Friend class // Friend class
}; };

View File

@ -140,7 +140,7 @@ int main (int argc, char* argv[])
ok.addCallback ok.addCallback
( (
"clicked", "clicked",
F_FUNCTION_CALLBACK (&cb_quit), &cb_quit,
&dgl &dgl
); );

View File

@ -76,7 +76,7 @@ int main (int argc, char* argv[])
btn.addCallback btn.addCallback
( (
"clicked", "clicked",
F_FUNCTION_CALLBACK (&cb_quit), &cb_quit,
&app &app
); );

View File

@ -126,7 +126,7 @@ int main (int argc, char* argv[])
btn.addCallback ("clicked", cb_exit, &app); btn.addCallback ("clicked", cb_exit, &app);
Exit.addCallback ("clicked", cb_exit, &app); Exit.addCallback ("clicked", cb_exit, &app);
Quit.addCallback ("clicked", cb_exit, &app); Quit.addCallback ("clicked", cb_exit, &app);
key_F1.addCallback ("activate",cb_tooltip, &app); key_F1.addCallback ("activate", cb_tooltip, &app);
// Set dialog object as main widget // Set dialog object as main widget
app.setMainWidget(&dgl); app.setMainWidget(&dgl);

View File

@ -120,7 +120,7 @@ int main (int argc, char* argv[])
check1.addCallback check1.addCallback
( (
"clicked", "clicked",
F_FUNCTION_CALLBACK (&cb_publish), &cb_publish,
&check2 &check2
); );
@ -128,7 +128,7 @@ int main (int argc, char* argv[])
btn.addCallback btn.addCallback
( (
"clicked", "clicked",
F_FUNCTION_CALLBACK (&cb_quit), &cb_quit,
&app &app
); );

View File

@ -45,7 +45,7 @@ FString& mapToString ( std::map<FString
, FString>::const_iterator iter ); , FString>::const_iterator iter );
// Lazy conversion import function // Lazy conversion insert function
void doubleToItem ( FListBoxItem& item void doubleToItem ( FListBoxItem& item
, FDataPtr container, int index) , FDataPtr container, int index)
{ {
@ -57,7 +57,7 @@ void doubleToItem ( FListBoxItem& item
item.setData (FDataPtr(&(*iter))); item.setData (FDataPtr(&(*iter)));
} }
// Import converter functions // Insert converter functions
FString& doubleToString (std::list<double>::const_iterator iter) FString& doubleToString (std::list<double>::const_iterator iter)
{ {
auto temp = temp_str.lock(); auto temp = temp_str.lock();
@ -127,12 +127,12 @@ Listbox::Listbox (FWidget* parent)
list2.setText ("double"); list2.setText ("double");
// //
// Import via lazy conversion on print // Insert via lazy conversion on print
// //
list2.insert (&double_list, doubleToItem); 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); //list2.insert (double_list.begin(), double_list.end(), doubleToString);

View File

@ -141,7 +141,6 @@ void Scrollview::draw()
for (int x{0}; x < int(getScrollWidth()); x++) for (int x{0}; x < int(getScrollWidth()); x++)
print (32 + ((x + y) % 0x5f)); print (32 + ((x + y) % 0x5f));
} }
if ( isMonochron() ) if ( isMonochron() )

View File

@ -21,6 +21,7 @@
***********************************************************************/ ***********************************************************************/
#include <fstream> #include <fstream>
#include <functional>
#include <map> #include <map>
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -95,6 +96,7 @@ ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
progressBar.setGeometry(FPoint(2, 3), FSize(34, 1), false); progressBar.setGeometry(FPoint(2, 3), FSize(34, 1), false);
//progressBar.setPercentage(78); //progressBar.setPercentage(78);
using namespace std::placeholders;
reset.addCallback reset.addCallback
( (
"clicked", "clicked",

View File

@ -377,7 +377,7 @@ void Window::addClickedCallback ( finalcut::FWidget* widget
, WindowCallback call ) , WindowCallback call )
{ {
FMemberCallback callback FMemberCallback callback
= reinterpret_cast<finalcut::FWidget::FMemberCallback>(call); = reinterpret_cast<FMemberCallback>(call);
widget->addCallback widget->addCallback
( (
@ -391,7 +391,7 @@ void Window::addClickedCallback ( finalcut::FWidget* widget
, FAppCallback call ) , FAppCallback call )
{ {
FMemberCallback callback FMemberCallback callback
= reinterpret_cast<finalcut::FWidget::FMemberCallback>(call); = reinterpret_cast<FMemberCallback>(call);
widget->addCallback widget->addCallback
( (

View File

@ -9,7 +9,7 @@ else
fi fi
# Is the file executable? # 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 LD_LIBRARY_PATH=../src/.libs/ valgrind --tool=callgrind -v "$PROG" 2>/dev/null

View File

@ -11,12 +11,12 @@ else
fi fi
# Is the file executable? # 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? # ELF executable file?
ELFMAGIC="$(echo -e "\\x7fELF")" ELFMAGIC="$(echo -e "\\x7fELF")"
MAGIC="$(dd bs=1 count=4 if="$PROG" 2>/dev/null)" 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" "$@" 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" "$@"

View File

@ -370,9 +370,12 @@ void FApplication::init (uInt64 key_time, uInt64 dblclick_time)
// Set the keyboard keypress timeout // Set the keyboard keypress timeout
if ( keyboard ) if ( keyboard )
{ {
FKeyboardCommand key_cmd1 (this, &FApplication::keyPressed); auto cmd1 = std::bind(&FApplication::keyPressed, this);
FKeyboardCommand key_cmd2 (this, &FApplication::keyReleased); auto cmd2 = std::bind(&FApplication::keyReleased, this);
FKeyboardCommand key_cmd3 (this, &FApplication::escapeKeyPressed); auto cmd3 = std::bind(&FApplication::escapeKeyPressed, this);
FKeyboardCommand key_cmd1 (cmd1);
FKeyboardCommand key_cmd2 (cmd2);
FKeyboardCommand key_cmd3 (cmd3);
keyboard->setPressCommand (key_cmd1); keyboard->setPressCommand (key_cmd1);
keyboard->setReleaseCommand (key_cmd2); keyboard->setReleaseCommand (key_cmd2);
keyboard->setEscPressedCommand (key_cmd3); keyboard->setEscPressedCommand (key_cmd3);

View File

@ -165,7 +165,6 @@ int FDialog::exec()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::setPos (const FPoint& pos, bool) void FDialog::setPos (const FPoint& pos, bool)
{ {
setPos_error = false; setPos_error = false;
// Avoid to move widget completely outside the terminal // Avoid to move widget completely outside the terminal

View File

@ -453,33 +453,33 @@ void FFileDialog::clear()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
long FFileDialog::numOfDirs() sInt64 FFileDialog::numOfDirs()
{ {
if ( dir_entries.empty() ) if ( dir_entries.empty() )
return 0; return 0;
long n = std::count_if ( std::begin(dir_entries) sInt64 n = std::count_if ( std::begin(dir_entries)
, std::end(dir_entries) , std::end(dir_entries)
, [] (dir_entry& entry) , [] (dir_entry& entry)
{ {
return entry.directory return entry.directory
&& std::strcmp(entry.name, ".") != 0; && std::strcmp(entry.name, ".") != 0;
} }
); );
return n; return n;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FFileDialog::sortDir() void FFileDialog::sortDir()
{ {
long start{}; sInt64 start{};
if ( std::strcmp((*dir_entries.begin()).name, "..") == 0 ) if ( std::strcmp((*dir_entries.begin()).name, "..") == 0 )
start = 1; start = 1;
else else
start = 0; start = 0;
long dir_num = numOfDirs(); sInt64 dir_num = numOfDirs();
// directories first // directories first
std::sort ( dir_entries.begin() + start std::sort ( dir_entries.begin() + start
, dir_entries.end() , dir_entries.end()

View File

@ -49,25 +49,6 @@ struct timeval FKeyboard::time_keypressed{};
FTermLinux* FKeyboard::linux{nullptr}; FTermLinux* FKeyboard::linux{nullptr};
#endif #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 // class FKeyboard

View File

@ -21,6 +21,7 @@
***********************************************************************/ ***********************************************************************/
#include <memory> #include <memory>
#include <utility>
#include "final/fapplication.h" #include "final/fapplication.h"
#include "final/fcolorpair.h" #include "final/fcolorpair.h"

View File

@ -322,82 +322,7 @@ void FListBox::onKeyPress (FKeyEvent* ev)
std::size_t current_before = current; std::size_t current_before = current;
int xoffset_before = xoffset; int xoffset_before = xoffset;
int yoffset_before = yoffset; int yoffset_before = yoffset;
FKey key = ev->key(); processKeyAction(ev); // Process the keystrokes
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();
}
if ( current_before != current ) if ( current_before != current )
{ {
@ -759,6 +684,57 @@ void FListBox::init()
setLeftPadding(1); setLeftPadding(1);
setBottomPadding(1); setBottomPadding(1);
setRightPadding(1 + int(nf_offset)); setRightPadding(1 + int(nf_offset));
mapKeyFunctions();
}
//----------------------------------------------------------------------
inline void FListBox::mapKeyFunctions()
{
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);
}
//----------------------------------------------------------------------
void FListBox::processKeyAction (FKeyEvent* ev)
{
int idx = int(ev->key());
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();
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1770,7 +1746,7 @@ void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
if ( conv_type != lazy_convert || ! iter->getText().isNull() ) if ( conv_type != lazy_convert || ! iter->getText().isNull() )
return; return;
convertToItem (*iter, source_container, y + yoffset); lazy_inserter (*iter, source_container, y + yoffset);
std::size_t column_width = getColumnWidth(iter->text); std::size_t column_width = getColumnWidth(iter->text);
recalculateHorizontalBar (column_width, hasBrackets(iter)); recalculateHorizontalBar (column_width, hasBrackets(iter));

View File

@ -25,6 +25,7 @@
#endif #endif
#include <memory> #include <memory>
#include <unordered_map>
#include <vector> #include <vector>
#include "final/emptyfstring.h" #include "final/emptyfstring.h"
@ -875,79 +876,11 @@ void FListView::sort()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::onKeyPress (FKeyEvent* ev) void FListView::onKeyPress (FKeyEvent* ev)
{ {
int position_before = current_iter.getPosition() int position_before = current_iter.getPosition();
, xoffset_before = xoffset int xoffset_before = xoffset;
, first_line_position_before = first_visible_line.getPosition() first_line_position_before = first_visible_line.getPosition();
, pagesize = int(getClientHeight()) - 1;
FKey key = ev->key();
clicked_expander_pos.setPoint(-1, -1); clicked_expander_pos.setPoint(-1, -1);
processKeyAction(ev); // Process the keystrokes
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();
}
if ( position_before != current_iter.getPosition() ) if ( position_before != current_iter.getPosition() )
processChanged(); processChanged();
@ -982,9 +915,9 @@ void FListView::onMouseDown (FMouseEvent* ev)
getStatusBar()->drawMessage(); getStatusBar()->drawMessage();
} }
int first_line_position_before = first_visible_line.getPosition() int mouse_x = ev->getX();
, mouse_x = ev->getX() int mouse_y = ev->getY();
, mouse_y = ev->getY(); first_line_position_before = first_visible_line.getPosition();
if ( mouse_x > 1 && mouse_x < int(getWidth()) ) if ( mouse_x > 1 && mouse_x < int(getWidth()) )
{ {
@ -1119,9 +1052,9 @@ void FListView::onMouseMove (FMouseEvent* ev)
return; return;
} }
int first_line_position_before = first_visible_line.getPosition() int mouse_x = ev->getX();
, mouse_x = ev->getX() int mouse_y = ev->getY();
, mouse_y = ev->getY(); first_line_position_before = first_visible_line.getPosition();
if ( mouse_x > 1 && mouse_x < int(getWidth()) if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) ) && mouse_y > 1 && mouse_y < int(getHeight()) )
@ -1194,8 +1127,8 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::onTimer (FTimerEvent*) void FListView::onTimer (FTimerEvent*)
{ {
int position_before = current_iter.getPosition() int position_before = current_iter.getPosition();
, first_line_position_before = first_visible_line.getPosition(); first_line_position_before = first_visible_line.getPosition();
switch ( int(drag_scroll) ) switch ( int(drag_scroll) )
{ {
@ -1233,9 +1166,9 @@ void FListView::onTimer (FTimerEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::onWheel (FWheelEvent* ev) void FListView::onWheel (FWheelEvent* ev)
{ {
int position_before = current_iter.getPosition() int position_before = current_iter.getPosition();
, first_line_position_before = first_visible_line.getPosition() int pagesize{4};
, pagesize{4}; first_line_position_before = first_visible_line.getPosition();
if ( drag_scroll != fc::noScroll ) if ( drag_scroll != fc::noScroll )
stopDragScroll(); stopDragScroll();
@ -1391,6 +1324,46 @@ void FListView::init()
setLeftPadding(1); setLeftPadding(1);
setBottomPadding(1); setBottomPadding(1);
setRightPadding(1 + int(nf_offset)); setRightPadding(1 + int(nf_offset));
mapKeyFunctions();
}
//----------------------------------------------------------------------
inline void FListView::mapKeyFunctions()
{
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);
}
//----------------------------------------------------------------------
void FListView::processKeyAction (FKeyEvent* ev)
{
int idx = int(ev->key());
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();
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2291,7 +2264,7 @@ inline void FListView::toggleCheckbox()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FListView::collapseAndScrollLeft (int& first_line_position_before) inline void FListView::collapseAndScrollLeft()
{ {
if ( itemlist.empty() ) if ( itemlist.empty() )
return; return;
@ -2348,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() ) if ( itemlist.empty() )
return; return;
@ -2618,9 +2591,9 @@ void FListView::scrollBy (int dx, int dy)
void FListView::cb_VBarChange (FWidget*, FDataPtr) void FListView::cb_VBarChange (FWidget*, FDataPtr)
{ {
FScrollbar::sType scrollType = vbar->getScrollType(); FScrollbar::sType scrollType = vbar->getScrollType();
int distance{1} int distance{1};
, pagesize{4} int pagesize{4};
, first_line_position_before = first_visible_line.getPosition(); first_line_position_before = first_visible_line.getPosition();
switch ( scrollType ) switch ( scrollType )
{ {

View File

@ -567,7 +567,7 @@ void FMenuItem::init (FWidget* parent)
addCallback // for this element addCallback // for this element
( (
"deactivate", "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 else if ( isMenu(parent) ) // Parent is menu

View File

@ -53,7 +53,7 @@ FMouse::FMouse()
// public methods of FMouse // public methods of FMouse
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* FMouse::getClassName() const const FString FMouse::getClassName() const
{ {
return "FMouse"; return "FMouse";
} }
@ -314,7 +314,7 @@ FMouseGPM::~FMouseGPM() // destructor
// public methods of FMouseX11 // public methods of FMouseX11
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* FMouseGPM::getClassName() const const FString FMouseGPM::getClassName() const
{ {
return "FMouseGPM"; return "FMouseGPM";
} }
@ -555,7 +555,7 @@ int FMouseGPM::gpmEvent (bool clear)
// public methods of FMouseX11 // public methods of FMouseX11
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* FMouseX11::getClassName() const const FString FMouseX11::getClassName() const
{ {
return "FMouseX11"; return "FMouseX11";
} }
@ -733,7 +733,7 @@ void FMouseX11::setButtonState (int btn, struct timeval* time)
// public methods of FMouseSGR // public methods of FMouseSGR
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* FMouseSGR::getClassName() const const FString FMouseSGR::getClassName() const
{ {
return "FMouseSGR"; return "FMouseSGR";
} }
@ -962,7 +962,7 @@ void FMouseSGR::setReleasedButtonState (int btn)
// public methods of FMouseUrxvt // public methods of FMouseUrxvt
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* FMouseUrxvt::getClassName() const const FString FMouseUrxvt::getClassName() const
{ {
return "FMouseUrxvt"; return "FMouseUrxvt";
} }

View File

@ -69,7 +69,7 @@ void FRadioMenuItem::init (FWidget* parent)
addCallback // for this element addCallback // for this element
( (
"toggled", "toggled",
F_METHOD_CALLBACK (parent, &FMenu::cb_menuitem_toggled) F_METHOD_CALLBACK (menu_ptr, &FMenu::cb_menuitem_toggled)
); );
} }
} }

View File

@ -464,52 +464,12 @@ void FScrollView::drawBorder()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::onKeyPress (FKeyEvent* ev) 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: key_map[idx]();
scrollBy (0, -1); ev->accept();
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;
} }
} }
@ -764,6 +724,7 @@ void FScrollView::init (FWidget* parent)
initScrollbar (vbar, fc::vertical, &FScrollView::cb_VBarChange); initScrollbar (vbar, fc::vertical, &FScrollView::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_HBarChange); initScrollbar (hbar, fc::horizontal, &FScrollView::cb_HBarChange);
mapKeyFunctions();
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
@ -797,6 +758,24 @@ void FScrollView::init (FWidget* parent)
setChildPrintArea (viewport); setChildPrintArea (viewport);
} }
//----------------------------------------------------------------------
inline void FScrollView::mapKeyFunctions()
{
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] = \
[&] ()
{
int yoffset_end = int(getScrollHeight() - getViewportHeight());
scrollToY (1 + yoffset_end);
};
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::calculateScrollbarPos() void FScrollView::calculateScrollbarPos()
{ {

View File

@ -35,27 +35,24 @@ FStartOptions* FStartOptions::start_options{};
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FStartOptions::FStartOptions() FStartOptions::FStartOptions()
: cursor_optimisation{true} : cursor_optimisation{true}
, mouse_support{true} , mouse_support{true}
, terminal_detection{true} , terminal_detection{true}
, color_change{true} , color_change{true}
, vgafont{false} , vgafont{false}
, newfont{false} , newfont{false}
, encoding{fc::UNKNOWN} , encoding{fc::UNKNOWN}
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
, meta_sends_escape{true} , meta_sends_escape{true}
, change_cursorstyle{true} , change_cursorstyle{true}
#elif defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__NetBSD__) || defined(__OpenBSD__)
, meta_sends_escape{true} , meta_sends_escape{true}
#endif #endif
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FStartOptions::~FStartOptions() // destructor FStartOptions::~FStartOptions() // destructor
{ { }
if ( start_options )
delete start_options;
}
// public methods of FStartOptions // public methods of FStartOptions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -77,6 +74,13 @@ FStartOptions& FStartOptions::getFStartOptions()
return *start_options; return *start_options;
} }
//----------------------------------------------------------------------
void FStartOptions::destroyObject()
{
if ( start_options )
delete start_options;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStartOptions::setDefault() void FStartOptions::setDefault()
{ {

View File

@ -67,9 +67,6 @@ static FTerm* init_term_object{nullptr};
// global init state // global init state
static bool term_initialized{false}; static bool term_initialized{false};
// function pointer
int (*FTerm::Fputchar)(int);
// static class attributes // static class attributes
FTermData* FTerm::data {nullptr}; FTermData* FTerm::data {nullptr};
FSystem* FTerm::fsys {nullptr}; FSystem* FTerm::fsys {nullptr};
@ -674,16 +671,16 @@ bool FTerm::setVGAFont()
data->setTermEncoding (fc::PC); data->setTermEncoding (fc::PC);
if ( isXTerminal() && data->hasUTF8Console() ) if ( isXTerminal() && data->hasUTF8Console() )
Fputchar = &FTerm::putchar_UTF8; putchar() = &FTerm::putchar_UTF8;
else else
Fputchar = &FTerm::putchar_ASCII; putchar() = &FTerm::putchar_ASCII;
} }
#if defined(__linux__) #if defined(__linux__)
else if ( isLinuxTerm() ) else if ( isLinuxTerm() )
{ {
data->setVGAFont(linux->loadVGAFont()); data->setVGAFont(linux->loadVGAFont());
data->setTermEncoding (fc::PC); data->setTermEncoding (fc::PC);
Fputchar = &FTerm::putchar_ASCII; putchar() = &FTerm::putchar_ASCII;
} }
#endif // defined(__linux__) #endif // defined(__linux__)
else else
@ -716,16 +713,16 @@ bool FTerm::setNewFont()
data->setTermEncoding (fc::PC); data->setTermEncoding (fc::PC);
if ( isXTerminal() && data->hasUTF8Console() ) if ( isXTerminal() && data->hasUTF8Console() )
Fputchar = &FTerm::putchar_UTF8; putchar() = &FTerm::putchar_UTF8;
else else
Fputchar = &FTerm::putchar_ASCII; putchar() = &FTerm::putchar_ASCII;
} }
#if defined(__linux__) #if defined(__linux__)
else if ( isLinuxTerm() ) else if ( isLinuxTerm() )
{ {
data->setNewFont(linux->loadNewFont()); data->setNewFont(linux->loadNewFont());
data->setTermEncoding (fc::PC); data->setTermEncoding (fc::PC);
Fputchar = &FTerm::putchar_ASCII; // function pointer putchar() = &FTerm::putchar_ASCII; // function pointer
} }
#endif // defined(__linux__) #endif // defined(__linux__)
else else
@ -1086,25 +1083,25 @@ void FTerm::setEncoding (fc::encoding enc)
|| enc == fc::PC // CP-437 || enc == fc::PC // CP-437
|| enc == fc::ASCII ); || enc == fc::ASCII );
// Set the new Fputchar function pointer // Set the new putchar() function pointer
switch ( enc ) switch ( enc )
{ {
case fc::UTF8: case fc::UTF8:
Fputchar = &FTerm::putchar_UTF8; putchar() = &FTerm::putchar_UTF8;
break; break;
case fc::VT100: case fc::VT100:
case fc::PC: case fc::PC:
if ( isXTerminal() && data->hasUTF8Console() ) if ( isXTerminal() && data->hasUTF8Console() )
Fputchar = &FTerm::putchar_UTF8; putchar() = &FTerm::putchar_UTF8;
else else
Fputchar = &FTerm::putchar_ASCII; putchar() = &FTerm::putchar_ASCII;
break; break;
case fc::ASCII: case fc::ASCII:
case fc::UNKNOWN: case fc::UNKNOWN:
case fc::NUM_OF_ENCODINGS: case fc::NUM_OF_ENCODINGS:
Fputchar = &FTerm::putchar_ASCII; putchar() = &FTerm::putchar_ASCII;
} }
if ( isLinuxTerm() ) if ( isLinuxTerm() )
@ -1198,6 +1195,13 @@ bool FTerm::scrollTermReverse()
return false; return false;
} }
//----------------------------------------------------------------------
FTerm::defaultPutChar& FTerm::putchar()
{
static defaultPutChar* fputchar = new defaultPutChar();
return *fputchar;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::putstring (const char str[], int affcnt) void FTerm::putstring (const char str[], int affcnt)
{ {
@ -1719,7 +1723,7 @@ void FTerm::init_locale()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::init_encoding() 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) bool force_vt100{false}; // VT100 line drawing (G1 character set)
init_encoding_set(); init_encoding_set();
@ -1771,7 +1775,7 @@ void FTerm::init_term_encoding()
{ {
data->setUTF8Console(true); data->setUTF8Console(true);
data->setTermEncoding (fc::UTF8); data->setTermEncoding (fc::UTF8);
Fputchar = &FTerm::putchar_UTF8; // function pointer putchar() = &FTerm::putchar_UTF8; // function pointer
data->setUTF8(true); data->setUTF8(true);
setUTF8(true); setUTF8(true);
keyboard->enableUTF8(); keyboard->enableUTF8();
@ -1782,13 +1786,13 @@ void FTerm::init_term_encoding()
{ {
data->setVT100Console (true); data->setVT100Console (true);
data->setTermEncoding (fc::VT100); data->setTermEncoding (fc::VT100);
Fputchar = &FTerm::putchar_ASCII; // function pointer putchar() = &FTerm::putchar_ASCII; // function pointer
} }
else else
{ {
data->setASCIIConsole (true); data->setASCIIConsole (true);
data->setTermEncoding (fc::ASCII); data->setTermEncoding (fc::ASCII);
Fputchar = &FTerm::putchar_ASCII; // function pointer putchar() = &FTerm::putchar_ASCII; // function pointer
} }
} }
@ -1800,12 +1804,12 @@ void FTerm::init_individual_term_encoding()
|| (isTeraTerm() && ! data->isUTF8()) ) || (isTeraTerm() && ! data->isUTF8()) )
{ {
data->setTermEncoding (fc::PC); data->setTermEncoding (fc::PC);
Fputchar = &FTerm::putchar_ASCII; // function pointer putchar() = &FTerm::putchar_ASCII; // function pointer
if ( hasUTF8() && getStartOptions().encoding == fc::UNKNOWN ) if ( hasUTF8() && getStartOptions().encoding == fc::UNKNOWN )
{ {
if ( isXTerminal() ) if ( isXTerminal() )
Fputchar = &FTerm::putchar_UTF8; // function pointer putchar() = &FTerm::putchar_UTF8; // function pointer
} }
} }
} }
@ -1815,7 +1819,7 @@ void FTerm::init_force_vt100_encoding()
{ {
data->setVT100Console(true); data->setVT100Console(true);
data->setTermEncoding (fc::VT100); data->setTermEncoding (fc::VT100);
Fputchar = &FTerm::putchar_ASCII; // function pointer putchar() = &FTerm::putchar_ASCII; // function pointer
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1829,7 +1833,7 @@ void FTerm::init_utf8_without_alt_charset()
{ {
data->setASCIIConsole(true); data->setASCIIConsole(true);
data->setTermEncoding (fc::ASCII); data->setTermEncoding (fc::ASCII);
Fputchar = &FTerm::putchar_ASCII; // function pointer putchar() = &FTerm::putchar_ASCII; // function pointer
} }
} }
@ -2160,7 +2164,6 @@ inline void FTerm::allocationValues()
#if DEBUG #if DEBUG
getFTermDebugData(); getFTermDebugData();
#endif #endif
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2205,6 +2208,10 @@ inline void FTerm::deallocationValues()
if ( data ) if ( data )
delete data; delete data;
defaultPutChar* putchar_ptr = &(putchar());
delete putchar_ptr;
FStartOptions::destroyObject();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2597,11 +2604,12 @@ FString getFullWidth (const FString& str)
{ {
c += 0xfee0; c += 0xfee0;
} }
else for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++) else
{ {
if ( fc::halfWidth_fullWidth[i][HALF] == c ) // found for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
{ {
c = fc::halfWidth_fullWidth[i][FULL]; if ( fc::halfWidth_fullWidth[i][HALF] == c ) // found
c = fc::halfWidth_fullWidth[i][FULL];
} }
} }
} }
@ -2624,11 +2632,12 @@ FString getHalfWidth (const FString& str)
{ {
c -= 0xfee0; c -= 0xfee0;
} }
else for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++) else
{ {
if ( fc::halfWidth_fullWidth[i][FULL] == c ) // found for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
{ {
c = fc::halfWidth_fullWidth[i][HALF]; if ( fc::halfWidth_fullWidth[i][FULL] == c ) // found
c = fc::halfWidth_fullWidth[i][HALF];
} }
} }
} }

View File

@ -26,7 +26,6 @@
#include "final/emptyfstring.h" #include "final/emptyfstring.h"
#include "final/fc.h" #include "final/fc.h"
#include "final/fconfig.h"
#include "final/fsystem.h" #include "final/fsystem.h"
#include "final/fterm.h" #include "final/fterm.h"
#include "final/ftermdata.h" #include "final/ftermdata.h"

View File

@ -41,26 +41,6 @@
namespace finalcut 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 // class FTermLinux
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -830,8 +810,8 @@ void FTermLinux::writeAttributeController (uChar index, uChar data)
const uInt16 input_status_1 = getInputStatusRegisterOne(); const uInt16 input_status_1 = getInputStatusRegisterOne();
fsystem->inPortByte (input_status_1); // switch to index mode fsystem->inPortByte (input_status_1); // switch to index mode
fsystem->outPortByte (index & 0x1f, attrib_cntlr_write); // selects address register fsystem->outPortByte (index & 0x1f, attrib_cntlr_write); // selects address register
fsystem->outPortByte (data, attrib_cntlr_write); // write to data register fsystem->outPortByte (data, attrib_cntlr_write); // write to data register
// Disable access to the palette and unblank the display // Disable access to the palette and unblank the display
fsystem->inPortByte (input_status_1); // switch to index mode fsystem->inPortByte (input_status_1); // switch to index mode

View File

@ -38,22 +38,8 @@ namespace finalcut
{ {
// static class attributes // static class attributes
bool FTermXTerminal::mouse_support{false}; bool FTermXTerminal::mouse_support{false};
bool FTermXTerminal::meta_sends_esc{false}; FSystem* FTermXTerminal::fsystem{nullptr};
bool FTermXTerminal::xterm_default_colors{false};
std::size_t FTermXTerminal::term_width{80};
std::size_t FTermXTerminal::term_height{24};
FString FTermXTerminal::xterm_font{};
FString FTermXTerminal::xterm_title{};
FString FTermXTerminal::foreground_color{};
FString FTermXTerminal::background_color{};
FString FTermXTerminal::cursor_color{};
FString FTermXTerminal::mouse_foreground_color{};
FString FTermXTerminal::mouse_background_color{};
FString FTermXTerminal::highlight_background_color{};
FSystem* FTermXTerminal::fsystem{nullptr};
FTermDetection* FTermXTerminal::term_detection{nullptr};
fc::xtermCursorStyle FTermXTerminal::cursor_style{fc::unknown_cursor_style};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -786,7 +772,7 @@ void FTermXTerminal::enableXTermMouse()
// Activate the xterm mouse support // Activate the xterm mouse support
if ( mouse_support ) if ( mouse_support )
return; return; // The mouse is already activated
if ( ! fsystem ) if ( ! fsystem )
fsystem = FTerm::getFSystem(); fsystem = FTerm::getFSystem();
@ -806,7 +792,7 @@ void FTermXTerminal::disableXTermMouse()
// Deactivate the xterm mouse support // Deactivate the xterm mouse support
if ( ! mouse_support ) if ( ! mouse_support )
return; return; // The mouse was already deactivated
FTerm::putstring (CSI "?1006l" // disable SGR mouse mode FTerm::putstring (CSI "?1006l" // disable SGR mouse mode
CSI "?1015l" // disable urxvt mouse mode CSI "?1015l" // disable urxvt mouse mode

View File

@ -300,7 +300,9 @@ void FTextView::clear()
if ( useFDialogBorder() ) if ( useFDialogBorder() )
{ {
auto parent = getParentWidget(); auto parent = getParentWidget();
static_cast<FDialog*>(parent)->redraw();
if ( parent )
static_cast<FDialog*>(parent)->redraw();
} }
else else
drawBorder(); drawBorder();
@ -323,50 +325,12 @@ void FTextView::clear()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::onKeyPress (FKeyEvent* ev) 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: key_map[idx]();
scrollBy (0, -1); ev->accept();
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;
} }
} }
@ -612,6 +576,20 @@ void FTextView::init()
setLeftPadding(1); setLeftPadding(1);
setBottomPadding(1); setBottomPadding(1);
setRightPadding(1 + nf_offset); setRightPadding(1 + nf_offset);
mapKeyFunctions();
}
//----------------------------------------------------------------------
inline void FTextView::mapKeyFunctions()
{
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())); };
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include <utility>
#include "final/fapplication.h" #include "final/fapplication.h"
#include "final/fbuttongroup.h" #include "final/fbuttongroup.h"
#include "final/fevent.h" #include "final/fevent.h"

View File

@ -290,14 +290,14 @@ void FVTerm::updateTerminal()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::addPreprocessingHandler ( FVTerm* instance void FVTerm::addPreprocessingHandler ( FVTerm* instance
, FPreprocessingHandler handler ) , FVTermPreprocessing function )
{ {
if ( ! print_area ) if ( ! print_area )
FVTerm::getPrintArea(); FVTerm::getPrintArea();
if ( print_area ) if ( print_area )
{ {
vterm_preprocessing obj{ instance, handler }; vterm_preprocessing obj{ instance, function };
delPreprocessingHandler (instance); delPreprocessingHandler (instance);
print_area->preprocessing_call.push_back(obj); print_area->preprocessing_call.push_back(obj);
} }
@ -1104,9 +1104,9 @@ void FVTerm::callPreprocessingHandler (term_area* area)
while ( iter != end ) while ( iter != end )
{ {
FPreprocessingHandler handler = iter->handler;
// call the preprocessing handler // call the preprocessing handler
(iter->instance->*handler)(); auto preprocessingHandler = iter->function;
preprocessingHandler();
++iter; ++iter;
} }
} }
@ -1838,7 +1838,8 @@ void FVTerm::flush_out()
{ {
while ( ! output_buffer->empty() ) while ( ! output_buffer->empty() )
{ {
FTerm::Fputchar(output_buffer->front()); static FTerm::defaultPutChar& FTermPutchar = FTerm::putchar();
FTermPutchar (output_buffer->front());
output_buffer->pop(); output_buffer->pop();
} }
@ -2525,7 +2526,6 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
whitespace++; whitespace++;
else else
break; break;
} }
if ( whitespace == 1 ) if ( whitespace == 1 )

View File

@ -821,6 +821,8 @@ int FWidget::numOfFocusableChildren()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::close() bool FWidget::close()
{ {
// Sends a close event and quits the application on acceptance
FCloseEvent ev(fc::Close_Event); FCloseEvent ev(fc::Close_Event);
FApplication::sendEvent(this, &ev); FApplication::sendEvent(this, &ev);
@ -844,29 +846,31 @@ bool FWidget::close()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::addCallback ( const FString& cb_signal void FWidget::addCallback ( const FString& cb_signal
, FCallback cb_handler , FCallback cb_function
, FDataPtr data ) , FDataPtr data )
{ {
// add a (normal) function pointer as callback // Add a (normal) function pointer as callback
callback_data obj{ cb_signal, cb_handler, data };
callback_data obj{ cb_signal, nullptr, cb_function, data };
callback_objects.push_back(obj); callback_objects.push_back(obj);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::addCallback ( const FString& cb_signal void FWidget::addCallback ( const FString& cb_signal
, FWidget* cb_instance , FWidget* cb_instance
, FMemberCallback cb_handler , FCallback cb_function
, FDataPtr data ) , FDataPtr data )
{ {
// add a member function pointer as callback // Add a member function pointer as callback
member_callback_data obj{ cb_signal, cb_instance, cb_handler, data };
member_callback_objects.push_back(obj); callback_data 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() ) if ( callback_objects.empty() )
return; return;
@ -875,7 +879,7 @@ void FWidget::delCallback (FCallback cb_handler)
while ( iter != callback_objects.end() ) while ( iter != callback_objects.end() )
{ {
if ( iter->cb_handler == cb_handler ) if ( getCallbackPtr(iter->cb_function) == getCallbackPtr(cb_function) )
iter = callback_objects.erase(iter); iter = callback_objects.erase(iter);
else else
++iter; ++iter;
@ -885,17 +889,17 @@ void FWidget::delCallback (FCallback cb_handler)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::delCallback (FWidget* cb_instance) 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; 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 ) if ( iter->cb_instance == cb_instance )
iter = member_callback_objects.erase(iter); iter = callback_objects.erase(iter);
else else
++iter; ++iter;
} }
@ -904,58 +908,40 @@ void FWidget::delCallback (FWidget* cb_instance)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::delCallbacks() 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
callback_objects.clear(); // function pointer
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::emitCallback (const FString& emit_signal) void FWidget::emitCallback (const FString& emit_signal)
{ {
// member function pointer // Initiate callback for the given signal
if ( ! member_callback_objects.empty() ) if ( callback_objects.empty() )
return;
auto iter = callback_objects.begin();
auto last = callback_objects.end();
while ( iter != last )
{ {
auto m_iter = member_callback_objects.begin(); if ( iter->cb_signal == emit_signal )
auto m_end = member_callback_objects.end();
while ( m_iter != m_end )
{ {
if ( m_iter->cb_signal == emit_signal ) // Calling the stored function pointer
{ auto callback = iter->cb_function;
auto callback = m_iter->cb_handler; callback (this, iter->data);
// call the member function pointer
(m_iter->cb_instance->*callback) (this, m_iter->data);
}
++m_iter;
} }
}
// function pointer ++iter;
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;
}
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::addAccelerator (FKey key, FWidget* obj) void FWidget::addAccelerator (FKey key, FWidget* obj)
{ {
// Adding a keyboard accelerator for the given widget
auto widget = static_cast<FWidget*>(FWindow::getWindowWidget(obj)); auto widget = static_cast<FWidget*>(FWindow::getWindowWidget(obj));
accelerator accel = { key, obj }; accelerator accel = { key, obj };
@ -969,6 +955,8 @@ void FWidget::addAccelerator (FKey key, FWidget* obj)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::delAccelerator (FWidget* obj) void FWidget::delAccelerator (FWidget* obj)
{ {
// Deletes all accelerators of the given widget
auto widget = static_cast<FWidget*>(FWindow::getWindowWidget(this)); auto widget = static_cast<FWidget*>(FWindow::getWindowWidget(this));
if ( ! widget || widget == statusbar || widget == menubar ) if ( ! widget || widget == statusbar || widget == menubar )
@ -993,6 +981,8 @@ void FWidget::delAccelerator (FWidget* obj)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::redraw() void FWidget::redraw()
{ {
// Redraw the widget immediately unless it is hidden.
if ( ! redraw_root_widget ) if ( ! redraw_root_widget )
redraw_root_widget = this; redraw_root_widget = this;
@ -1054,6 +1044,8 @@ void FWidget::resize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::show() void FWidget::show()
{ {
// Make the widget visible and draw it
if ( ! isVisible() ) if ( ! isVisible() )
return; return;
@ -1113,6 +1105,8 @@ void FWidget::show()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::hide() void FWidget::hide()
{ {
// Hide the widget
flags.hidden = true; flags.hidden = true;
if ( isVisible() ) if ( isVisible() )
@ -1477,12 +1471,12 @@ FVTerm::term_area* FWidget::getPrintArea()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::addPreprocessingHandler ( FVTerm* instance void FWidget::addPreprocessingHandler ( FVTerm* instance
, FPreprocessingHandler handler ) , FVTermPreprocessing function )
{ {
if ( ! getCurrentPrintArea() ) if ( ! getCurrentPrintArea() )
FWidget::getPrintArea(); FWidget::getPrintArea();
FVTerm::addPreprocessingHandler (instance, handler); FVTerm::addPreprocessingHandler (instance, function);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2116,6 +2110,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 bool FWidget::changeFocus ( FWidget* follower, FWidget* parent
, fc::FocusTypes ft ) , fc::FocusTypes ft )

View File

@ -107,7 +107,7 @@ class FApplication : public FWidget
FApplication& operator = (const FApplication&) = delete; FApplication& operator = (const FApplication&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
int getArgc() const; int getArgc() const;
char** getArgv() const; char** getArgv() const;
static FApplication* getApplicationObject(); static FApplication* getApplicationObject();
@ -203,7 +203,7 @@ class FApplication : public FWidget
// FApplication inline functions // FApplication inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FApplication::getClassName() const inline const FString FApplication::getClassName() const
{ return "FApplication"; } { return "FApplication"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -82,7 +82,7 @@ class FButton : public FWidget
FButton& operator = (const FString&); FButton& operator = (const FString&);
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
FString& getText(); FString& getText();
// Mutators // Mutators
@ -178,7 +178,7 @@ class FButton : public FWidget
// FButton inline functions // FButton inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FButton::getClassName() const inline const FString FButton::getClassName() const
{ return "FButton"; } { return "FButton"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -83,7 +83,7 @@ class FButtonGroup : public FScrollView
FButtonGroup& operator = (const FButtonGroup&) = delete; FButtonGroup& operator = (const FButtonGroup&) = delete;
// Accessor // Accessor
const char* getClassName() const override; const FString getClassName() const override;
FToggleButton* getFirstButton(); FToggleButton* getFirstButton();
FToggleButton* getLastButton(); FToggleButton* getLastButton();
FToggleButton* getButton (int) const; FToggleButton* getButton (int) const;
@ -144,7 +144,7 @@ class FButtonGroup : public FScrollView
// FButtonGroup inline functions // FButtonGroup inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FButtonGroup::getClassName() const inline const FString FButtonGroup::getClassName() const
{ return "FButtonGroup"; } { return "FButtonGroup"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -83,20 +83,20 @@ class FCheckBox : public FToggleButton
FCheckBox& operator = (const FCheckBox&) = delete; FCheckBox& operator = (const FCheckBox&) = delete;
// Accessor // Accessor
const char* getClassName() const override; const FString getClassName() const override;
private: private:
// Methods // Methods
void init(); void init();
void draw() override; void draw() override;
void drawCheckButton(); void drawCheckButton();
void drawChecked(); void drawChecked();
void drawUnchecked(); void drawUnchecked();
}; };
// FCheckBox inline functions // FCheckBox inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FCheckBox::getClassName() const inline const FString FCheckBox::getClassName() const
{ return "FCheckBox"; } { return "FCheckBox"; }
} // namespace finalcut } // namespace finalcut

View File

@ -83,7 +83,7 @@ class FCheckMenuItem : public FMenuItem
FCheckMenuItem& operator = (const FCheckMenuItem&) = delete; FCheckMenuItem& operator = (const FCheckMenuItem&) = delete;
// Accessor // Accessor
const char* getClassName() const override; const FString getClassName() const override;
private: private:
// Methods // Methods
@ -94,7 +94,7 @@ class FCheckMenuItem : public FMenuItem
// FCheckMenuItem inline functions // FCheckMenuItem inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FCheckMenuItem::getClassName() const inline const FString FCheckMenuItem::getClassName() const
{ return "FCheckMenuItem"; } { return "FCheckMenuItem"; }
} // namespace finalcut } // namespace finalcut

View File

@ -36,6 +36,7 @@
#endif #endif
#include "final/fc.h" #include "final/fc.h"
#include "final/fstring.h"
#include "final/ftypes.h" #include "final/ftypes.h"
namespace finalcut namespace finalcut
@ -72,7 +73,7 @@ class FColorPair
} }
// Accessor // Accessor
const char* getClassName() const const FString getClassName() const
{ return "FColorPair"; } { return "FColorPair"; }
FColor getForegroundColor() const FColor getForegroundColor() const

View File

@ -35,6 +35,8 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include "final/fstring.h"
namespace finalcut namespace finalcut
{ {
@ -55,7 +57,7 @@ class FColorPalette final
typedef void (*funcp)(FColor, int, int, int); typedef void (*funcp)(FColor, int, int, int);
// Accessor // Accessor
virtual const char* getClassName() const; virtual const FString getClassName() const;
// Methods // Methods
static void set8ColorPalette (funcp); static void set8ColorPalette (funcp);
@ -66,7 +68,7 @@ class FColorPalette final
// FColorPalette inline functions // FColorPalette inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FColorPalette::getClassName() const inline const FString FColorPalette::getClassName() const
{ return "FColorPalette"; } { return "FColorPalette"; }
} // namespace finalcut } // namespace finalcut

View File

@ -96,7 +96,7 @@ class FDialog : public FWindow
FDialog& operator = (const FDialog&) = delete; FDialog& operator = (const FDialog&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
FString getText() const; FString getText() const;
// Mutators // Mutators
@ -238,7 +238,7 @@ class FDialog : public FWindow
// FDialog inline functions // FDialog inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FDialog::getClassName() const inline const FString FDialog::getClassName() const
{ return "FDialog"; } { return "FDialog"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -89,7 +89,7 @@ class FDialogListMenu : public FMenu
FDialogListMenu& operator = (const FDialogListMenu&) = delete; FDialogListMenu& operator = (const FDialogListMenu&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
private: private:
// Method // Method
@ -99,7 +99,7 @@ class FDialogListMenu : public FMenu
// FDialogListMenu inline functions // FDialogListMenu inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FDialogListMenu::getClassName() const inline const FString FDialogListMenu::getClassName() const
{ return "FDialogListMenu"; } { return "FDialogListMenu"; }
} // namespace finalcut } // namespace finalcut

View File

@ -117,7 +117,7 @@ class FFileDialog : public FDialog
FFileDialog& operator = (const FFileDialog&); FFileDialog& operator = (const FFileDialog&);
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
const FString getPath() const; const FString getPath() const;
const FString getFilter() const; const FString getFilter() const;
const FString getSelectedFile() const; const FString getSelectedFile() const;
@ -174,7 +174,7 @@ class FFileDialog : public FDialog
void initCallbacks(); void initCallbacks();
bool pattern_match (const char* const, char[]); bool pattern_match (const char* const, char[]);
void clear(); void clear();
long numOfDirs(); sInt64 numOfDirs();
void sortDir(); void sortDir();
int readDir(); int readDir();
void getEntry (const char* const, struct dirent*); void getEntry (const char* const, struct dirent*);
@ -216,7 +216,7 @@ class FFileDialog : public FDialog
// FMessageBox inline functions // FMessageBox inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FFileDialog::getClassName() const inline const FString FFileDialog::getClassName() const
{ return "FFileDialog"; } { return "FFileDialog"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -36,6 +36,8 @@
#endif #endif
#include <sys/time.h> #include <sys/time.h>
#include <functional>
#include "final/fstring.h"
#include "final/ftypes.h" #include "final/ftypes.h"
namespace finalcut namespace finalcut
@ -53,17 +55,21 @@ class FTermLinux;
class FKeyboardCommand final class FKeyboardCommand final
{ {
public: public:
// Constructor // Constructors
explicit FKeyboardCommand ( FApplication* = nullptr FKeyboardCommand () = default;
, void(FApplication::*)() = nullptr); explicit FKeyboardCommand (std::function<void()> fn)
: handler(fn)
{ }
// Method // Method
void execute(); void execute()
{
handler();
}
private: private:
// Data members // Data members
FApplication* instance{nullptr}; std::function<void()> handler{};
void (FApplication::*handler)(){nullptr};
}; };
@ -93,34 +99,34 @@ class FKeyboard final
FKeyboard& operator = (const FKeyboard&) = delete; FKeyboard& operator = (const FKeyboard&) = delete;
// Accessors // Accessors
virtual const char* getClassName() const; virtual const FString getClassName() const;
FKey getKey(); FKey getKey();
const FString getKeyName (FKey); const FString getKeyName (FKey);
keybuffer& getKeyBuffer(); keybuffer& getKeyBuffer();
timeval* getKeyPressedTime(); timeval* getKeyPressedTime();
// Mutators // Mutators
void setTermcapMap (fc::fkeymap*); void setTermcapMap (fc::fkeymap*);
void setKeypressTimeout (const uInt64); void setKeypressTimeout (const uInt64);
void enableUTF8(); void enableUTF8();
void disableUTF8(); void disableUTF8();
void enableMouseSequences(); void enableMouseSequences();
void disableMouseSequences(); void disableMouseSequences();
void setPressCommand (FKeyboardCommand); void setPressCommand (FKeyboardCommand);
void setReleaseCommand (FKeyboardCommand); void setReleaseCommand (FKeyboardCommand);
void setEscPressedCommand (FKeyboardCommand); void setEscPressedCommand (FKeyboardCommand);
// Inquiry // Inquiry
bool isInputDataPending(); bool isInputDataPending();
// Methods // Methods
static void init(); static void init();
bool& unprocessedInput(); bool& unprocessedInput();
bool isKeyPressed(); bool isKeyPressed();
void clearKeyBuffer(); void clearKeyBuffer();
void clearKeyBufferOnTimeout(); void clearKeyBufferOnTimeout();
void fetchKeyCode(); void fetchKeyCode();
void escapeKeyHandling(); void escapeKeyHandling();
private: private:
// Constants // Constants
@ -128,58 +134,58 @@ class FKeyboard final
static constexpr FKey NOT_SET = static_cast<FKey>(-1); static constexpr FKey NOT_SET = static_cast<FKey>(-1);
// Accessors // Accessors
FKey getMouseProtocolKey(); FKey getMouseProtocolKey();
FKey getTermcapKey(); FKey getTermcapKey();
FKey getMetaKey(); FKey getMetaKey();
FKey getSingleKey(); FKey getSingleKey();
// Mutators // Mutators
bool setNonBlockingInput (bool); bool setNonBlockingInput (bool);
bool setNonBlockingInput(); bool setNonBlockingInput();
bool unsetNonBlockingInput(); bool unsetNonBlockingInput();
// Inquiry // Inquiry
static bool isKeypressTimeout(); static bool isKeypressTimeout();
// Methods // Methods
FKey UTF8decode (const char[]); FKey UTF8decode (const char[]);
ssize_t readKey(); ssize_t readKey();
void parseKeyBuffer(); void parseKeyBuffer();
FKey parseKeyString(); FKey parseKeyString();
FKey keyCorrection (const FKey&); FKey keyCorrection (const FKey&);
void substringKeyHandling(); void substringKeyHandling();
void keyPressed(); void keyPressed();
void keyReleased(); void keyReleased();
void escapeKeyPressed(); void escapeKeyPressed();
// Data members // Data members
FKeyboardCommand keypressed_cmd{}; FKeyboardCommand keypressed_cmd{};
FKeyboardCommand keyreleased_cmd{}; FKeyboardCommand keyreleased_cmd{};
FKeyboardCommand escape_key_cmd{}; FKeyboardCommand escape_key_cmd{};
#if defined(__linux__) #if defined(__linux__)
#undef linux #undef linux
static FTermLinux* linux; static FTermLinux* linux;
#endif #endif
static timeval time_keypressed; static timeval time_keypressed;
static uInt64 key_timeout; static uInt64 key_timeout;
fc::fkeymap* key_map{nullptr}; fc::fkeymap* key_map{nullptr};
FKey key{0}; FKey key{0};
char read_buf[READ_BUF_SIZE]{'\0'}; char read_buf[READ_BUF_SIZE]{'\0'};
char fifo_buf[FIFO_BUF_SIZE]{'\0'}; char fifo_buf[FIFO_BUF_SIZE]{'\0'};
int fifo_offset{0}; int fifo_offset{0};
int stdin_status_flags{0}; int stdin_status_flags{0};
bool fifo_in_use{false}; bool fifo_in_use{false};
bool input_data_pending{false}; bool input_data_pending{false};
bool utf8_input{false}; bool utf8_input{false};
bool mouse_support{true}; bool mouse_support{true};
bool non_blocking_stdin{false}; bool non_blocking_stdin{false};
}; };
// FKeyboard inline functions // FKeyboard inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FKeyboard::getClassName() const inline const FString FKeyboard::getClassName() const
{ return "FKeyboard"; } { return "FKeyboard"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -98,7 +98,7 @@ class FLabel : public FWidget
const FLabel& operator >> (FString&); const FLabel& operator >> (FString&);
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
FWidget* getAccelWidget(); FWidget* getAccelWidget();
fc::text_alignment getAlignment(); fc::text_alignment getAlignment();
FString& getText(); FString& getText();
@ -165,7 +165,7 @@ class FLabel : public FWidget
// FLabel inline functions // FLabel inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FLabel::getClassName() const inline const FString FLabel::getClassName() const
{ return "FLabel"; } { return "FLabel"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -53,6 +53,8 @@
#endif #endif
#include <limits> #include <limits>
#include <utility>
#include "final/fwidget.h" #include "final/fwidget.h"
namespace finalcut namespace finalcut
@ -106,7 +108,7 @@ class FLineEdit : public FWidget
const FLineEdit& operator >> (FString&); const FLineEdit& operator >> (FString&);
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
FString getText() const; FString getText() const;
std::size_t getMaxLength() const; std::size_t getMaxLength() const;
std::size_t getCursorPosition() const; std::size_t getCursorPosition() const;
@ -210,7 +212,7 @@ class FLineEdit : public FWidget
// FLineEdit inline functions // FLineEdit inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FLineEdit::getClassName() const inline const FString FLineEdit::getClassName() const
{ return "FLineEdit"; } { return "FLineEdit"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -53,7 +53,7 @@ e Copyright 2014-2019 Markus Gans *
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include <memory> #include <unordered_map>
#include <vector> #include <vector>
#include "final/fscrollbar.h" #include "final/fscrollbar.h"
@ -86,32 +86,32 @@ class FListBoxItem
FListBoxItem& operator = (const FListBoxItem&); FListBoxItem& operator = (const FListBoxItem&);
// Accessors // Accessors
virtual const char* getClassName() const; virtual const FString getClassName() const;
virtual FString& getText(); virtual FString& getText();
virtual FDataPtr getData() const; virtual FDataPtr getData() const;
// Mutators // Mutators
void setText (const FString&); void setText (const FString&);
void setData (FDataPtr); void setData (FDataPtr);
// Methods // Methods
void clear(); void clear();
private: private:
// Data members
FString text{};
FDataPtr data_pointer{nullptr};
fc::brackets_type brackets{fc::NoBrackets};
bool selected{false};
// Friend classes // Friend classes
friend class FListBox; friend class FListBox;
// Data members
FString text{};
FDataPtr data_pointer{nullptr};
fc::brackets_type brackets{fc::NoBrackets};
bool selected{false};
}; };
// FListBoxItem inline functions // FListBoxItem inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FListBoxItem::getClassName() const inline const FString FListBoxItem::getClassName() const
{ return "FListBoxItem"; } { return "FListBoxItem"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -165,7 +165,7 @@ class FListBox : public FWidget
FListBox& operator = (const FListBox&) = delete; FListBox& operator = (const FListBox&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
std::size_t getCount() const; std::size_t getCount() const;
FListBoxItem getItem (std::size_t); FListBoxItem getItem (std::size_t);
FListBoxItem getItem (listBoxItems::iterator) const; FListBoxItem getItem (listBoxItems::iterator) const;
@ -238,6 +238,11 @@ class FListBox : public FWidget
void adjustSize() override; void adjustSize() override;
private: private:
// Typedefs
typedef std::unordered_map<int, std::function<void()>> keyMap;
typedef std::unordered_map<int, std::function<bool()>> keyMapResult;
typedef std::function<void(FListBoxItem&, FDataPtr, int)> lazyInsert;
// Enumeration // Enumeration
enum convert_type enum convert_type
{ {
@ -255,6 +260,8 @@ class FListBox : public FWidget
// Methods // Methods
void init(); void init();
void mapKeyFunctions();
void processKeyAction (FKeyEvent*);
void draw() override; void draw() override;
void drawBorder() override; void drawBorder() override;
void drawScrollbars(); void drawScrollbars();
@ -310,9 +317,7 @@ class FListBox : public FWidget
void cb_HBarChange (FWidget*, FDataPtr); void cb_HBarChange (FWidget*, FDataPtr);
// Function Pointer // Function Pointer
void (*convertToItem) ( FListBoxItem& lazyInsert lazy_inserter{};
, FDataPtr
, int index ){nullptr};
// Data members // Data members
listBoxItems itemlist{}; listBoxItems itemlist{};
@ -321,6 +326,8 @@ class FListBox : public FWidget
FScrollbarPtr hbar{nullptr}; FScrollbarPtr hbar{nullptr};
FString text{}; FString text{};
FString inc_search{}; FString inc_search{};
keyMap key_map{};
keyMapResult key_map_result{};
convert_type conv_type{FListBox::no_convert}; convert_type conv_type{FListBox::no_convert};
fc::dragScroll drag_scroll{fc::noScroll}; fc::dragScroll drag_scroll{fc::noScroll};
int scroll_repeat{100}; int scroll_repeat{100};
@ -369,7 +376,7 @@ inline FListBox::FListBox ( Container container
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FListBox::getClassName() const inline const FString FListBox::getClassName() const
{ return "FListBox"; } { return "FListBox"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -488,7 +495,7 @@ void FListBox::insert (Container container, LazyConverter convert)
{ {
conv_type = lazy_convert; conv_type = lazy_convert;
source_container = container; source_container = container;
convertToItem = convert; lazy_inserter = convert;
std::size_t size = container->size(); std::size_t size = container->size();
if ( size > 0 ) if ( size > 0 )

View File

@ -53,7 +53,6 @@
#endif #endif
#include <list> #include <list>
#include <memory>
#include <stack> #include <stack>
#include <vector> #include <vector>
@ -90,7 +89,7 @@ class FListViewItem : public FObject
FListViewItem& operator = (const FListViewItem&); FListViewItem& operator = (const FListViewItem&);
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
uInt getColumnCount() const; uInt getColumnCount() const;
int getSortColumn() const; int getSortColumn() const;
FString getText (int) const; FString getText (int) const;
@ -144,7 +143,7 @@ class FListViewItem : public FObject
// FListViewItem inline functions // FListViewItem inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FListViewItem::getClassName() const inline const FString FListViewItem::getClassName() const
{ return "FListViewItem"; } { return "FListViewItem"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -209,7 +208,7 @@ class FListViewIterator
bool operator != (const FListViewIterator&) const; bool operator != (const FListViewIterator&) const;
// Accessor // Accessor
const char* getClassName() const; const FString getClassName() const;
int getPosition() const; int getPosition() const;
// Methods // Methods
@ -245,7 +244,7 @@ inline bool FListViewIterator::operator != (const FListViewIterator& rhs) const
{ return node != rhs.node; } { return node != rhs.node; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FListViewIterator::getClassName() const inline const FString FListViewIterator::getClassName() const
{ return "FListViewIterator"; } { return "FListViewIterator"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -276,7 +275,7 @@ class FListView : public FWidget
FListView& operator = (const FListView&) = delete; FListView& operator = (const FListView&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
std::size_t getCount(); std::size_t getCount();
fc::text_alignment getColumnAlignment (int) const; fc::text_alignment getColumnAlignment (int) const;
FString getColumnText (int) const; FString getColumnText (int) const;
@ -360,6 +359,10 @@ class FListView : public FWidget
void adjustSize() override; void adjustSize() override;
private: private:
// Typedefs
typedef std::unordered_map<int, std::function<void()>> keyMap;
typedef std::unordered_map<int, std::function<bool()>> keyMapResult;
// Constants // Constants
static constexpr std::size_t checkbox_space = 4; static constexpr std::size_t checkbox_space = 4;
@ -377,6 +380,8 @@ class FListView : public FWidget
// Methods // Methods
void init(); void init();
void mapKeyFunctions();
void processKeyAction (FKeyEvent*);
template <typename Compare> template <typename Compare>
void sort (Compare); void sort (Compare);
std::size_t getAlignOffset ( fc::text_alignment std::size_t getAlignOffset ( fc::text_alignment
@ -415,8 +420,8 @@ class FListView : public FWidget
void processClick(); void processClick();
void processChanged(); void processChanged();
void toggleCheckbox(); void toggleCheckbox();
void collapseAndScrollLeft (int&); void collapseAndScrollLeft();
void expandAndScrollRight (int&); void expandAndScrollRight();
void firstPos(); void firstPos();
void lastPos(); void lastPos();
bool expandSubtree(); bool expandSubtree();
@ -451,10 +456,13 @@ class FListView : public FWidget
sortTypes sort_type{}; sortTypes sort_type{};
FPoint clicked_expander_pos{-1, -1}; FPoint clicked_expander_pos{-1, -1};
FPoint clicked_header_pos{-1, -1}; FPoint clicked_header_pos{-1, -1};
keyMap key_map{};
keyMapResult key_map_result{};
const FListViewItem* clicked_checkbox_item{nullptr}; const FListViewItem* clicked_checkbox_item{nullptr};
std::size_t nf_offset{0}; std::size_t nf_offset{0};
std::size_t max_line_width{1}; std::size_t max_line_width{1};
fc::dragScroll drag_scroll{fc::noScroll}; fc::dragScroll drag_scroll{fc::noScroll};
int first_line_position_before{-1};
int scroll_repeat{100}; int scroll_repeat{100};
int scroll_distance{1}; int scroll_distance{1};
int xoffset{0}; int xoffset{0};
@ -492,7 +500,7 @@ struct FListView::Header
// FListView inline functions // FListView inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FListView::getClassName() const inline const FString FListView::getClassName() const
{ return "FListView"; } { return "FListView"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -90,7 +90,7 @@ class FMenu : public FWindow, public FMenuList
FMenu& operator = (const FMenu&) = delete; FMenu& operator = (const FMenu&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
FString getText() const; FString getText() const;
FMenuItem* getItem(); FMenuItem* getItem();
@ -237,7 +237,7 @@ class FMenu : public FWindow, public FMenuList
// FMenu inline functions // FMenu inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FMenu::getClassName() const inline const FString FMenu::getClassName() const
{ return "FMenu"; } { return "FMenu"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -88,22 +88,22 @@ class FMenuBar : public FWindow, public FMenuList
FMenuBar& operator = (const FMenuBar&) = delete; FMenuBar& operator = (const FMenuBar&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
// Methods // Methods
void resetMenu(); void resetMenu();
void hide() override; void hide() override;
void adjustSize() override; void adjustSize() override;
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*) override; void onKeyPress (FKeyEvent*) override;
void onMouseDown (FMouseEvent*) override; void onMouseDown (FMouseEvent*) override;
void onMouseUp (FMouseEvent*) override; void onMouseUp (FMouseEvent*) override;
void onMouseMove (FMouseEvent*) override; void onMouseMove (FMouseEvent*) override;
void onAccel (FAccelEvent*) override; void onAccel (FAccelEvent*) override;
// Callback methods // Callback methods
void cb_item_deactivated (FWidget*, FDataPtr); void cb_item_deactivated (FWidget*, FDataPtr);
private: private:
// Constants // Constants
@ -119,49 +119,49 @@ class FMenuBar : public FWindow, public FMenuList
} menuText; } menuText;
// Inquiry // Inquiry
bool isMenu (const FMenuItem*) const; bool isMenu (const FMenuItem*) const;
// Methods // Methods
void init(); void init();
void calculateDimensions(); void calculateDimensions();
bool selectNextItem(); bool selectNextItem();
bool selectPrevItem(); bool selectPrevItem();
bool hotkeyMenu (FKeyEvent*&); bool hotkeyMenu (FKeyEvent*&);
void draw() override; void draw() override;
void drawItems(); void drawItems();
void drawItem (FMenuItem*, std::size_t&); void drawItem (FMenuItem*, std::size_t&);
void setLineAttributes (FMenuItem*); void setLineAttributes (FMenuItem*);
void setCursorToHotkeyPosition (FMenuItem*, std::size_t); void setCursorToHotkeyPosition (FMenuItem*, std::size_t);
void drawMenuText (menuText&); void drawMenuText (menuText&);
void drawEllipsis (const menuText&, std::size_t); void drawEllipsis (const menuText&, std::size_t);
void drawLeadingSpace (std::size_t&); void drawLeadingSpace (std::size_t&);
void drawTrailingSpace (std::size_t&); void drawTrailingSpace (std::size_t&);
void adjustItems(); void adjustItems();
bool activateMenu (FMenuItem*); bool activateMenu (FMenuItem*);
bool clickItem (FMenuItem*); bool clickItem (FMenuItem*);
void unselectMenuItem (FMenuItem*); void unselectMenuItem (FMenuItem*);
void selectMenuItem (FMenuItem*); void selectMenuItem (FMenuItem*);
void mouseDownOverList (const FMouseEvent*); void mouseDownOverList (const FMouseEvent*);
void mouseUpOverList (const FMouseEvent*); void mouseUpOverList (const FMouseEvent*);
void mouseMoveOverList (const FMouseEvent*); void mouseMoveOverList (const FMouseEvent*);
void passEventToMenu (const FMouseEvent*&); void passEventToMenu (const FMouseEvent*&);
void leaveMenuBar(); void leaveMenuBar();
// Friend classes // Friend classes
friend class FMenu; friend class FMenu;
friend class FMenuItem; friend class FMenuItem;
// Data members // Data members
std::size_t screenWidth{80}; std::size_t screenWidth{80};
bool mouse_down{false}; bool mouse_down{false};
bool drop_down{false}; bool drop_down{false};
bool focus_changed{false}; bool focus_changed{false};
}; };
// FMenuBar inline functions // FMenuBar inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FMenuBar::getClassName() const inline const FString FMenuBar::getClassName() const
{ return "FMenuBar"; } { return "FMenuBar"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -93,7 +93,7 @@ class FMenuItem : public FWidget
FMenuItem& operator = (const FMenuItem&) = delete; FMenuItem& operator = (const FMenuItem&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
FKey getHotkey() const; FKey getHotkey() const;
FMenu* getMenu() const; FMenu* getMenu() const;
std::size_t getTextLength() const; std::size_t getTextLength() const;
@ -199,7 +199,7 @@ class FMenuItem : public FWidget
// FMenuItem inline functions // FMenuItem inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FMenuItem::getClassName() const inline const FString FMenuItem::getClassName() const
{ return "FMenuItem"; } { return "FMenuItem"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -71,7 +71,7 @@ class FMenuList
FMenuList& operator = (const FMenuList&) = delete; FMenuList& operator = (const FMenuList&) = delete;
// Accessors // Accessors
virtual const char* getClassName() const; virtual const FString getClassName() const;
std::size_t getCount() const; std::size_t getCount() const;
FMenuItem* getItem (int) const; FMenuItem* getItem (int) const;
FMenuItem* getSelectedItem() const; FMenuItem* getSelectedItem() const;
@ -104,7 +104,7 @@ class FMenuList
// FMenuList inline functions // FMenuList inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FMenuList::getClassName() const inline const FString FMenuList::getClassName() const
{ return "FMenuList"; } { return "FMenuList"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -106,7 +106,7 @@ class FMessageBox : public FDialog
FMessageBox& operator = (const FMessageBox&); FMessageBox& operator = (const FMessageBox&);
// Accessor // Accessor
const char* getClassName() const override; const FString getClassName() const override;
const FString getTitlebarText() const; const FString getTitlebarText() const;
const FString getHeadline() const; const FString getHeadline() const;
const FString getText() const; const FString getText() const;
@ -168,7 +168,7 @@ class FMessageBox : public FDialog
// FMessageBox inline functions // FMessageBox inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FMessageBox::getClassName() const inline const FString FMessageBox::getClassName() const
{ return "FMessageBox"; } { return "FMessageBox"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -102,38 +102,38 @@ class FMouse
{ } { }
// Accessors // Accessors
virtual const char* getClassName() const; virtual const FString getClassName() const;
FPoint& getPos(); FPoint& getPos();
void clearEvent(); void clearEvent();
// Mutators // Mutators
void setMaxWidth (uInt16); void setMaxWidth (uInt16);
void setMaxHeight (uInt16); void setMaxHeight (uInt16);
void setDblclickInterval (const uInt64); void setDblclickInterval (const uInt64);
// Inquiries // Inquiries
virtual bool hasData() = 0; virtual bool hasData() = 0;
bool hasEvent(); bool hasEvent();
bool isLeftButtonPressed(); bool isLeftButtonPressed();
bool isLeftButtonReleased(); bool isLeftButtonReleased();
bool isLeftButtonDoubleClick(); bool isLeftButtonDoubleClick();
bool isRightButtonPressed(); bool isRightButtonPressed();
bool isRightButtonReleased(); bool isRightButtonReleased();
bool isMiddleButtonPressed(); bool isMiddleButtonPressed();
bool isMiddleButtonReleased(); bool isMiddleButtonReleased();
bool isShiftKeyPressed(); bool isShiftKeyPressed();
bool isControlKeyPressed(); bool isControlKeyPressed();
bool isMetaKeyPressed(); bool isMetaKeyPressed();
bool isWheelUp(); bool isWheelUp();
bool isWheelDown(); bool isWheelDown();
bool isMoved(); bool isMoved();
bool isInputDataPending(); bool isInputDataPending();
// Methods // Methods
static FMouse* createMouseObject (mouse_type); static FMouse* createMouseObject (mouse_type);
void clearButtonState(); void clearButtonState();
virtual void setRawData (FKeyboard::keybuffer&) = 0; virtual void setRawData (FKeyboard::keybuffer&) = 0;
virtual void processEvent (struct timeval*) = 0; virtual void processEvent (struct timeval*) = 0;
protected: protected:
// Typedef and Enumerations // Typedef and Enumerations
@ -207,7 +207,7 @@ class FMouseGPM final : public FMouse
virtual ~FMouseGPM(); virtual ~FMouseGPM();
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
// Mutators // Mutators
void setStdinNo(int); void setStdinNo(int);
@ -275,7 +275,7 @@ class FMouseX11 final : public FMouse
virtual ~FMouseX11() = default; virtual ~FMouseX11() = default;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
// Inquiry // Inquiry
bool hasData() override; bool hasData() override;
@ -334,14 +334,14 @@ class FMouseSGR final : public FMouse
virtual ~FMouseSGR() = default; virtual ~FMouseSGR() = default;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
// Inquiry // Inquiry
bool hasData() override; bool hasData() override;
// Methods // Methods
void setRawData (FKeyboard::keybuffer&) override; void setRawData (FKeyboard::keybuffer&) override;
void processEvent (struct timeval*) override; void processEvent (struct timeval*) override;
private: private:
// Enumeration // Enumeration
@ -368,10 +368,10 @@ class FMouseSGR final : public FMouse
static constexpr std::size_t MOUSE_BUF_SIZE = 13; static constexpr std::size_t MOUSE_BUF_SIZE = 13;
// Methods // Methods
void setKeyState (int); void setKeyState (int);
void setMoveState (const FPoint&, int); void setMoveState (const FPoint&, int);
void setPressedButtonState (int, struct timeval*); void setPressedButtonState (int, struct timeval*);
void setReleasedButtonState (int); void setReleasedButtonState (int);
// Data members // Data members
char sgr_mouse[MOUSE_BUF_SIZE]{'\0'}; char sgr_mouse[MOUSE_BUF_SIZE]{'\0'};
@ -393,14 +393,14 @@ class FMouseUrxvt final : public FMouse
virtual ~FMouseUrxvt() = default; virtual ~FMouseUrxvt() = default;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
// Inquiry // Inquiry
bool hasData() override; bool hasData() override;
// Methods // Methods
void setRawData (FKeyboard::keybuffer&) override; void setRawData (FKeyboard::keybuffer&) override;
void processEvent (struct timeval*) override; void processEvent (struct timeval*) override;
private: private:
// Enumeration // Enumeration
@ -428,9 +428,9 @@ class FMouseUrxvt final : public FMouse
static constexpr std::size_t MOUSE_BUF_SIZE = 13; static constexpr std::size_t MOUSE_BUF_SIZE = 13;
// Methods // Methods
void setKeyState (int); void setKeyState (int);
void setMoveState (const FPoint&, int); void setMoveState (const FPoint&, int);
void setButtonState (int, struct timeval*); void setButtonState (int, struct timeval*);
// Data members // Data members
char urxvt_mouse[MOUSE_BUF_SIZE]{'\0'}; char urxvt_mouse[MOUSE_BUF_SIZE]{'\0'};
@ -452,67 +452,67 @@ class FMouseControl
virtual ~FMouseControl(); virtual ~FMouseControl();
// Accessors // Accessors
virtual const char* getClassName() const; virtual const FString getClassName() const;
FPoint& getPos(); FPoint& getPos();
void clearEvent(); void clearEvent();
// Mutators // Mutators
void setStdinNo (int); void setStdinNo (int);
void setMaxWidth (uInt16); void setMaxWidth (uInt16);
void setMaxHeight (uInt16); void setMaxHeight (uInt16);
void setDblclickInterval (const uInt64); void setDblclickInterval (const uInt64);
void useGpmMouse (bool = true); void useGpmMouse (bool = true);
void useXtermMouse (bool = true); void useXtermMouse (bool = true);
// Inquiries // Inquiries
bool hasData(); bool hasData();
bool hasEvent(); bool hasEvent();
bool isLeftButtonPressed(); bool isLeftButtonPressed();
bool isLeftButtonReleased(); bool isLeftButtonReleased();
bool isLeftButtonDoubleClick(); bool isLeftButtonDoubleClick();
bool isRightButtonPressed(); bool isRightButtonPressed();
bool isRightButtonReleased(); bool isRightButtonReleased();
bool isMiddleButtonPressed(); bool isMiddleButtonPressed();
bool isMiddleButtonReleased(); bool isMiddleButtonReleased();
bool isShiftKeyPressed(); bool isShiftKeyPressed();
bool isControlKeyPressed(); bool isControlKeyPressed();
bool isMetaKeyPressed(); bool isMetaKeyPressed();
bool isWheelUp(); bool isWheelUp();
bool isWheelDown(); bool isWheelDown();
bool isMoved(); bool isMoved();
bool isInputDataPending(); bool isInputDataPending();
bool isGpmMouseEnabled(); bool isGpmMouseEnabled();
// Methods // Methods
void enable(); void enable();
void disable(); void disable();
virtual void setRawData ( FMouse::mouse_type virtual void setRawData ( FMouse::mouse_type
, FKeyboard::keybuffer& ); , FKeyboard::keybuffer& );
virtual void processEvent (struct timeval* time); virtual void processEvent (struct timeval* time);
bool getGpmKeyPressed (bool); bool getGpmKeyPressed (bool);
void drawGpmPointer(); void drawGpmPointer();
private: private:
// Typedef // Typedef
typedef std::map<FMouse::mouse_type, FMouse*> FMouseProtocol; typedef std::map<FMouse::mouse_type, FMouse*> FMouseProtocol;
// Accessor // Accessor
FMouse* getMouseWithData(); FMouse* getMouseWithData();
FMouse* getMouseWithEvent(); FMouse* getMouseWithEvent();
void xtermMouse (bool); void xtermMouse (bool);
void enableXTermMouse(); void enableXTermMouse();
void disableXTermMouse(); void disableXTermMouse();
// Data member // Data member
FMouseProtocol mouse_protocol{}; FMouseProtocol mouse_protocol{};
FPoint zero_point{0, 0}; FPoint zero_point{0, 0};
bool use_gpm_mouse{false}; bool use_gpm_mouse{false};
bool use_xterm_mouse{false}; bool use_xterm_mouse{false};
}; };
// FMouseControl inline functions // FMouseControl inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FMouseControl::getClassName() const inline const FString FMouseControl::getClassName() const
{ return "FMouseControl"; } { return "FMouseControl"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -89,41 +89,41 @@ class FObject
FObject& operator = (const FObject&) = delete; FObject& operator = (const FObject&) = delete;
// Accessors // Accessors
virtual const char* getClassName() const; virtual const FString getClassName() const;
FObject* getParent() const; FObject* getParent() const;
FObject* getChild (int) const; FObject* getChild (int) const;
FObjectList& getChildren(); FObjectList& getChildren();
const FObjectList& getChildren() const; const FObjectList& getChildren() const;
int numOfChildren() const; int numOfChildren() const;
iterator begin(); iterator begin();
iterator end(); iterator end();
const_iterator begin() const; const_iterator begin() const;
const_iterator end() const; const_iterator end() const;
// Inquiries // Inquiries
bool hasParent() const; bool hasParent() const;
bool hasChildren() const; bool hasChildren() const;
bool isChild (const FObject*) const; bool isChild (const FObject*) const;
bool isDirectChild (const FObject*) const; bool isDirectChild (const FObject*) const;
bool isWidget() const; bool isWidget() const;
bool isInstanceOf (const char[]) const; bool isInstanceOf (const FString&) const;
bool isTimerInUpdating() const; bool isTimerInUpdating() const;
// Methods // Methods
void removeParent(); void removeParent();
void addChild (FObject*); void addChild (FObject*);
void delChild (FObject*); void delChild (FObject*);
// Event handler // Event handler
virtual bool event (FEvent*); virtual bool event (FEvent*);
// Timer methods // Timer methods
static void getCurrentTime (timeval*); static void getCurrentTime (timeval*);
static bool isTimeout (timeval*, uInt64); static bool isTimeout (timeval*, uInt64);
int addTimer (int); int addTimer (int);
bool delTimer (int); bool delTimer (int);
bool delOwnTimer(); bool delOwnTimer();
bool delAllTimer(); bool delAllTimer();
protected: protected:
struct timer_data struct timer_data
@ -138,34 +138,35 @@ class FObject
typedef std::vector<timer_data> TimerList; typedef std::vector<timer_data> TimerList;
// Accessor // Accessor
TimerList* getTimerList() const; TimerList* getTimerList() const;
// Mutator // Mutator
void setWidgetProperty (bool); void setWidgetProperty (bool);
// Method // Method
uInt processTimerEvent(); uInt processTimerEvent();
// Event handler // Event handler
virtual void onTimer (FTimerEvent*); virtual void onTimer (FTimerEvent*);
virtual void onUserEvent (FUserEvent*); virtual void onUserEvent (FUserEvent*);
private: private:
// Method // Method
virtual void performTimerAction (const FObject*, const FEvent*); virtual void performTimerAction ( const FObject*
, const FEvent* );
// Data members // Data members
FObject* parent_obj{nullptr}; FObject* parent_obj{nullptr};
FObjectList children_list{}; // no children yet FObjectList children_list{}; // no children yet
bool has_parent{false}; bool has_parent{false};
bool widget_object{false}; bool widget_object{false};
static bool timer_modify_lock; static bool timer_modify_lock;
static TimerList* timer_list; static TimerList* timer_list;
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FObject::getClassName() const inline const FString FObject::getClassName() const
{ return "FObject"; } { return "FObject"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -217,8 +218,8 @@ inline bool FObject::isWidget() const
{ return widget_object; } { return widget_object; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FObject::isInstanceOf (const char classname[]) const inline bool FObject::isInstanceOf (const FString& classname) const
{ return ( classname ) ? bool(strcmp(classname, getClassName()) == 0) : false; } { return bool( classname == getClassName() ); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FObject::isTimerInUpdating() const inline bool FObject::isTimerInUpdating() const

View File

@ -58,6 +58,8 @@
#include <algorithm> // need for std::swap #include <algorithm> // need for std::swap
#include "final/fstring.h"
namespace finalcut namespace finalcut
{ {
@ -128,7 +130,7 @@ class FOptiAttr final
friend bool operator != (const charData&, const charData&); friend bool operator != (const charData&, const charData&);
// Accessors // Accessors
const char* getClassName() const; const FString getClassName() const;
// Mutators // Mutators
void setTermEnvironment (termEnv&); void setTermEnvironment (termEnv&);
@ -353,7 +355,7 @@ inline bool operator != ( const charData& lhs,
{ return ! ( lhs == rhs ); } { return ! ( lhs == rhs ); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FOptiAttr::getClassName() const inline const FString FOptiAttr::getClassName() const
{ return "FOptiAttr"; } { return "FOptiAttr"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -62,6 +62,8 @@
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include "final/fstring.h"
namespace finalcut namespace finalcut
{ {
@ -107,59 +109,59 @@ class FOptiMove final
virtual ~FOptiMove(); virtual ~FOptiMove();
// Accessors // Accessors
const char* getClassName() const; const FString getClassName() const;
uInt getCursorHomeLength() const; uInt getCursorHomeLength() const;
uInt getCarriageReturnLength() const; uInt getCarriageReturnLength() const;
uInt getCursorToLLLength() const; uInt getCursorToLLLength() const;
uInt getTabLength() const; uInt getTabLength() const;
uInt getBackTabLength() const; uInt getBackTabLength() const;
uInt getCursorUpLength() const; uInt getCursorUpLength() const;
uInt getCursorDownLength() const; uInt getCursorDownLength() const;
uInt getCursorLeftLength() const; uInt getCursorLeftLength() const;
uInt getCursorRightLength() const; uInt getCursorRightLength() const;
uInt getCursorAddressLength() const; uInt getCursorAddressLength() const;
uInt getColumnAddressLength() const; uInt getColumnAddressLength() const;
uInt getRowAddressLength() const; uInt getRowAddressLength() const;
uInt getParmUpCursorLength() const; uInt getParmUpCursorLength() const;
uInt getParmDownCursorLength() const; uInt getParmDownCursorLength() const;
uInt getParmLeftCursorLength() const; uInt getParmLeftCursorLength() const;
uInt getParmRightCursorLength() const; uInt getParmRightCursorLength() const;
uInt getEraseCharsLength() const; uInt getEraseCharsLength() const;
uInt getRepeatCharLength() const; uInt getRepeatCharLength() const;
uInt getClrBolLength() const; uInt getClrBolLength() const;
uInt getClrEolLength() const; uInt getClrEolLength() const;
// Mutators // Mutators
void setBaudRate (int); void setBaudRate (int);
void setTabStop (int); void setTabStop (int);
void setTermSize (std::size_t, std::size_t); void setTermSize (std::size_t, std::size_t);
void setTermEnvironment (termEnv&); void setTermEnvironment (termEnv&);
void set_cursor_home (char[]); void set_cursor_home (char[]);
void set_cursor_to_ll (char[]); void set_cursor_to_ll (char[]);
void set_carriage_return (char[]); void set_carriage_return (char[]);
void set_tabular (char[]); void set_tabular (char[]);
void set_back_tab (char[]); void set_back_tab (char[]);
void set_cursor_up (char[]); void set_cursor_up (char[]);
void set_cursor_down (char[]); void set_cursor_down (char[]);
void set_cursor_left (char[]); void set_cursor_left (char[]);
void set_cursor_right (char[]); void set_cursor_right (char[]);
void set_cursor_address (char[]); void set_cursor_address (char[]);
void set_column_address (char[]); void set_column_address (char[]);
void set_row_address (char[]); void set_row_address (char[]);
void set_parm_up_cursor (char[]); void set_parm_up_cursor (char[]);
void set_parm_down_cursor (char[]); void set_parm_down_cursor (char[]);
void set_parm_left_cursor (char[]); void set_parm_left_cursor (char[]);
void set_parm_right_cursor (char[]); void set_parm_right_cursor (char[]);
void set_erase_chars (char[]); void set_erase_chars (char[]);
void set_repeat_char (char[]); void set_repeat_char (char[]);
void set_clr_bol (char[]); void set_clr_bol (char[]);
void set_clr_eol (char[]); void set_clr_eol (char[]);
void set_auto_left_margin (bool); void set_auto_left_margin (bool);
void set_eat_newline_glitch (bool); void set_eat_newline_glitch (bool);
// Methods // Methods
void check_boundaries (int&, int&, int&, int&); void check_boundaries (int&, int&, int&, int&);
char* moveCursor (int, int, int, int); char* moveCursor (int, int, int, int);
private: private:
// Constant // Constant
@ -180,66 +182,66 @@ class FOptiMove final
// maximum character distance to avoid direct cursor addressing // maximum character distance to avoid direct cursor addressing
// Methods // Methods
void calculateCharDuration(); void calculateCharDuration();
int capDuration (char[], int); int capDuration (char[], int);
int capDurationToLength (int); int capDurationToLength (int);
int repeatedAppend (const capability&, volatile int, char*); int repeatedAppend (const capability&, volatile int, char*);
int relativeMove (char[], int, int, int, int); int relativeMove (char[], int, int, int, int);
int verticalMove (char[], int, int); int verticalMove (char[], int, int);
void downMove (char[], int&, int, int); void downMove (char[], int&, int, int);
void upMove (char[], int&, int, int); void upMove (char[], int&, int, int);
int horizontalMove (char[], int, int); int horizontalMove (char[], int, int);
void rightMove (char[], int&, int, int); void rightMove (char[], int&, int, int);
void leftMove (char[], int&, int, int); void leftMove (char[], int&, int, int);
bool isWideMove (int, int, int, int); bool isWideMove (int, int, int, int);
bool isMethod0Faster (int&, int, int); bool isMethod0Faster (int&, int, int);
bool isMethod1Faster (int&, int, int, int, int); bool isMethod1Faster (int&, int, int, int, int);
bool isMethod2Faster (int&, int, int, int); bool isMethod2Faster (int&, int, int, int);
bool isMethod3Faster (int&, int, int); bool isMethod3Faster (int&, int, int);
bool isMethod4Faster (int&, int, int); bool isMethod4Faster (int&, int, int);
bool isMethod5Faster (int&, int, int, int); bool isMethod5Faster (int&, int, int, int);
void moveByMethod (int, int, int, int, int); void moveByMethod (int, int, int, int, int);
// Friend function // Friend function
friend void printDurations (const FOptiMove&); friend void printDurations (const FOptiMove&);
// Data members // Data members
capability F_cursor_home{}; capability F_cursor_home{};
capability F_carriage_return{}; capability F_carriage_return{};
capability F_cursor_to_ll{}; capability F_cursor_to_ll{};
capability F_tab{}; capability F_tab{};
capability F_back_tab{}; capability F_back_tab{};
capability F_cursor_up{}; capability F_cursor_up{};
capability F_cursor_down{}; capability F_cursor_down{};
capability F_cursor_left{}; capability F_cursor_left{};
capability F_cursor_right{}; capability F_cursor_right{};
capability F_cursor_address{}; capability F_cursor_address{};
capability F_column_address{}; capability F_column_address{};
capability F_row_address{}; capability F_row_address{};
capability F_parm_up_cursor{}; capability F_parm_up_cursor{};
capability F_parm_down_cursor{}; capability F_parm_down_cursor{};
capability F_parm_left_cursor{}; capability F_parm_left_cursor{};
capability F_parm_right_cursor{}; capability F_parm_right_cursor{};
capability F_erase_chars{}; capability F_erase_chars{};
capability F_repeat_char{}; capability F_repeat_char{};
capability F_clr_bol{}; capability F_clr_bol{};
capability F_clr_eol{}; capability F_clr_eol{};
std::size_t screen_width{80}; std::size_t screen_width{80};
std::size_t screen_height{24}; std::size_t screen_height{24};
int char_duration{1}; int char_duration{1};
int baudrate{9600}; int baudrate{9600};
int tabstop{0}; int tabstop{0};
char move_buf[BUF_SIZE]{'\0'}; char move_buf[BUF_SIZE]{'\0'};
bool automatic_left_margin{false}; bool automatic_left_margin{false};
bool eat_nl_glitch{false}; bool eat_nl_glitch{false};
}; };
// FOptiMove inline functions // FOptiMove inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FOptiMove::getClassName() const inline const FString FOptiMove::getClassName() const
{ return "FOptiMove"; } { return "FOptiMove"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -37,6 +37,8 @@
#include <iostream> #include <iostream>
#include "final/fstring.h"
namespace finalcut namespace finalcut
{ {
@ -71,20 +73,20 @@ class FPoint
friend std::istream& operator >> (std::istream&, FPoint&); friend std::istream& operator >> (std::istream&, FPoint&);
// Accessors // Accessors
virtual const char* getClassName(); virtual const FString getClassName();
int getX() const; int getX() const;
int getY() const; int getY() const;
void setX (int); void setX (int);
void setY (int); void setY (int);
void setPoint (const FPoint&); void setPoint (const FPoint&);
void setPoint (int, int); void setPoint (int, int);
// Inquiry // Inquiry
bool isOrigin() const; bool isOrigin() const;
// Point references // Point references
int& x_ref(); int& x_ref();
int& y_ref(); int& y_ref();
private: private:
// Data members // Data members
@ -133,7 +135,7 @@ inline FPoint operator - (const FPoint& p)
{ return FPoint(-p.xpos, -p.ypos); } { return FPoint(-p.xpos, -p.ypos); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FPoint::getClassName() inline const FString FPoint::getClassName()
{ return "FPoint"; } { return "FPoint"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -74,7 +74,7 @@ class FProgressbar : public FWidget
virtual ~FProgressbar(); virtual ~FProgressbar();
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
std::size_t getPercentage(); std::size_t getPercentage();
// Mutators // Mutators
@ -111,7 +111,7 @@ class FProgressbar : public FWidget
// FProgressbar inline functions // FProgressbar inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FProgressbar::getClassName() const inline const FString FProgressbar::getClassName() const
{ return "FProgressbar"; } { return "FProgressbar"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -83,21 +83,21 @@ class FRadioButton : public FToggleButton
FRadioButton& operator = (const FRadioButton&) = delete; FRadioButton& operator = (const FRadioButton&) = delete;
// Accessor // Accessor
const char* getClassName() const override; const FString getClassName() const override;
private: private:
// Methods // Methods
void init(); void init();
void draw() override; void draw() override;
void drawRadioButton(); void drawRadioButton();
void drawChecked(); void drawChecked();
void drawUnchecked(); void drawUnchecked();
}; };
// FRadioButton inline functions // FRadioButton inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FRadioButton::getClassName() const inline const FString FRadioButton::getClassName() const
{ return "FRadioButton"; } { return "FRadioButton"; }
} // namespace finalcut } // namespace finalcut

View File

@ -83,18 +83,18 @@ class FRadioMenuItem : public FMenuItem
FRadioMenuItem& operator = (const FRadioMenuItem&) = delete; FRadioMenuItem& operator = (const FRadioMenuItem&) = delete;
// Accessor // Accessor
const char* getClassName() const override; const FString getClassName() const override;
private: private:
// Methods // Methods
void init (FWidget*); void init (FWidget*);
void processToggle(); void processToggle();
void processClicked() override; void processClicked() override;
}; };
// FRadioMenuItem inline functions // FRadioMenuItem inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FRadioMenuItem::getClassName() const inline const FString FRadioMenuItem::getClassName() const
{ return "FRadioMenuItem"; } { return "FRadioMenuItem"; }
} // namespace finalcut } // namespace finalcut

View File

@ -41,6 +41,8 @@
#include <algorithm> #include <algorithm>
#include "final/fstring.h"
namespace finalcut namespace finalcut
{ {
@ -78,61 +80,61 @@ class FRect
friend std::istream& operator >> (std::istream&, FRect&); friend std::istream& operator >> (std::istream&, FRect&);
// Accessors // Accessors
virtual const char* getClassName(); virtual const FString getClassName();
int getX1() const; int getX1() const;
int getY1() const; int getY1() const;
int getX2() const; int getX2() const;
int getY2() const; int getY2() const;
int getX() const; int getX() const;
int getY() const; int getY() const;
FPoint getPos() const; FPoint getPos() const;
FPoint getUpperLeftPos() const; FPoint getUpperLeftPos() const;
FPoint getUpperRightPos() const; FPoint getUpperRightPos() const;
FPoint getLowerLeftPos() const; FPoint getLowerLeftPos() const;
FPoint getLowerRightPos() const; FPoint getLowerRightPos() const;
std::size_t getWidth() const; std::size_t getWidth() const;
std::size_t getHeight() const; std::size_t getHeight() const;
FSize getSize() const; FSize getSize() const;
// Mutators // Mutators
void setX1 (int); void setX1 (int);
void setY1 (int); void setY1 (int);
void setX2 (int); void setX2 (int);
void setY2 (int); void setY2 (int);
void setX (int); void setX (int);
void setY (int); void setY (int);
void setPos (int, int); void setPos (int, int);
void setPos (const FPoint&); void setPos (const FPoint&);
void setWidth (std::size_t); void setWidth (std::size_t);
void setHeight (std::size_t); void setHeight (std::size_t);
void setSize (std::size_t, std::size_t); void setSize (std::size_t, std::size_t);
void setSize (const FSize&); void setSize (const FSize&);
void setRect (const FRect&); void setRect (const FRect&);
void setRect (const FPoint&, const FSize&); void setRect (const FPoint&, const FSize&);
void setRect (int, int, std::size_t, std::size_t); void setRect (int, int, std::size_t, std::size_t);
void setCoordinates (const FPoint&, const FPoint&); void setCoordinates (const FPoint&, const FPoint&);
void setCoordinates (int, int, int, int); void setCoordinates (int, int, int, int);
// Inquiry // Inquiry
bool isEmpty() const; bool isEmpty() const;
// Coordinate references // Coordinate references
int& x1_ref(); int& x1_ref();
int& y1_ref(); int& y1_ref();
int& x2_ref(); int& x2_ref();
int& y2_ref(); int& y2_ref();
// Methods // Methods
void move (int, int); void move (int, int);
void move (const FPoint&); void move (const FPoint&);
void scaleBy (int, int); void scaleBy (int, int);
void scaleBy (const FPoint&); void scaleBy (const FPoint&);
bool contains (int, int) const; bool contains (int, int) const;
bool contains (const FPoint&) const; bool contains (const FPoint&) const;
bool contains (const FRect&) const; bool contains (const FRect&) const;
bool overlap (const FRect&) const; bool overlap (const FRect&) const;
FRect intersect (const FRect&) const; FRect intersect (const FRect&) const;
FRect combined (const FRect&) const; FRect combined (const FRect&) const;
private: private:
// Data members // Data members
@ -171,7 +173,7 @@ inline FRect::FRect (int x, int y, std::size_t width, std::size_t height)
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FRect::getClassName() inline const FString FRect::getClassName()
{ return "FRect"; } { return "FRect"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -52,6 +52,9 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include <functional>
#include <memory>
#include "final/fwidget.h" #include "final/fwidget.h"
namespace finalcut namespace finalcut
@ -100,7 +103,7 @@ class FScrollbar : public FWidget
FScrollbar& operator = (const FScrollbar&) = delete; FScrollbar& operator = (const FScrollbar&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
int getValue() const; int getValue() const;
sType getScrollType() const; sType getScrollType() const;
@ -170,11 +173,11 @@ class FScrollbar : public FWidget
// non-member function forward declarations // non-member function forward declarations
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template<typename Callback> template<typename Instance, typename Callback>
void initScrollbar ( FScrollbarPtr& bar void initScrollbar ( FScrollbarPtr& bar
, fc::orientation o , fc::orientation o
, FWidget* cb_instance , Instance cb_instance
, Callback cb_handler ) , const Callback& cb_handler )
{ {
try try
{ {
@ -186,6 +189,7 @@ void initScrollbar ( FScrollbarPtr& bar
return; return;
} }
using namespace std::placeholders;
bar->setMinimum(0); bar->setMinimum(0);
bar->setValue(0); bar->setValue(0);
bar->hide(); bar->hide();
@ -193,14 +197,14 @@ void initScrollbar ( FScrollbarPtr& bar
bar->addCallback bar->addCallback
( (
"change-value", "change-value",
F_METHOD_CALLBACK (cb_instance, cb_handler) std::bind(cb_handler, cb_instance, _1, _2)
); );
} }
// FScrollbar inline functions // FScrollbar inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FScrollbar::getClassName() const inline const FString FScrollbar::getClassName() const
{ return "FScrollbar"; } { return "FScrollbar"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -53,7 +53,7 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include <memory> #include <unordered_map>
#include "final/fscrollbar.h" #include "final/fscrollbar.h"
#include "final/fwidget.h" #include "final/fwidget.h"
@ -85,7 +85,7 @@ class FScrollView : public FWidget
FScrollView& operator = (const FScrollView&) = delete; FScrollView& operator = (const FScrollView&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
std::size_t getViewportWidth() const; std::size_t getViewportWidth() const;
std::size_t getViewportHeight() const; std::size_t getViewportHeight() const;
const FSize getViewportSize(); const FSize getViewportSize();
@ -153,6 +153,9 @@ class FScrollView : public FWidget
void copy2area(); void copy2area();
private: private:
// Typedefs
typedef std::unordered_map<int, std::function<void()>> keyMap;
// Constants // Constants
static constexpr int vertical_border_spacing = 2; static constexpr int vertical_border_spacing = 2;
static constexpr int horizontal_border_spacing = 2; static constexpr int horizontal_border_spacing = 2;
@ -162,11 +165,12 @@ class FScrollView : public FWidget
// Methods // Methods
void init (FWidget*); void init (FWidget*);
void mapKeyFunctions();
void calculateScrollbarPos();
template<typename Callback> template<typename Callback>
void initScrollbar ( FScrollbarPtr& void initScrollbar ( FScrollbarPtr&
, fc::orientation , fc::orientation
, Callback ); , Callback );
void calculateScrollbarPos();
void setHorizontalScrollBarVisibility(); void setHorizontalScrollBarVisibility();
void setVerticalScrollBarVisibility(); void setVerticalScrollBarVisibility();
void setViewportCursor(); void setViewportCursor();
@ -176,22 +180,23 @@ class FScrollView : public FWidget
void cb_HBarChange (FWidget*, FDataPtr); void cb_HBarChange (FWidget*, FDataPtr);
// Data members // Data members
FRect scroll_geometry{1, 1, 1, 1}; FRect scroll_geometry{1, 1, 1, 1};
FRect viewport_geometry{}; FRect viewport_geometry{};
term_area* viewport{nullptr}; // virtual scroll content term_area* viewport{nullptr}; // virtual scroll content
FScrollbarPtr vbar{nullptr}; FScrollbarPtr vbar{nullptr};
FScrollbarPtr hbar{nullptr}; FScrollbarPtr hbar{nullptr};
uInt8 nf_offset{0}; keyMap key_map{};
bool border{true}; uInt8 nf_offset{0};
bool use_own_print_area{false}; bool border{true};
bool update_scrollbar{true}; bool use_own_print_area{false};
fc::scrollBarMode vMode{fc::Auto}; // fc:Auto, fc::Hidden or fc::Scroll bool update_scrollbar{true};
fc::scrollBarMode hMode{fc::Auto}; fc::scrollBarMode vMode{fc::Auto}; // fc:Auto, fc::Hidden or fc::Scroll
fc::scrollBarMode hMode{fc::Auto};
}; };
// FScrollView inline functions // FScrollView inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FScrollView::getClassName() const inline const FString FScrollView::getClassName() const
{ return "FScrollView"; } { return "FScrollView"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -38,6 +38,7 @@
#include <limits> #include <limits>
#include <iostream> #include <iostream>
#include "final/fstring.h"
#include "final/ftypes.h" #include "final/ftypes.h"
namespace finalcut namespace finalcut
@ -78,21 +79,21 @@ class FSize
friend std::istream& operator >> (std::istream&, FSize&); friend std::istream& operator >> (std::istream&, FSize&);
// Accessors // Accessors
virtual const char* getClassName(); virtual const FString getClassName();
std::size_t getWidth() const; std::size_t getWidth() const;
std::size_t getHeight() const; std::size_t getHeight() const;
std::size_t getArea() const; std::size_t getArea() const;
void setWidth (std::size_t); void setWidth (std::size_t);
void setHeight (std::size_t); void setHeight (std::size_t);
void setSize (FSize); void setSize (FSize);
void setSize (std::size_t, std::size_t); void setSize (std::size_t, std::size_t);
// Inquiry // Inquiry
bool isEmpty() const; bool isEmpty() const;
// Side references // Side references
std::size_t& width_ref(); std::size_t& width_ref();
std::size_t& height_ref(); std::size_t& height_ref();
private: private:
// Data members // Data members
@ -161,7 +162,7 @@ inline FSize operator - (const FSize& s1, const FSize& s2)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FSize::getClassName() inline const FString FSize::getClassName()
{ return "FSize"; } { return "FSize"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -38,6 +38,7 @@
#include <iostream> #include <iostream>
#include "final/fc.h" #include "final/fc.h"
#include "final/fstring.h"
#include "final/ftypes.h" #include "final/ftypes.h"
namespace finalcut namespace finalcut
@ -63,11 +64,15 @@ class FStartOptions final
FStartOptions& operator = (const FStartOptions&) = delete; FStartOptions& operator = (const FStartOptions&) = delete;
// Accessors // Accessors
virtual const FString getClassName();
static FStartOptions& getFStartOptions(); static FStartOptions& getFStartOptions();
// Mutator // Mutator
void setDefault(); void setDefault();
// Method
static void destroyObject();
// Data members // Data members
uInt8 cursor_optimisation : 1; uInt8 cursor_optimisation : 1;
uInt8 mouse_support : 1; uInt8 mouse_support : 1;
@ -90,6 +95,10 @@ class FStartOptions final
static FStartOptions* start_options; static FStartOptions* start_options;
}; };
//----------------------------------------------------------------------
inline const FString FStartOptions::getClassName()
{ return "FStartOptions"; }
} // namespace finalcut } // namespace finalcut
#endif // FSTARTOPTIONS_H #endif // FSTARTOPTIONS_H

View File

@ -59,6 +59,7 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include <memory>
#include <vector> #include <vector>
#include "final/fwidget.h" #include "final/fwidget.h"
@ -91,7 +92,7 @@ class FStatusKey : public FWidget
FStatusKey& operator = (const FStatusKey&) = delete; FStatusKey& operator = (const FStatusKey&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
virtual FKey getKey() const; virtual FKey getKey() const;
virtual FString getText() const; virtual FString getText() const;
@ -132,7 +133,7 @@ class FStatusKey : public FWidget
// FStatusKey inline functions // FStatusKey inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FStatusKey::getClassName() const inline const FString FStatusKey::getClassName() const
{ return "FStatusKey"; } { return "FStatusKey"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -200,7 +201,7 @@ class FStatusBar : public FWindow
FStatusBar& operator = (const FStatusBar&) = delete; FStatusBar& operator = (const FStatusBar&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
FStatusKey* getStatusKey (int) const; FStatusKey* getStatusKey (int) const;
FString getMessage() const; FString getMessage() const;
std::size_t getCount() const; std::size_t getCount() const;
@ -258,7 +259,7 @@ class FStatusBar : public FWindow
// FStatusBar inline functions // FStatusBar inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FStatusBar::getClassName() const inline const FString FStatusBar::getClassName() const
{ return "FStatusBar"; } { return "FStatusBar"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -55,6 +55,7 @@
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include <utility>
#include <vector> #include <vector>
#include "final/fc.h" #include "final/fc.h"
@ -181,7 +182,7 @@ class FString
friend std::wistream& operator >> (std::wistream&, FString&); friend std::wistream& operator >> (std::wistream&, FString&);
// Accessor // Accessor
virtual const char* getClassName(); virtual const FString getClassName();
// inquiries // inquiries
bool isNull() const; bool isNull() const;
@ -287,7 +288,7 @@ class FString
// FString inline functions // FString inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FString::getClassName() inline const FString FString::getClassName()
{ return "FString"; } { return "FString"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -83,7 +83,7 @@ class FSwitch : public FToggleButton
FSwitch& operator = (const FSwitch&) = delete; FSwitch& operator = (const FSwitch&) = delete;
// Accessor // Accessor
const char* getClassName() const override; const FString getClassName() const override;
// Mutator // Mutator
void setText (const FString&) override; void setText (const FString&) override;
@ -107,7 +107,7 @@ class FSwitch : public FToggleButton
// FSwitch inline functions // FSwitch inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FSwitch::getClassName() const inline const FString FSwitch::getClassName() const
{ return "FSwitch"; } { return "FSwitch"; }
} // namespace finalcut } // namespace finalcut

View File

@ -180,7 +180,8 @@ class FSystemImpl : public FSystem
int tputs (const char* str, int affcnt, int (*putc)(int)) override int tputs (const char* str, int affcnt, int (*putc)(int)) override
{ {
#if defined(__sun) && defined(__SVR4) #if defined(__sun) && defined(__SVR4)
return ::tputs (C_STR(str), affcnt, reinterpret_cast<int (*)(char)>(putc)); return ::tputs ( C_STR(str)
, affcnt, reinterpret_cast<int (*)(char)>(putc) );
#else #else
return ::tputs (str, affcnt, putc); return ::tputs (str, affcnt, putc);
#endif #endif

View File

@ -110,9 +110,12 @@
#include <clocale> #include <clocale>
#include <cmath> #include <cmath>
#include <csignal> #include <csignal>
#include <functional>
#include <map> #include <map>
#include <queue> #include <queue>
#include <utility>
#include <string> #include <string>
#include <vector>
#include "final/fc.h" #include "final/fc.h"
#include "final/fstring.h" #include "final/fstring.h"
@ -154,7 +157,8 @@ class FTermXTerminal;
class FTerm final class FTerm final
{ {
public: public:
struct initializationValues; // forward declaration // Typedef
typedef std::function<int(int)> defaultPutChar;
// Constructor // Constructor
explicit FTerm (bool = false); explicit FTerm (bool = false);
@ -169,7 +173,7 @@ class FTerm final
FTerm& operator = (const FTerm&) = delete; FTerm& operator = (const FTerm&) = delete;
// Accessors // Accessors
virtual const char* getClassName() const; virtual const FString getClassName() const;
static std::size_t getLineNumber(); static std::size_t getLineNumber();
static std::size_t getColumnNumber(); static std::size_t getColumnNumber();
static const FString getKeyName (FKey); static const FString getKeyName (FKey);
@ -278,9 +282,7 @@ class FTerm final
static bool scrollTermForward(); static bool scrollTermForward();
static bool scrollTermReverse(); static bool scrollTermReverse();
// function pointer -> static function static defaultPutChar& putchar(); // function pointer
static int (*Fputchar)(int);
template<typename... Args> template<typename... Args>
static void putstringf (const char[], Args&&...); static void putstringf (const char[], Args&&...);
static void putstring (const char[], int = 1); static void putstring (const char[], int = 1);
@ -399,7 +401,7 @@ std::size_t getColumnWidth (const FTermBuffer&);
// FTerm inline functions // FTerm inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTerm::getClassName() const inline const FString FTerm::getClassName() const
{ return "FTerm"; } { return "FTerm"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -427,8 +429,9 @@ inline void FTerm::putstringf (const char format[], Args&&... args)
if ( ! fsys ) if ( ! fsys )
getFSystem(); getFSystem();
std::vector<char> buf(size); std::size_t count = std::size_t(size);
std::snprintf (&buf[0], size, format, std::forward<Args>(args)...); std::vector<char> buf(count);
std::snprintf (&buf[0], count, format, std::forward<Args>(args)...);
fsys->tputs (&buf[0], 1, FTerm::putchar_ASCII); fsys->tputs (&buf[0], 1, FTerm::putchar_ASCII);
} }

View File

@ -37,6 +37,7 @@
#include <sstream> // std::stringstream #include <sstream> // std::stringstream
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
namespace finalcut namespace finalcut
@ -78,7 +79,7 @@ class FTermBuffer
, const FTermBuffer& ); , const FTermBuffer& );
// Accessors // Accessors
virtual const char* getClassName() const; virtual const FString getClassName() const;
std::size_t getLength() const; std::size_t getLength() const;
const charDataVector& getBuffer() const; const charDataVector& getBuffer() const;
@ -158,7 +159,7 @@ inline FTermBuffer& FTermBuffer::operator << (const FColorPair& pair)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTermBuffer::getClassName() const inline const FString FTermBuffer::getClassName() const
{ return "FTermBuffer"; } { return "FTermBuffer"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -90,7 +90,7 @@ class FTermcap final
~FTermcap() = default; ~FTermcap() = default;
// Accessors // Accessors
const char* getClassName() const; const FString getClassName() const;
// Methods // Methods
static void init(); static void init();
@ -128,7 +128,7 @@ class FTermcap final
// FTermcap inline functions // FTermcap inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTermcap::getClassName() const inline const FString FTermcap::getClassName() const
{ return "FTermcap"; } { return "FTermcap"; }
} // namespace finalcut } // namespace finalcut

View File

@ -56,7 +56,7 @@ class FTermcapQuirks final
virtual ~FTermcapQuirks(); virtual ~FTermcapQuirks();
// Accessor // Accessor
virtual const char* getClassName() const; virtual const FString getClassName() const;
// Methods // Methods
static void terminalFixup(); static void terminalFixup();
@ -85,7 +85,7 @@ class FTermcapQuirks final
// FTermcapQuirks inline functions // FTermcapQuirks inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTermcapQuirks::getClassName() const inline const FString FTermcapQuirks::getClassName() const
{ return "FTermcapQuirks"; } { return "FTermcapQuirks"; }
} // namespace finalcut } // namespace finalcut

View File

@ -69,7 +69,7 @@ class FTermData final
FTermData& operator = (const FTermData&) = delete; FTermData& operator = (const FTermData&) = delete;
// Accessors // Accessors
const char* getClassName() const; const FString getClassName() const;
encodingMap& getEncodingList(); encodingMap& getEncodingList();
charSubstitution& getCharSubstitutionMap(); charSubstitution& getCharSubstitutionMap();
fc::encoding getTermEncoding() const; fc::encoding getTermEncoding() const;
@ -132,8 +132,8 @@ class FTermData final
FString xterm_font{}; FString xterm_font{};
FString xterm_title{}; FString xterm_title{};
fc::encoding term_encoding{fc::UNKNOWN}; fc::encoding term_encoding{fc::UNKNOWN};
int fd_tty{-1}; // Teletype (tty) file descriptor is still undefined int fd_tty{-1}; // Teletype (tty) file descriptor
// is still undefined
#if DEBUG #if DEBUG
int framebuffer_bpp{-1}; int framebuffer_bpp{-1};
#endif #endif
@ -158,7 +158,7 @@ class FTermData final
// FTermData inline functions // FTermData inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTermData::getClassName() const inline const FString FTermData::getClassName() const
{ return "FTermData"; } { return "FTermData"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -86,7 +86,7 @@ class FTermDetection final
virtual ~FTermDetection(); virtual ~FTermDetection();
// Accessor // Accessor
const char* getClassName() const; const FString getClassName() const;
static char* getTermType(); static char* getTermType();
static int getGnomeTerminalID(); static int getGnomeTerminalID();
terminalType& getTermTypeStruct(); terminalType& getTermTypeStruct();
@ -222,7 +222,7 @@ class FTermDetection final
// FTermDetection inline functions // FTermDetection inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTermDetection::getClassName() const inline const FString FTermDetection::getClassName() const
{ return "FTermDetection"; } { return "FTermDetection"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -95,7 +95,7 @@ class FTermFreeBSD final
FTermFreeBSD& operator = (const FTermFreeBSD&) = delete; FTermFreeBSD& operator = (const FTermFreeBSD&) = delete;
// Accessors // Accessors
const char* getClassName() const; const FString getClassName() const;
static CursorStyle getCursorStyle(); static CursorStyle getCursorStyle();
// Inquiry // Inquiry
@ -135,7 +135,7 @@ class FTermFreeBSD final
// FTermFreeBSD inline functions // FTermFreeBSD inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTermFreeBSD::getClassName() const inline const FString FTermFreeBSD::getClassName() const
{ return "FTermFreeBSD"; } { return "FTermFreeBSD"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -38,6 +38,7 @@
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#include "final/fstring.h"
#include "final/ftypes.h" #include "final/ftypes.h"
namespace finalcut namespace finalcut
@ -57,43 +58,43 @@ class FTermios final
virtual ~FTermios(); virtual ~FTermios();
// Accessors // Accessors
const char* getClassName() const; const FString getClassName() const;
static termios getTTY(); static termios getTTY();
static int getStdIn(); static int getStdIn();
static int getStdOut(); static int getStdOut();
static int getStdErr(); static int getStdErr();
// Inquiries // Inquiries
static bool isRaw(); static bool isRaw();
// Methods // Methods
static void init(); static void init();
static void setTTY (const termios&); static void setTTY (const termios&);
static void storeTTYsettings(); static void storeTTYsettings();
static void restoreTTYsettings(); static void restoreTTYsettings();
static void setHardwareEcho(); static void setHardwareEcho();
static void unsetHardwareEcho(); static void unsetHardwareEcho();
static void setCaptureSendCharacters(); static void setCaptureSendCharacters();
static void unsetCaptureSendCharacters(); static void unsetCaptureSendCharacters();
static bool setRawMode (bool); static bool setRawMode (bool);
static bool setRawMode(); static bool setRawMode();
static bool unsetRawMode(); static bool unsetRawMode();
static bool setCookedMode(); static bool setCookedMode();
static uInt getBaudRate(); static uInt getBaudRate();
private: private:
// Data members // Data members
static int stdin_no; static int stdin_no;
static int stdout_no; static int stdout_no;
static int stderr_no; static int stderr_no;
static bool raw_mode; static bool raw_mode;
static struct termios term_init; static struct termios term_init;
}; };
// FTermios inline functions // FTermios inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTermios::getClassName() const inline const FString FTermios::getClassName() const
{ return "FTermios"; } { return "FTermios"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -85,45 +85,45 @@ class FTermLinux final
FTermLinux& operator = (const FTermLinux&) = delete; FTermLinux& operator = (const FTermLinux&) = delete;
// Accessors // Accessors
const char* getClassName() const; const FString getClassName() const;
static fc::linuxConsoleCursorStyle getCursorStyle(); fc::linuxConsoleCursorStyle getCursorStyle();
static char* getCursorStyleString(); char* getCursorStyleString();
static int getFramebufferBpp(); int getFramebufferBpp();
// Mutators // Mutators
static bool setCursorStyle (CursorStyle); bool setCursorStyle (CursorStyle);
static bool setPalette (FColor, int, int, int); bool setPalette (FColor, int, int, int);
static void setUTF8 (bool); void setUTF8 (bool);
// Inquiries // Inquiries
static bool isLinuxConsole(); bool isLinuxConsole();
static bool isVGAFontUsed(); bool isVGAFontUsed();
static bool isNewFontUsed(); bool isNewFontUsed();
// Methods // Methods
static void init(); void init();
static void initCharMap(); void initCharMap();
static void finish(); void finish();
static bool loadVGAFont(); bool loadVGAFont();
static bool loadNewFont(); bool loadNewFont();
static bool loadOldFont(); bool loadOldFont();
static bool saveColorMap(); bool saveColorMap();
static bool resetColorMap(); bool resetColorMap();
static void setBeep (int, int); void setBeep (int, int);
static void resetBeep(); void resetBeep();
static FKey modifierKeyCorrection (const FKey&); FKey modifierKeyCorrection (const FKey&);
private: private:
// Typedef // Typedef
static struct modifier_key // bit field struct modifier_key // bit field
{ {
uChar shift : 1; // 0..1 uChar shift : 1; // 0..1
uChar alt_gr : 1; // 0..1 uChar alt_gr : 1; // 0..1
uChar ctrl : 1; // 0..1 uChar ctrl : 1; // 0..1
uChar alt : 1; // 0..1 uChar alt : 1; // 0..1
uChar : 4; // padding bits uChar : 4; // padding bits
} mod_key; } mod_key{};
typedef struct typedef struct
{ {
@ -138,63 +138,63 @@ class FTermLinux final
} ColorMap; } ColorMap;
// Accessors // Accessors
static int getFramebuffer_bpp(); int getFramebuffer_bpp();
static bool getScreenFont(); bool getScreenFont();
static bool getUnicodeMap (); bool getUnicodeMap ();
static modifier_key& getModifierKey(); modifier_key& getModifierKey();
// Mutators // Mutators
static int setScreenFont ( uChar[], uInt, uInt, uInt int setScreenFont ( uChar[], uInt, uInt, uInt
, bool = false ); , bool = false );
static int setUnicodeMap (struct unimapdesc*); int setUnicodeMap (struct unimapdesc*);
static void setLinuxCursorStyle (fc::linuxConsoleCursorStyle); void setLinuxCursorStyle (fc::linuxConsoleCursorStyle);
// Methods // Methods
#if defined(__x86_64__) || defined(__i386) || defined(__arm__) #if defined(__x86_64__) || defined(__i386) || defined(__arm__)
static uInt16 getInputStatusRegisterOne(); uInt16 getInputStatusRegisterOne();
static uChar readAttributeController (uChar); uChar readAttributeController (uChar);
static void writeAttributeController (uChar, uChar); void writeAttributeController (uChar, uChar);
static uChar getAttributeMode(); uChar getAttributeMode();
static void setAttributeMode (uChar); void setAttributeMode (uChar);
static int setBlinkAsIntensity (bool); int setBlinkAsIntensity (bool);
static void getVGAPalette(); void getVGAPalette();
static void setVGADefaultPalette(); void setVGADefaultPalette();
static bool setVGAPalette (FColor, int, int, int); bool setVGAPalette (FColor, int, int, int);
static bool saveVGAPalette(); bool saveVGAPalette();
static bool resetVGAPalette(); bool resetVGAPalette();
#endif // defined(__x86_64__) || defined(__i386) || defined(__arm__) #endif // defined(__x86_64__) || defined(__i386) || defined(__arm__)
static FKey shiftKeyCorrection (const FKey&); FKey shiftKeyCorrection (const FKey&);
static FKey ctrlKeyCorrection (const FKey&); FKey ctrlKeyCorrection (const FKey&);
static FKey altKeyCorrection (const FKey&); FKey altKeyCorrection (const FKey&);
static FKey shiftCtrlKeyCorrection (const FKey&); FKey shiftCtrlKeyCorrection (const FKey&);
static FKey shiftAltKeyCorrection (const FKey&); FKey shiftAltKeyCorrection (const FKey&);
static FKey ctrlAltKeyCorrection (const FKey&); FKey ctrlAltKeyCorrection (const FKey&);
static FKey shiftCtrlAltKeyCorrection (const FKey&); FKey shiftCtrlAltKeyCorrection (const FKey&);
static sInt16 getFontPos (wchar_t ucs); sInt16 getFontPos (wchar_t ucs);
static void initSpecialCharacter(); void initSpecialCharacter();
static void characterFallback (wchar_t, std::vector<wchar_t>); void characterFallback (wchar_t, std::vector<wchar_t>);
// Data members // Data members
#if defined(__linux__) #if defined(__linux__)
static bool vga_font; bool vga_font{};
static bool new_font; bool new_font{};
static bool has_saved_palette; bool has_saved_palette{};
static FTermData* fterm_data; FTermData* fterm_data{nullptr};
static FSystem* fsystem; FSystem* fsystem{nullptr};
static FTermDetection* term_detection; FTermDetection* term_detection{nullptr};
static CursorStyle linux_console_cursor_style; CursorStyle linux_console_cursor_style{};
static console_font_op screen_font; console_font_op screen_font{};
static unimapdesc screen_unicode_map; unimapdesc screen_unicode_map{};
static ColorMap saved_color_map; ColorMap saved_color_map{};
static ColorMap cmap; ColorMap cmap{};
static int framebuffer_bpp; int framebuffer_bpp{-1};
#endif // defined(__linux__) #endif // defined(__linux__)
}; };
// FTermLinux inline functions // FTermLinux inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTermLinux::getClassName() const inline const FString FTermLinux::getClassName() const
{ return "FTermLinux"; } { return "FTermLinux"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -45,7 +45,7 @@
#define WSKBD_BELL_DOPITCH 0x1 // get/set pitch #define WSKBD_BELL_DOPITCH 0x1 // get/set pitch
#define WSKBD_BELL_DOPERIOD 0x2 // get/set period #define WSKBD_BELL_DOPERIOD 0x2 // get/set period
#define WSKBD_BELL_DOVOLUME 0x4 // get/set volume #define WSKBD_BELL_DOVOLUME 0x4 // get/set volume
#define WSKBD_BELL_DOALL 0x7 // all of the above #define WSKBD_BELL_DOALL 0x7 // all of the above
typedef uInt32 kbd_t; typedef uInt32 kbd_t;
@ -87,7 +87,7 @@ class FTermOpenBSD final
FTermOpenBSD& operator = (const FTermOpenBSD&) = delete; FTermOpenBSD& operator = (const FTermOpenBSD&) = delete;
// Accessor // Accessor
const char* getClassName() const; const FString getClassName() const;
// Inquiries // Inquiries
static bool isBSDConsole(); static bool isBSDConsole();
@ -120,7 +120,7 @@ class FTermOpenBSD final
// FTermOpenBSD inline functions // FTermOpenBSD inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTermOpenBSD::getClassName() const inline const FString FTermOpenBSD::getClassName() const
{ return "FTermOpenBSD"; } { return "FTermOpenBSD"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -57,107 +57,107 @@ class FTermXTerminal final
virtual ~FTermXTerminal(); virtual ~FTermXTerminal();
// Mutators // Mutators
static void redefineDefaultColors (bool); void redefineDefaultColors (bool);
static void setCursorStyle (fc::xtermCursorStyle); void setCursorStyle (fc::xtermCursorStyle);
static void setFont (const FString&); void setFont (const FString&);
static void setTitle (const FString&); void setTitle (const FString&);
static void setTermSize (const FSize&); void setTermSize (const FSize&);
static void setForeground (const FString&); void setForeground (const FString&);
static void setBackground (const FString&); void setBackground (const FString&);
static void setCursorColor (const FString&); void setCursorColor (const FString&);
static void setMouseForeground (const FString&); void setMouseForeground (const FString&);
static void setMouseBackground (const FString&); void setMouseBackground (const FString&);
static void setHighlightBackground (const FString&); void setHighlightBackground (const FString&);
static void setMouseSupport (bool); static void setMouseSupport (bool);
static void setMouseSupport(); static void setMouseSupport();
static void unsetMouseSupport(); static void unsetMouseSupport();
static void metaSendsESC (bool); void metaSendsESC (bool);
// Accessors // Accessors
const char* getClassName() const; const FString getClassName() const;
static fc::xtermCursorStyle getCursorStyle(); fc::xtermCursorStyle getCursorStyle();
static const FString getFont(); const FString getFont();
static const FString getTitle(); const FString getTitle();
static const FString getForeground(); const FString getForeground();
static const FString getBackground(); const FString getBackground();
static const FString getCursorColor(); const FString getCursorColor();
static const FString getMouseForeground(); const FString getMouseForeground();
static const FString getMouseBackground(); const FString getMouseBackground();
static const FString getHighlightBackground(); const FString getHighlightBackground();
// Inquiries // Inquiries
static bool hasFont(); bool hasFont();
static bool hasTitle(); bool hasTitle();
// Methods // Methods
static void init(); void init();
static void setDefaults(); void setDefaults();
static void resetColorMap(); void resetColorMap();
static void resetForeground(); void resetForeground();
static void resetBackground(); void resetBackground();
static void resetCursorColor(); void resetCursorColor();
static void resetMouseForeground(); void resetMouseForeground();
static void resetMouseBackground(); void resetMouseBackground();
static void resetHighlightBackground(); void resetHighlightBackground();
static void resetDefaults(); void resetDefaults();
static void captureFontAndTitle(); void captureFontAndTitle();
private: private:
// Methods // Methods
static void setXTermCursorStyle(); void setXTermCursorStyle();
static void setXTermFont(); void setXTermFont();
static void setXTermTitle(); void setXTermTitle();
static void setXTermSize(); void setXTermSize();
static void setXTermForeground(); void setXTermForeground();
static void setXTermBackground(); void setXTermBackground();
static void setXTermCursorColor(); void setXTermCursorColor();
static void setXTermMouseForeground(); void setXTermMouseForeground();
static void setXTermMouseBackground(); void setXTermMouseBackground();
static void setXTermHighlightBackground(); void setXTermHighlightBackground();
static void setXTerm8ColorDefaults(); void setXTerm8ColorDefaults();
static void setXTerm16ColorDefaults(); void setXTerm16ColorDefaults();
static void setXTermDefaultsMouseCursor(); void setXTermDefaultsMouseCursor();
static bool canSetXTermBackground(); bool canSetXTermBackground();
static void resetXTermColorMap(); void resetXTermColorMap();
static void resetXTermForeground(); void resetXTermForeground();
static void resetXTermBackground(); void resetXTermBackground();
static void resetXTermCursorColor(); void resetXTermCursorColor();
static void resetXTermMouseForeground(); void resetXTermMouseForeground();
static void resetXTermMouseBackground(); void resetXTermMouseBackground();
static void resetXTermHighlightBackground(); void resetXTermHighlightBackground();
static bool canResetColor(); bool canResetColor();
static void oscPrefix(); void oscPrefix();
static void oscPostfix(); void oscPostfix();
static const FString captureXTermFont(); const FString captureXTermFont();
static const FString captureXTermTitle(); const FString captureXTermTitle();
static void enableXTermMouse(); static void enableXTermMouse();
static void disableXTermMouse(); static void disableXTermMouse();
static void enableXTermMetaSendsESC(); void enableXTermMetaSendsESC();
static void disableXTermMetaSendsESC(); void disableXTermMetaSendsESC();
// Data members // Data members
static bool mouse_support; static bool mouse_support;
static bool meta_sends_esc; bool meta_sends_esc{false};
static bool xterm_default_colors; bool xterm_default_colors{false};
static std::size_t term_width; std::size_t term_width{80};
static std::size_t term_height; std::size_t term_height{24};
static FString xterm_font; FString xterm_font{};
static FString xterm_title; FString xterm_title{};
static FString foreground_color; FString foreground_color{};
static FString background_color; FString background_color{};
static FString cursor_color; FString cursor_color{};
static FString mouse_foreground_color; FString mouse_foreground_color{};
static FString mouse_background_color; FString mouse_background_color{};
static FString highlight_background_color; FString highlight_background_color{};
static FSystem* fsystem; static FSystem* fsystem;
static FTermDetection* term_detection; FTermDetection* term_detection{nullptr};
static fc::xtermCursorStyle cursor_style; fc::xtermCursorStyle cursor_style{fc::unknown_cursor_style};
}; };
// FTermXTerminal inline functions // FTermXTerminal inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTermXTerminal::getClassName() const inline const FString FTermXTerminal::getClassName() const
{ return "FTermXTerminal"; } { return "FTermXTerminal"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -52,7 +52,8 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include <memory> #include <string>
#include <unordered_map>
#include <vector> #include <vector>
#include "final/fwidget.h" #include "final/fwidget.h"
@ -93,7 +94,7 @@ class FTextView : public FWidget
FTextView& operator << (const std::string&); FTextView& operator << (const std::string&);
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
std::size_t getColumns() const; std::size_t getColumns() const;
std::size_t getRows() const; std::size_t getRows() const;
const FString getText() const; const FString getText() const;
@ -136,6 +137,9 @@ class FTextView : public FWidget
void adjustSize() override; void adjustSize() override;
private: private:
// Typedefs
typedef std::unordered_map<int, std::function<void()>> keyMap;
// Accessors // Accessors
std::size_t getTextHeight(); std::size_t getTextHeight();
std::size_t getTextWidth(); std::size_t getTextWidth();
@ -146,6 +150,7 @@ class FTextView : public FWidget
// Methods // Methods
void init(); void init();
void mapKeyFunctions();
void draw() override; void draw() override;
void drawBorder() override; void drawBorder() override;
void drawScrollbars(); void drawScrollbars();
@ -162,6 +167,7 @@ class FTextView : public FWidget
FStringList data{}; FStringList data{};
FScrollbarPtr vbar{nullptr}; FScrollbarPtr vbar{nullptr};
FScrollbarPtr hbar{nullptr}; FScrollbarPtr hbar{nullptr};
keyMap key_map{};
bool update_scrollbar{true}; bool update_scrollbar{true};
int xoffset{0}; int xoffset{0};
int yoffset{0}; int yoffset{0};
@ -205,7 +211,7 @@ inline FTextView& FTextView::operator << (const std::string& string)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTextView::getClassName() const inline const FString FTextView::getClassName() const
{ return "FTextView"; } { return "FTextView"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -84,7 +84,7 @@ class FToggleButton : public FWidget
FToggleButton& operator = (const FToggleButton&) = delete; FToggleButton& operator = (const FToggleButton&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
FString& getText(); FString& getText();
// Mutators // Mutators
@ -167,7 +167,7 @@ class FToggleButton : public FWidget
// FRadioButton inline functions // FRadioButton inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FToggleButton::getClassName() const inline const FString FToggleButton::getClassName() const
{ return "FToggleButton"; } { return "FToggleButton"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -85,7 +85,7 @@ class FToolTip : public FWindow
FToolTip& operator = (const FToolTip&) = delete; FToolTip& operator = (const FToolTip&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
const FString getText() const; const FString getText() const;
// Mutators // Mutators
@ -115,7 +115,7 @@ class FToolTip : public FWindow
// FToolTip inline functions // FToolTip inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FToolTip::getClassName() const inline const FString FToolTip::getClassName() const
{ return "FToolTip"; } { return "FToolTip"; }
} // namespace finalcut } // namespace finalcut

View File

@ -51,15 +51,20 @@
#include <queue> #include <queue>
#include <sstream> // std::stringstream #include <sstream> // std::stringstream
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
#include "final/fc.h" #include "final/fc.h"
#include "final/fterm.h" #include "final/fterm.h"
// Preprocessing handler macro // Preprocessing handler macro
//#define F_PREPROC_HANDLER(i,h)
// static_cast<FVTerm*>((i))
// , reinterpret_cast<FVTerm::FPreprocessingHandler>((h))
#define F_PREPROC_HANDLER(i,h) \ #define F_PREPROC_HANDLER(i,h) \
static_cast<FVTerm*>((i)) \ reinterpret_cast<FVTerm*>((i)), \
, reinterpret_cast<FVTerm::FPreprocessingHandler>((h)) std::bind ( reinterpret_cast<FVTerm::FPreprocessingHandler>((h)) \
, reinterpret_cast<FVTerm*>((i)) )
namespace finalcut namespace finalcut
{ {
@ -94,13 +99,14 @@ class FVTerm
} line_changes; } line_changes;
typedef void (FVTerm::*FPreprocessingHandler)(); typedef void (FVTerm::*FPreprocessingHandler)();
typedef std::function<void()> FVTermPreprocessing;
struct term_area; // forward declaration struct term_area; // forward declaration
struct vterm_preprocessing struct vterm_preprocessing
{ {
FVTerm* instance; FVTerm* instance;
FPreprocessingHandler handler; FVTermPreprocessing function;
}; };
typedef std::vector<vterm_preprocessing> FPreprocessing; typedef std::vector<vterm_preprocessing> FPreprocessing;
@ -142,7 +148,7 @@ class FVTerm
FVTerm& operator << (const FColorPair&); FVTerm& operator << (const FColorPair&);
// Accessors // Accessors
virtual const char* getClassName() const; virtual const FString getClassName() const;
static FColor getTermForegroundColor(); static FColor getTermForegroundColor();
static FColor getTermBackgroundColor(); static FColor getTermBackgroundColor();
term_area*& getVWin(); term_area*& getVWin();
@ -288,7 +294,7 @@ class FVTerm
void updateTerminal (terminal_update); void updateTerminal (terminal_update);
void updateTerminal(); void updateTerminal();
virtual void addPreprocessingHandler ( FVTerm* virtual void addPreprocessingHandler ( FVTerm*
, FPreprocessingHandler ); , FVTermPreprocessing );
virtual void delPreprocessingHandler (FVTerm*); virtual void delPreprocessingHandler (FVTerm*);
template<typename... Args> template<typename... Args>
@ -497,7 +503,6 @@ class FVTerm
static uInt clr_bol_length; static uInt clr_bol_length;
static uInt clr_eol_length; static uInt clr_eol_length;
static uInt cursor_address_length; static uInt cursor_address_length;
}; };
@ -589,7 +594,7 @@ inline FVTerm& FVTerm::operator << (const FColorPair& pair)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FVTerm::getClassName() const inline const FString FVTerm::getClassName() const
{ return "FVTerm"; } { return "FVTerm"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -95,6 +95,7 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include <functional>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -107,11 +108,14 @@
// Callback macros // Callback macros
#define F_FUNCTION_CALLBACK(h) \ #define F_FUNCTION_CALLBACK(h) \
reinterpret_cast<finalcut::FWidget::FCallback>((h)) reinterpret_cast<finalcut::FWidget::FCallbackPtr>((h))
#define F_METHOD_CALLBACK(i,h) \ #define F_METHOD_CALLBACK(i,h) \
reinterpret_cast<finalcut::FWidget*>((i)) \ reinterpret_cast<finalcut::FWidget*>((i)), \
, reinterpret_cast<finalcut::FWidget::FMemberCallback>((h)) std::bind ( reinterpret_cast<finalcut::FWidget::FMemberCallback>((h)) \
, reinterpret_cast<finalcut::FWidget*>((i)) \
, std::placeholders::_1 \
, std::placeholders::_2 )
namespace finalcut namespace finalcut
{ {
@ -144,8 +148,9 @@ class FWidget : public FVTerm, public FObject
// Typedefs // Typedefs
typedef std::vector<FWidget*> widgetList; typedef std::vector<FWidget*> widgetList;
typedef std::vector<accelerator> Accelerators; typedef std::vector<accelerator> Accelerators;
typedef void (*FCallback)(FWidget*, FDataPtr); typedef void (*FCallbackPtr)(FWidget*, FDataPtr);
typedef void (FWidget::*FMemberCallback)(FWidget*, FDataPtr); typedef void (FWidget::*FMemberCallback)(FWidget*, FDataPtr);
typedef std::function<void(FWidget*, FDataPtr)> FCallback;
struct widget_flags // Properties of a widget ⚑ struct widget_flags // Properties of a widget ⚑
{ {
@ -183,7 +188,7 @@ class FWidget : public FVTerm, public FObject
FWidget& operator = (const FWidget&) = delete; FWidget& operator = (const FWidget&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
FWidget* getRootWidget() const; FWidget* getRootWidget() const;
FWidget* getParentWidget() const; FWidget* getParentWidget() const;
static FWidget*& getMainWidget(); static FWidget*& getMainWidget();
@ -315,7 +320,7 @@ class FWidget : public FVTerm, public FObject
, FDataPtr = nullptr ); , FDataPtr = nullptr );
void addCallback ( const FString& void addCallback ( const FString&
, FWidget* , FWidget*
, FMemberCallback , FCallback
, FDataPtr = nullptr ); , FDataPtr = nullptr );
void delCallback (FCallback); void delCallback (FCallback);
void delCallback (FWidget*); void delCallback (FWidget*);
@ -346,21 +351,13 @@ class FWidget : public FVTerm, public FObject
struct callback_data struct callback_data
{ {
FString cb_signal; FString cb_signal;
FCallback cb_handler; FWidget* cb_instance;
FCallback cb_function;
FDataPtr data; FDataPtr data;
}; };
struct member_callback_data
{
FString cb_signal;
FWidget* cb_instance;
FMemberCallback cb_handler;
FDataPtr data;
};
// Typedefs // Typedefs
typedef std::vector<callback_data> CallbackObjects; typedef std::vector<callback_data> CallbackObjects;
typedef std::vector<member_callback_data> MemberCallbackObjects;
// Accessor // Accessor
term_area* getPrintArea() override; term_area* getPrintArea() override;
@ -370,7 +367,7 @@ class FWidget : public FVTerm, public FObject
static widgetList*& getAlwaysOnTopList(); static widgetList*& getAlwaysOnTopList();
static widgetList*& getWidgetCloseList(); static widgetList*& getWidgetCloseList();
void addPreprocessingHandler ( FVTerm* void addPreprocessingHandler ( FVTerm*
, FPreprocessingHandler ) override; , FVTermPreprocessing ) override;
void delPreprocessingHandler (FVTerm*) override; void delPreprocessingHandler (FVTerm*) override;
// Inquiry // Inquiry
@ -417,6 +414,7 @@ class FWidget : public FVTerm, public FObject
void insufficientSpaceAdjust(); void insufficientSpaceAdjust();
void KeyPressEvent (FKeyEvent*); void KeyPressEvent (FKeyEvent*);
void KeyDownEvent (FKeyEvent*); void KeyDownEvent (FKeyEvent*);
FCallbackPtr getCallbackPtr (FCallback);
bool changeFocus (FWidget*, FWidget*, fc::FocusTypes); bool changeFocus (FWidget*, FWidget*, fc::FocusTypes);
void processDestroy(); void processDestroy();
virtual void draw(); virtual void draw();
@ -495,7 +493,6 @@ class FWidget : public FVTerm, public FObject
FColor background_color{fc::Default}; FColor background_color{fc::Default};
FString statusbar_message{}; FString statusbar_message{};
Accelerators* accelerator_list{nullptr}; Accelerators* accelerator_list{nullptr};
MemberCallbackObjects member_callback_objects{};
CallbackObjects callback_objects{}; CallbackObjects callback_objects{};
static FStatusBar* statusbar; static FStatusBar* statusbar;
@ -532,7 +529,7 @@ void drawBorder (FWidget*, FRect);
// FWidget inline functions // FWidget inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FWidget::getClassName() const inline const FString FWidget::getClassName() const
{ return "FWidget"; } { return "FWidget"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -88,7 +88,7 @@ class FWindow : public FWidget
FWindow& operator = (const FWindow&) = delete; FWindow& operator = (const FWindow&) = delete;
// Accessors // Accessors
const char* getClassName() const override; const FString getClassName() const override;
static FWindow* getWindowWidget (const FWidget*); static FWindow* getWindowWidget (const FWidget*);
static int getWindowLayer (const FWidget*); static int getWindowLayer (const FWidget*);
FWidget* getWindowFocusWidget() const; FWidget* getWindowFocusWidget() const;
@ -182,7 +182,7 @@ class FWindow : public FWidget
// FWindow inline functions // FWindow inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FWindow::getClassName() const inline const FString FWindow::getClassName() const
{ return "FWindow"; } { return "FWindow"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -71,8 +71,8 @@ class FColorPairTest : public CPPUNIT_NS::TestFixture
void FColorPairTest::classNameTest() void FColorPairTest::classNameTest()
{ {
const finalcut::FColorPair p; const finalcut::FColorPair p;
const char* const classname = p.getClassName(); const finalcut::FString& classname = p.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname, "FColorPair") == 0 ); CPPUNIT_ASSERT ( classname == "FColorPair" );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -293,8 +293,8 @@ FKeyboardTest::~FKeyboardTest()
void FKeyboardTest::classNameTest() void FKeyboardTest::classNameTest()
{ {
finalcut::FKeyboard k; finalcut::FKeyboard k;
const char* const classname = k.getClassName(); const finalcut::FString& classname = k.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname, "FKeyboard") == 0 ); CPPUNIT_ASSERT ( classname == "FKeyboard" );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2779,17 +2779,12 @@ void FKeyboardTest::unknownKeyTest()
void FKeyboardTest::init() void FKeyboardTest::init()
{ {
keyboard = new finalcut::FKeyboard(); keyboard = new finalcut::FKeyboard();
finalcut::FApplication* object = \ auto cmd1 = std::bind(&FKeyboardTest::keyPressed, this);
reinterpret_cast<finalcut::FApplication*>(this); auto cmd2 = std::bind(&FKeyboardTest::keyReleased, this);
void (finalcut::FApplication::*method1)() auto cmd3 = std::bind(&FKeyboardTest::escapeKeyPressed, this);
= reinterpret_cast<void(finalcut::FApplication::*)()>(&FKeyboardTest::keyPressed); finalcut::FKeyboardCommand key_cmd1 (cmd1);
void (finalcut::FApplication::*method2)() finalcut::FKeyboardCommand key_cmd2 (cmd2);
= reinterpret_cast<void(finalcut::FApplication::*)()>(&FKeyboardTest::keyReleased); finalcut::FKeyboardCommand key_cmd3 (cmd3);
void (finalcut::FApplication::*method3)()
= reinterpret_cast<void(finalcut::FApplication::*)()>(&FKeyboardTest::escapeKeyPressed);
finalcut::FKeyboardCommand key_cmd1 (object, method1);
finalcut::FKeyboardCommand key_cmd2 (object, method2);
finalcut::FKeyboardCommand key_cmd3 (object, method3);
keyboard->setPressCommand (key_cmd1); keyboard->setPressCommand (key_cmd1);
keyboard->setReleaseCommand (key_cmd2); keyboard->setReleaseCommand (key_cmd2);
keyboard->setEscPressedCommand (key_cmd3); keyboard->setEscPressedCommand (key_cmd3);

View File

@ -126,30 +126,30 @@ class FMouseTest : public CPPUNIT_NS::TestFixture
void FMouseTest::classNameTest() void FMouseTest::classNameTest()
{ {
test::FMouse_protected m; test::FMouse_protected m;
const char* const classname1 = m.getClassName(); const finalcut::FString& classname1 = m.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname1, "FMouse") == 0 ); CPPUNIT_ASSERT ( classname1 == "FMouse" );
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
finalcut::FMouseGPM gpm_mouse; finalcut::FMouseGPM gpm_mouse;
const char* const classname2 = gpm_mouse.getClassName(); const finalcut::FString& classname2 = gpm_mouse.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname2, "FMouseGPM") == 0 ); CPPUNIT_ASSERT ( classname2 == "FMouseGPM" );
#endif #endif
finalcut::FMouseX11 x11_mouse; finalcut::FMouseX11 x11_mouse;
const char* const classname3 = x11_mouse.getClassName(); const finalcut::FString& classname3 = x11_mouse.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname3, "FMouseX11") == 0 ); CPPUNIT_ASSERT ( classname3 == "FMouseX11" );
finalcut::FMouseSGR sgr_mouse; finalcut::FMouseSGR sgr_mouse;
const char* const classname4 = sgr_mouse.getClassName(); const finalcut::FString& classname4 = sgr_mouse.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname4, "FMouseSGR") == 0 ); CPPUNIT_ASSERT ( classname4 == "FMouseSGR" );
finalcut::FMouseUrxvt urxvt_mouse; finalcut::FMouseUrxvt urxvt_mouse;
const char* const classname5 = urxvt_mouse.getClassName(); const finalcut::FString& classname5 = urxvt_mouse.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname5, "FMouseUrxvt") == 0 ); CPPUNIT_ASSERT ( classname5 == "FMouseUrxvt" );
finalcut::FMouseControl mouse_control; finalcut::FMouseControl mouse_control;
const char* const classname6 = mouse_control.getClassName(); const finalcut::FString& classname6 = mouse_control.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname6, "FMouseControl") == 0 ); CPPUNIT_ASSERT ( classname6 == "FMouseControl" );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -183,8 +183,8 @@ class FObjectTest : public CPPUNIT_NS::TestFixture
void FObjectTest::classNameTest() void FObjectTest::classNameTest()
{ {
finalcut::FObject o; finalcut::FObject o;
const char* const classname = o.getClassName(); const finalcut::FString& classname = o.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname, "FObject") == 0 ); CPPUNIT_ASSERT ( classname == "FObject" );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -224,12 +224,12 @@ void FObjectTest::noArgumentTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObjectTest::childObjectTest() void FObjectTest::childObjectTest()
{/* {
* obj -> c1 -> c5 -> c6 // obj -> c1 -> c5 -> c6
* -> c2 // -> c2
* -> c3 // -> c3
* -> c4 // -> c4
*/
finalcut::FObject obj; finalcut::FObject obj;
auto c1 = new finalcut::FObject(&obj); auto c1 = new finalcut::FObject(&obj);
auto c2 = new finalcut::FObject(&obj); auto c2 = new finalcut::FObject(&obj);
@ -294,9 +294,9 @@ void FObjectTest::widgetObjectTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObjectTest::removeParentTest() void FObjectTest::removeParentTest()
{/* {
* obj -> child // obj -> child
*/
auto obj = new finalcut::FObject(); auto obj = new finalcut::FObject();
auto child = new finalcut::FObject(obj); auto child = new finalcut::FObject(obj);
@ -321,9 +321,9 @@ void FObjectTest::removeParentTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObjectTest::addTest() void FObjectTest::addTest()
{/* {
* obj -> child // obj -> child
*/
auto obj = new finalcut::FObject(); auto obj = new finalcut::FObject();
auto child = new finalcut::FObject(); auto child = new finalcut::FObject();
@ -347,9 +347,9 @@ void FObjectTest::addTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObjectTest::delTest() void FObjectTest::delTest()
{/* {
* obj -> child // obj -> child
*/
auto obj = new finalcut::FObject(); auto obj = new finalcut::FObject();
auto child = new finalcut::FObject(obj); auto child = new finalcut::FObject(obj);
@ -374,11 +374,11 @@ void FObjectTest::delTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObjectTest::iteratorTest() void FObjectTest::iteratorTest()
{/* {
* obj -> child1 // obj -> child1
* -> child2 // -> child2
* -> child3 // -> child3
*/
auto obj = new finalcut::FObject(); auto obj = new finalcut::FObject();
auto child1 = new finalcut::FObject(obj); auto child1 = new finalcut::FObject(obj);
auto child2 = new finalcut::FObject(obj); auto child2 = new finalcut::FObject(obj);

View File

@ -111,8 +111,8 @@ class FOptiAttrTest : public CPPUNIT_NS::TestFixture
void FOptiAttrTest::classNameTest() void FOptiAttrTest::classNameTest()
{ {
finalcut::FOptiAttr opti_attr; finalcut::FOptiAttr opti_attr;
const char* const classname = opti_attr.getClassName(); const finalcut::FString& classname = opti_attr.getClassName();
CPPUNIT_ASSERT_CSTRING ( classname, "FOptiAttr"); CPPUNIT_ASSERT ( classname == "FOptiAttr");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -109,8 +109,8 @@ class FOptiMoveTest : public CPPUNIT_NS::TestFixture
void FOptiMoveTest::classNameTest() void FOptiMoveTest::classNameTest()
{ {
finalcut::FOptiMove opti_move; finalcut::FOptiMove opti_move;
const char* const classname = opti_move.getClassName(); const finalcut::FString& classname = opti_move.getClassName();
CPPUNIT_ASSERT_CSTRING ( classname, "FOptiMove"); CPPUNIT_ASSERT ( classname == "FOptiMove");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -698,7 +698,7 @@ void FOptiMoveTest::wyse50Test()
CPPUNIT_ASSERT_CSTRING (om.moveCursor (0, 0, 5, 5), C_STR(ESC "=%%")); CPPUNIT_ASSERT_CSTRING (om.moveCursor (0, 0, 5, 5), C_STR(ESC "=%%"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (5, 5, 0, 0), C_STR("\036")); CPPUNIT_ASSERT_CSTRING (om.moveCursor (5, 5, 0, 0), C_STR("\036"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (79, 1, 0, 1), C_STR("\r")); CPPUNIT_ASSERT_CSTRING (om.moveCursor (79, 1, 0, 1), C_STR("\r"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (79, 1, 0, 2), C_STR("\r\n"));om.set_auto_left_margin (true); CPPUNIT_ASSERT_CSTRING (om.moveCursor (79, 1, 0, 2), C_STR("\r\n"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (9, 4, 10, 4), C_STR("\f")); CPPUNIT_ASSERT_CSTRING (om.moveCursor (9, 4, 10, 4), C_STR("\f"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (10, 4, 9, 4), C_STR("\b")); CPPUNIT_ASSERT_CSTRING (om.moveCursor (10, 4, 9, 4), C_STR("\b"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (9, 4, 11, 4), C_STR("\f\f")); CPPUNIT_ASSERT_CSTRING (om.moveCursor (9, 4, 11, 4), C_STR("\f\f"));

View File

@ -88,8 +88,8 @@ class FPointTest : public CPPUNIT_NS::TestFixture
void FPointTest::classNameTest() void FPointTest::classNameTest()
{ {
finalcut::FPoint p; finalcut::FPoint p;
const char* const classname = p.getClassName(); const finalcut::FString& classname = p.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname, "FPoint") == 0 ); CPPUNIT_ASSERT ( classname == "FPoint" );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

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