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>
* Replacing null-terminated wide strings with FString objects
* Fix for getColumnWidth() with newfont character

View File

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

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}
Multi-Arch: same
Depends:
${shlibs:Depends}
xfonts-utils
, ${shlibs:Depends}
, ${misc:Depends}
Suggests:
coreutils

View File

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

View File

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

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
%:
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
# debmake generated override targets

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ else
fi
# Is the file executable?
test ! -x "$PROG" && echo "No executable file not found" && exit -1
test ! -x "$PROG" && echo "No executable file not found" && exit 1
LD_LIBRARY_PATH=../src/.libs/ valgrind --tool=callgrind -v "$PROG" 2>/dev/null

View File

@ -11,12 +11,12 @@ else
fi
# Is the file executable?
test ! -x "$PROG" && echo "No executable file not found" && exit -1
test ! -x "$PROG" && echo "No executable file not found" && exit 1
# ELF executable file?
ELFMAGIC="$(echo -e "\\x7fELF")"
MAGIC="$(dd bs=1 count=4 if="$PROG" 2>/dev/null)"
test "$MAGIC" != "$ELFMAGIC" && echo "No ELF executable file" && exit -2
test "$MAGIC" != "$ELFMAGIC" && echo "No ELF executable file" && exit 2
LD_LIBRARY_PATH=../src/.libs/ valgrind --tool=memcheck --suppressions=../doc/ncurses.supp --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes --log-file=./valgrind.txt "$PROG" "$@"

View File

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

View File

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

View File

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

View File

@ -49,25 +49,6 @@ struct timeval FKeyboard::time_keypressed{};
FTermLinux* FKeyboard::linux{nullptr};
#endif
//----------------------------------------------------------------------
// class FKeyboardCommand
//----------------------------------------------------------------------
// constructors and destructor
//----------------------------------------------------------------------
FKeyboardCommand::FKeyboardCommand ( FApplication* object
, void(FApplication::*method)() )
: instance(object)
, handler(method)
{ }
// public methods of FKeyboardCommand
//----------------------------------------------------------------------
void FKeyboardCommand::execute()
{
(instance->*handler)();
}
//----------------------------------------------------------------------
// class FKeyboard

View File

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

View File

@ -322,82 +322,7 @@ void FListBox::onKeyPress (FKeyEvent* ev)
std::size_t current_before = current;
int xoffset_before = xoffset;
int yoffset_before = yoffset;
FKey key = ev->key();
switch ( key )
{
case fc::Fkey_return:
case fc::Fkey_enter:
acceptSelection();
ev->accept();
break;
case fc::Fkey_up:
onePosUp();
ev->accept();
break;
case fc::Fkey_down:
onePosDown();
ev->accept();
break;
case fc::Fkey_left:
scrollLeft();
ev->accept();
break;
case fc::Fkey_right:
scrollRight();
ev->accept();
break;
case fc::Fkey_ppage:
onePageUp();
ev->accept();
break;
case fc::Fkey_npage:
onePageDown();
ev->accept();
break;
case fc::Fkey_home:
firstPos();
ev->accept();
break;
case fc::Fkey_end:
lastPos();
ev->accept();
break;
case fc::Fkey_ic: // insert key
if ( changeSelectionAndPosition() )
ev->accept();
break;
case fc::Fkey_space:
if ( spacebarProcessing() )
ev->accept();
break;
case fc::Fkey_erase:
case fc::Fkey_backspace:
if ( deletePreviousCharacter() )
ev->accept();
break;
case fc::Fkey_escape:
case fc::Fkey_escape_mintty:
if ( skipIncrementalSearch() )
ev->accept();
break;
default:
if ( keyIncSearchInput(key) )
ev->accept();
}
processKeyAction(ev); // Process the keystrokes
if ( current_before != current )
{
@ -759,6 +684,57 @@ void FListBox::init()
setLeftPadding(1);
setBottomPadding(1);
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() )
return;
convertToItem (*iter, source_container, y + yoffset);
lazy_inserter (*iter, source_container, y + yoffset);
std::size_t column_width = getColumnWidth(iter->text);
recalculateHorizontalBar (column_width, hasBrackets(iter));

View File

@ -25,6 +25,7 @@
#endif
#include <memory>
#include <unordered_map>
#include <vector>
#include "final/emptyfstring.h"
@ -875,79 +876,11 @@ void FListView::sort()
//----------------------------------------------------------------------
void FListView::onKeyPress (FKeyEvent* ev)
{
int position_before = current_iter.getPosition()
, xoffset_before = xoffset
, first_line_position_before = first_visible_line.getPosition()
, pagesize = int(getClientHeight()) - 1;
FKey key = ev->key();
int position_before = current_iter.getPosition();
int xoffset_before = xoffset;
first_line_position_before = first_visible_line.getPosition();
clicked_expander_pos.setPoint(-1, -1);
switch ( key )
{
case fc::Fkey_return:
case fc::Fkey_enter:
processClick();
ev->accept();
break;
case fc::Fkey_space:
toggleCheckbox();
ev->accept();
break;
case fc::Fkey_up:
stepBackward();
ev->accept();
break;
case fc::Fkey_down:
stepForward();
ev->accept();
break;
case fc::Fkey_left:
collapseAndScrollLeft (first_line_position_before);
ev->accept();
break;
case fc::Fkey_right:
expandAndScrollRight (first_line_position_before);
ev->accept();
break;
case fc::Fkey_ppage:
stepBackward(pagesize);
ev->accept();
break;
case fc::Fkey_npage:
stepForward(pagesize);
ev->accept();
break;
case fc::Fkey_home:
firstPos();
ev->accept();
break;
case fc::Fkey_end:
lastPos();
ev->accept();
break;
case int('+'):
if ( expandSubtree() )
ev->accept();
break;
case int('-'):
if ( collapseSubtree() )
ev->accept();
break;
default:
ev->ignore();
}
processKeyAction(ev); // Process the keystrokes
if ( position_before != current_iter.getPosition() )
processChanged();
@ -982,9 +915,9 @@ void FListView::onMouseDown (FMouseEvent* ev)
getStatusBar()->drawMessage();
}
int first_line_position_before = first_visible_line.getPosition()
, mouse_x = ev->getX()
, mouse_y = ev->getY();
int mouse_x = ev->getX();
int mouse_y = ev->getY();
first_line_position_before = first_visible_line.getPosition();
if ( mouse_x > 1 && mouse_x < int(getWidth()) )
{
@ -1119,9 +1052,9 @@ void FListView::onMouseMove (FMouseEvent* ev)
return;
}
int first_line_position_before = first_visible_line.getPosition()
, mouse_x = ev->getX()
, mouse_y = ev->getY();
int mouse_x = ev->getX();
int mouse_y = ev->getY();
first_line_position_before = first_visible_line.getPosition();
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
@ -1194,8 +1127,8 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
//----------------------------------------------------------------------
void FListView::onTimer (FTimerEvent*)
{
int position_before = current_iter.getPosition()
, first_line_position_before = first_visible_line.getPosition();
int position_before = current_iter.getPosition();
first_line_position_before = first_visible_line.getPosition();
switch ( int(drag_scroll) )
{
@ -1233,9 +1166,9 @@ void FListView::onTimer (FTimerEvent*)
//----------------------------------------------------------------------
void FListView::onWheel (FWheelEvent* ev)
{
int position_before = current_iter.getPosition()
, first_line_position_before = first_visible_line.getPosition()
, pagesize{4};
int position_before = current_iter.getPosition();
int pagesize{4};
first_line_position_before = first_visible_line.getPosition();
if ( drag_scroll != fc::noScroll )
stopDragScroll();
@ -1391,6 +1324,46 @@ void FListView::init()
setLeftPadding(1);
setBottomPadding(1);
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() )
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() )
return;
@ -2618,9 +2591,9 @@ void FListView::scrollBy (int dx, int dy)
void FListView::cb_VBarChange (FWidget*, FDataPtr)
{
FScrollbar::sType scrollType = vbar->getScrollType();
int distance{1}
, pagesize{4}
, first_line_position_before = first_visible_line.getPosition();
int distance{1};
int pagesize{4};
first_line_position_before = first_visible_line.getPosition();
switch ( scrollType )
{

View File

@ -567,7 +567,7 @@ void FMenuItem::init (FWidget* parent)
addCallback // for this element
(
"deactivate",
F_METHOD_CALLBACK (parent, &FMenuBar::cb_item_deactivated)
F_METHOD_CALLBACK (menubar_ptr, &FMenuBar::cb_item_deactivated)
);
}
else if ( isMenu(parent) ) // Parent is menu

View File

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

View File

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

View File

@ -464,52 +464,12 @@ void FScrollView::drawBorder()
//----------------------------------------------------------------------
void FScrollView::onKeyPress (FKeyEvent* ev)
{
int yoffset_end = int(getScrollHeight() - getViewportHeight());
int idx = int(ev->key());
switch ( ev->key() )
if ( key_map.find(idx) != key_map.end() )
{
case fc::Fkey_up:
scrollBy (0, -1);
key_map[idx]();
ev->accept();
break;
case fc::Fkey_down:
scrollBy (0, 1);
ev->accept();
break;
case fc::Fkey_left:
scrollBy (-1, 0);
ev->accept();
break;
case fc::Fkey_right:
scrollBy (1, 0);
ev->accept();
break;
case fc::Fkey_ppage:
scrollBy (0, int(-getViewportHeight()));
ev->accept();
break;
case fc::Fkey_npage:
scrollBy (0, int(getViewportHeight()));
ev->accept();
break;
case fc::Fkey_home:
scrollToY (1);
ev->accept();
break;
case fc::Fkey_end:
scrollToY (1 + yoffset_end);
ev->accept();
break;
default:
break;
}
}
@ -764,6 +724,7 @@ void FScrollView::init (FWidget* parent)
initScrollbar (vbar, fc::vertical, &FScrollView::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_HBarChange);
mapKeyFunctions();
const auto& wc = getFWidgetColors();
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
@ -797,6 +758,24 @@ void FScrollView::init (FWidget* parent)
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()
{

View File

@ -52,10 +52,7 @@ FStartOptions::FStartOptions()
//----------------------------------------------------------------------
FStartOptions::~FStartOptions() // destructor
{
if ( start_options )
delete start_options;
}
{ }
// public methods of FStartOptions
//----------------------------------------------------------------------
@ -77,6 +74,13 @@ FStartOptions& FStartOptions::getFStartOptions()
return *start_options;
}
//----------------------------------------------------------------------
void FStartOptions::destroyObject()
{
if ( start_options )
delete start_options;
}
//----------------------------------------------------------------------
void FStartOptions::setDefault()
{

View File

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

View File

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

View File

@ -41,26 +41,6 @@
namespace finalcut
{
// static class attributes
#if defined(__linux__)
FTermLinux::modifier_key FTermLinux::mod_key{};
console_font_op FTermLinux::screen_font{};
unimapdesc FTermLinux::screen_unicode_map{};
bool FTermLinux::new_font{false};
bool FTermLinux::vga_font{false};
bool FTermLinux::has_saved_palette{false};
FTermData* FTermLinux::fterm_data{nullptr};
FSystem* FTermLinux::fsystem{nullptr};
FTermDetection* FTermLinux::term_detection{nullptr};
fc::linuxConsoleCursorStyle FTermLinux::linux_console_cursor_style{};
FTermLinux::ColorMap FTermLinux::saved_color_map{};
FTermLinux::ColorMap FTermLinux::cmap{};
int FTermLinux::framebuffer_bpp{-1};
#endif // defined(__linux__)
//----------------------------------------------------------------------
// class FTermLinux
//----------------------------------------------------------------------

View File

@ -39,21 +39,7 @@ namespace finalcut
// static class attributes
bool FTermXTerminal::mouse_support{false};
bool FTermXTerminal::meta_sends_esc{false};
bool FTermXTerminal::xterm_default_colors{false};
std::size_t FTermXTerminal::term_width{80};
std::size_t FTermXTerminal::term_height{24};
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
if ( mouse_support )
return;
return; // The mouse is already activated
if ( ! fsystem )
fsystem = FTerm::getFSystem();
@ -806,7 +792,7 @@ void FTermXTerminal::disableXTermMouse()
// Deactivate the xterm mouse support
if ( ! mouse_support )
return;
return; // The mouse was already deactivated
FTerm::putstring (CSI "?1006l" // disable SGR mouse mode
CSI "?1015l" // disable urxvt mouse mode

View File

@ -300,6 +300,8 @@ void FTextView::clear()
if ( useFDialogBorder() )
{
auto parent = getParentWidget();
if ( parent )
static_cast<FDialog*>(parent)->redraw();
}
else
@ -323,50 +325,12 @@ void FTextView::clear()
//----------------------------------------------------------------------
void FTextView::onKeyPress (FKeyEvent* ev)
{
switch ( ev->key() )
int idx = int(ev->key());
if ( key_map.find(idx) != key_map.end() )
{
case fc::Fkey_up:
scrollBy (0, -1);
key_map[idx]();
ev->accept();
break;
case fc::Fkey_down:
scrollBy (0, 1);
ev->accept();
break;
case fc::Fkey_left:
scrollBy (-1, 0);
ev->accept();
break;
case fc::Fkey_right:
scrollBy (1, 0);
ev->accept();
break;
case fc::Fkey_ppage:
scrollBy (0, int(-getTextHeight()));
ev->accept();
break;
case fc::Fkey_npage:
scrollBy (0, int(getTextHeight()));
ev->accept();
break;
case fc::Fkey_home:
scrollToY (0);
ev->accept();
break;
case fc::Fkey_end:
scrollToY (int(getRows() - getTextHeight()));
ev->accept();
break;
default:
break;
}
}
@ -612,6 +576,20 @@ void FTextView::init()
setLeftPadding(1);
setBottomPadding(1);
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/>. *
***********************************************************************/
#include <utility>
#include "final/fapplication.h"
#include "final/fbuttongroup.h"
#include "final/fevent.h"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,6 +36,8 @@
#endif
#include <sys/time.h>
#include <functional>
#include "final/fstring.h"
#include "final/ftypes.h"
namespace finalcut
@ -53,17 +55,21 @@ class FTermLinux;
class FKeyboardCommand final
{
public:
// Constructor
explicit FKeyboardCommand ( FApplication* = nullptr
, void(FApplication::*)() = nullptr);
// Constructors
FKeyboardCommand () = default;
explicit FKeyboardCommand (std::function<void()> fn)
: handler(fn)
{ }
// Method
void execute();
void execute()
{
handler();
}
private:
// Data members
FApplication* instance{nullptr};
void (FApplication::*handler)(){nullptr};
std::function<void()> handler{};
};
@ -93,7 +99,7 @@ class FKeyboard final
FKeyboard& operator = (const FKeyboard&) = delete;
// Accessors
virtual const char* getClassName() const;
virtual const FString getClassName() const;
FKey getKey();
const FString getKeyName (FKey);
keybuffer& getKeyBuffer();
@ -179,7 +185,7 @@ class FKeyboard final
// FKeyboard inline functions
//----------------------------------------------------------------------
inline const char* FKeyboard::getClassName() const
inline const FString FKeyboard::getClassName() const
{ return "FKeyboard"; }
//----------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -88,7 +88,7 @@ class FMenuBar : public FWindow, public FMenuList
FMenuBar& operator = (const FMenuBar&) = delete;
// Accessors
const char* getClassName() const override;
const FString getClassName() const override;
// Methods
void resetMenu();
@ -161,7 +161,7 @@ class FMenuBar : public FWindow, public FMenuList
// FMenuBar inline functions
//----------------------------------------------------------------------
inline const char* FMenuBar::getClassName() const
inline const FString FMenuBar::getClassName() const
{ return "FMenuBar"; }
//----------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

@ -102,7 +102,7 @@ class FMouse
{ }
// Accessors
virtual const char* getClassName() const;
virtual const FString getClassName() const;
FPoint& getPos();
void clearEvent();
@ -207,7 +207,7 @@ class FMouseGPM final : public FMouse
virtual ~FMouseGPM();
// Accessors
const char* getClassName() const override;
const FString getClassName() const override;
// Mutators
void setStdinNo(int);
@ -275,7 +275,7 @@ class FMouseX11 final : public FMouse
virtual ~FMouseX11() = default;
// Accessors
const char* getClassName() const override;
const FString getClassName() const override;
// Inquiry
bool hasData() override;
@ -334,7 +334,7 @@ class FMouseSGR final : public FMouse
virtual ~FMouseSGR() = default;
// Accessors
const char* getClassName() const override;
const FString getClassName() const override;
// Inquiry
bool hasData() override;
@ -393,7 +393,7 @@ class FMouseUrxvt final : public FMouse
virtual ~FMouseUrxvt() = default;
// Accessors
const char* getClassName() const override;
const FString getClassName() const override;
// Inquiry
bool hasData() override;
@ -452,7 +452,7 @@ class FMouseControl
virtual ~FMouseControl();
// Accessors
virtual const char* getClassName() const;
virtual const FString getClassName() const;
FPoint& getPos();
void clearEvent();
@ -512,7 +512,7 @@ class FMouseControl
// FMouseControl inline functions
//----------------------------------------------------------------------
inline const char* FMouseControl::getClassName() const
inline const FString FMouseControl::getClassName() const
{ return "FMouseControl"; }
//----------------------------------------------------------------------

View File

@ -89,7 +89,7 @@ class FObject
FObject& operator = (const FObject&) = delete;
// Accessors
virtual const char* getClassName() const;
virtual const FString getClassName() const;
FObject* getParent() const;
FObject* getChild (int) const;
FObjectList& getChildren();
@ -106,7 +106,7 @@ class FObject
bool isChild (const FObject*) const;
bool isDirectChild (const FObject*) const;
bool isWidget() const;
bool isInstanceOf (const char[]) const;
bool isInstanceOf (const FString&) const;
bool isTimerInUpdating() const;
// Methods
@ -152,7 +152,8 @@ class FObject
private:
// Method
virtual void performTimerAction (const FObject*, const FEvent*);
virtual void performTimerAction ( const FObject*
, const FEvent* );
// Data members
FObject* parent_obj{nullptr};
@ -165,7 +166,7 @@ class FObject
//----------------------------------------------------------------------
inline const char* FObject::getClassName() const
inline const FString FObject::getClassName() const
{ return "FObject"; }
//----------------------------------------------------------------------
@ -217,8 +218,8 @@ inline bool FObject::isWidget() const
{ return widget_object; }
//----------------------------------------------------------------------
inline bool FObject::isInstanceOf (const char classname[]) const
{ return ( classname ) ? bool(strcmp(classname, getClassName()) == 0) : false; }
inline bool FObject::isInstanceOf (const FString& classname) const
{ return bool( classname == getClassName() ); }
//----------------------------------------------------------------------
inline bool FObject::isTimerInUpdating() const

View File

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

View File

@ -62,6 +62,8 @@
#include <cstring>
#include <iostream>
#include "final/fstring.h"
namespace finalcut
{
@ -107,7 +109,7 @@ class FOptiMove final
virtual ~FOptiMove();
// Accessors
const char* getClassName() const;
const FString getClassName() const;
uInt getCursorHomeLength() const;
uInt getCarriageReturnLength() const;
uInt getCursorToLLLength() const;
@ -239,7 +241,7 @@ class FOptiMove final
// FOptiMove inline functions
//----------------------------------------------------------------------
inline const char* FOptiMove::getClassName() const
inline const FString FOptiMove::getClassName() const
{ return "FOptiMove"; }
//----------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

@ -41,6 +41,8 @@
#include <algorithm>
#include "final/fstring.h"
namespace finalcut
{
@ -78,7 +80,7 @@ class FRect
friend std::istream& operator >> (std::istream&, FRect&);
// Accessors
virtual const char* getClassName();
virtual const FString getClassName();
int getX1() const;
int getY1() const;
int getX2() const;
@ -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"; }
//----------------------------------------------------------------------

View File

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

View File

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

View File

@ -38,6 +38,7 @@
#include <limits>
#include <iostream>
#include "final/fstring.h"
#include "final/ftypes.h"
namespace finalcut
@ -78,7 +79,7 @@ class FSize
friend std::istream& operator >> (std::istream&, FSize&);
// Accessors
virtual const char* getClassName();
virtual const FString getClassName();
std::size_t getWidth() const;
std::size_t getHeight() const;
std::size_t getArea() const;
@ -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"; }
//----------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

@ -180,7 +180,8 @@ class FSystemImpl : public FSystem
int tputs (const char* str, int affcnt, int (*putc)(int)) override
{
#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
return ::tputs (str, affcnt, putc);
#endif

View File

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

View File

@ -37,6 +37,7 @@
#include <sstream> // std::stringstream
#include <string>
#include <utility>
#include <vector>
namespace finalcut
@ -78,7 +79,7 @@ class FTermBuffer
, const FTermBuffer& );
// Accessors
virtual const char* getClassName() const;
virtual const FString getClassName() const;
std::size_t getLength() 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"; }
//----------------------------------------------------------------------

View File

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

View File

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

View File

@ -69,7 +69,7 @@ class FTermData final
FTermData& operator = (const FTermData&) = delete;
// Accessors
const char* getClassName() const;
const FString getClassName() const;
encodingMap& getEncodingList();
charSubstitution& getCharSubstitutionMap();
fc::encoding getTermEncoding() const;
@ -132,8 +132,8 @@ class FTermData final
FString xterm_font{};
FString xterm_title{};
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
int framebuffer_bpp{-1};
#endif
@ -158,7 +158,7 @@ class FTermData final
// FTermData inline functions
//----------------------------------------------------------------------
inline const char* FTermData::getClassName() const
inline const FString FTermData::getClassName() const
{ return "FTermData"; }
//----------------------------------------------------------------------

View File

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

View File

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

View File

@ -38,6 +38,7 @@
#include <termios.h>
#include <unistd.h>
#include "final/fstring.h"
#include "final/ftypes.h"
namespace finalcut
@ -57,7 +58,7 @@ class FTermios final
virtual ~FTermios();
// Accessors
const char* getClassName() const;
const FString getClassName() const;
static termios getTTY();
static int getStdIn();
static int getStdOut();
@ -93,7 +94,7 @@ class FTermios final
// FTermios inline functions
//----------------------------------------------------------------------
inline const char* FTermios::getClassName() const
inline const FString FTermios::getClassName() const
{ return "FTermios"; }
//----------------------------------------------------------------------

View File

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

View File

@ -87,7 +87,7 @@ class FTermOpenBSD final
FTermOpenBSD& operator = (const FTermOpenBSD&) = delete;
// Accessor
const char* getClassName() const;
const FString getClassName() const;
// Inquiries
static bool isBSDConsole();
@ -120,7 +120,7 @@ class FTermOpenBSD final
// FTermOpenBSD inline functions
//----------------------------------------------------------------------
inline const char* FTermOpenBSD::getClassName() const
inline const FString FTermOpenBSD::getClassName() const
{ return "FTermOpenBSD"; }
//----------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -109,8 +109,8 @@ class FOptiMoveTest : public CPPUNIT_NS::TestFixture
void FOptiMoveTest::classNameTest()
{
finalcut::FOptiMove opti_move;
const char* const classname = opti_move.getClassName();
CPPUNIT_ASSERT_CSTRING ( classname, "FOptiMove");
const finalcut::FString& classname = opti_move.getClassName();
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 (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, 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 (10, 4, 9, 4), C_STR("\b"));
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()
{
finalcut::FPoint p;
const char* const classname = p.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname, "FPoint") == 0 );
const finalcut::FString& classname = p.getClassName();
CPPUNIT_ASSERT ( classname == "FPoint" );
}
//----------------------------------------------------------------------

View File

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

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