Small code and text changes

This commit is contained in:
Markus Gans 2020-08-23 00:32:41 +02:00
parent 2b33c1875a
commit b9042d5a03
61 changed files with 1090 additions and 851 deletions

View File

@ -510,7 +510,7 @@ clicked by a keyboard or mouse, it sends the string "clicked". A signal
handler explicitly provided by Widget, in the form of a callback function
or a callback method, can react to such a signal.
A callback function has no return value can have various arguments:
A callback function has no return value and can have various arguments:
```cpp
void cb_function (FWidget* w, int* i, double* d, ...)
@ -527,29 +527,137 @@ void classname::cb_methode (FWidget* w, int* i, double* d, ...)
We use the `addCallback()` method of the `FWidget` class to connect
to other widget objects.
For calling functions and static methods:
(1) For calling functions or static methods via a pointer:
```cpp
template<typename Function
, typename FunctionPointer<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, FCallback cb_handler
, FDataPtr data )
, Function&& cb_function
, Args&&... args)
{...}
```
For calling a member method of a specific instance:
(2) For calling functions or static methods via a reference:
```cpp
template<typename Function
, typename FunctionReference<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, FWidget* cb_instance
, FMemberCallback cb_handler
, FDataPtr data )
, Function& cb_function
, Args&&... args)
{...}
```
There are two macros `F_FUNCTION_CALLBACK` and `F_METHOD_CALLBACK` to avoid
having to deal with necessary type conversions. With `delCallback()` you can
remove a connection to a signal handler or a widget. Alternatively, you can
use `delAllCallbacks()` to remove all existing callbacks from an object.
(3) For calling a member method of a specific instance:
```cpp
template<typename Object
, typename Function
, typename ObjectPointer<Object>::type = nullptr
, typename MemberFunctionPointer<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_member
, Args&&... args)
{...}
```
(4) For calling a std::bind call wrapper or a lambda expression:
```cpp
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Function&& cb_function
, Args&&... args)
{...}
```
(5) For calling a std::bind call wrapper to a specific instance:
```cpp
template<typename Object
, typename Function
, typename ObjectPointer<Object>::type = nullptr
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_function
, Args&&... args)
{...}
```
(6) For calling a lambda function that has been stored in a variable
with the keyword auto:
```cpp
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args)
{...}
```
With `delCallback(...)` you can remove a connection to a signal handler
or a widget instance. Alternatively, you can use `delCallbacks()` to
remove all existing callbacks from an object.
To delete functions or static methods callbacks via a pointer:(4)
```cpp
template<typename FunctionPtr
, typename FunctionPointer<FunctionPtr>::type = nullptr>
void FWidget::delCallback (FunctionPtr&& cb_func_ptr)
{...}
```
To delete functions or static methods callbacks via a reference:(5)
```cpp
template<typename Function
, typename FunctionReference<Function>::type = nullptr>
void FWidget::delCallback (Function& cb_function)
{...}
```
To delete all callbacks from a specific instance:(1)
```cpp
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void FWidget::delCallback (Object&& cb_instance)
{...}
```
To delete all callbacks of a signal:(2)
```cpp
void delCallback (const FString& cb_signal)
{...}
```
To delete all callbacks of a signal and specific instance:(3)
```cpp
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void delCallback (const FString& cb_signal, Object&& cb_instance)
{...}
```
To delete all callbacks from a widget:(6)
```cpp
void delCallback()
{...}
```
### The FINAL CUT widgets emit the following default signals ###

View File

@ -42,7 +42,7 @@ class Background final : public finalcut::FDialog
using FDialog::setGeometry;
// Typedef
typedef std::tuple<uChar,uChar,uChar> RGB;
typedef std::tuple<uChar, uChar, uChar> RGB;
// Constructor
explicit Background (finalcut::FWidget* = nullptr);

View File

@ -21,6 +21,7 @@
***********************************************************************/
#include <iomanip>
#include <memory>
#include <string>
#include <final/final.h>

View File

@ -28,7 +28,10 @@
#include <final/final.h>
namespace fc = finalcut::fc;
using namespace std::chrono;
using std::chrono::duration_cast;
using std::chrono::milliseconds;
using std::chrono::system_clock;
using std::chrono::time_point;
using finalcut::FPoint;
using finalcut::FSize;

View File

@ -32,7 +32,7 @@ namespace fc = finalcut::fc;
void tcapBoolean (const std::string&, bool);
void tcapNumeric (const std::string&, int);
void tcapString (const std::string&, const char[]);
void debug (finalcut::FApplication&);
void debug (const finalcut::FApplication&);
void booleans();
void numeric();
void string();
@ -207,7 +207,7 @@ void tcapString (const std::string& name, const char cap_str[])
//----------------------------------------------------------------------
#if DEBUG
void debug (finalcut::FApplication& TermApp)
void debug (const finalcut::FApplication& TermApp)
{
const auto& fterm = TermApp.getFTerm();
auto& debug_data = fterm.getFTermDebugData();

View File

@ -103,7 +103,6 @@ ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
progressBar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
//progressBar.setPercentage(78);
using namespace std::placeholders;
reset.addCallback
(
"clicked",
@ -293,7 +292,7 @@ class MyDialog final : public finalcut::FDialog
void onClose (finalcut::FCloseEvent*) override;
// Callback methods
void cb_noFunctionMsg (finalcut::FButton&);
void cb_noFunctionMsg (const finalcut::FButton&);
void cb_about();
void cb_terminfo();
void cb_drives();
@ -311,7 +310,7 @@ class MyDialog final : public finalcut::FDialog
void cb_activateButton ( const finalcut::FRadioButton&
, finalcut::FButton& ) const;
void cb_view (const finalcut::FMenuItem*);
void cb_setInput (finalcut::FListBox&, finalcut::FLineEdit&) const;
void cb_setInput (const finalcut::FListBox&, finalcut::FLineEdit&) const;
// Data members
bool initialized{false};
@ -805,7 +804,7 @@ void MyDialog::onClose (finalcut::FCloseEvent* ev)
}
//----------------------------------------------------------------------
void MyDialog::cb_noFunctionMsg (finalcut::FButton& button)
void MyDialog::cb_noFunctionMsg (const finalcut::FButton& button)
{
auto text = button.getText();
text = text.replace('&', "");
@ -1033,7 +1032,7 @@ void MyDialog::cb_view (const finalcut::FMenuItem* item)
}
//----------------------------------------------------------------------
void MyDialog::cb_setInput ( finalcut::FListBox& listbox
void MyDialog::cb_setInput ( const finalcut::FListBox& listbox
, finalcut::FLineEdit& lineedit) const
{
lineedit = listbox.getItem(listbox.currentItem()).getText();

View File

@ -20,7 +20,9 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <utility>
#include <vector>
#include <final/final.h>
namespace fc = finalcut::fc;

View File

@ -38,5 +38,52 @@ FCallback::FCallback()
FCallback::~FCallback() // destructor
{ }
// public methods of FCallback
//----------------------------------------------------------------------
void FCallback::delCallback (const FString& cb_signal)
{
// Deletes entries with the given signal from the callback list
if ( callback_objects.empty() )
return;
auto iter = callback_objects.begin();
while ( iter != callback_objects.end() )
{
if ( iter->cb_signal == cb_signal )
iter = callback_objects.erase(iter);
else
++iter;
}
}
//----------------------------------------------------------------------
void FCallback::delCallback()
{
// Delete all callbacks from this widget
callback_objects.clear(); // function pointer
}
//----------------------------------------------------------------------
void FCallback::emitCallback (const FString& emit_signal) const
{
// Initiate callback for the given signal
if ( callback_objects.empty() )
return;
for (auto&& cback : callback_objects)
{
if ( cback.cb_signal == emit_signal )
{
// Calling the stored function pointer
cback.cb_function();
}
}
}
} // namespace finalcut

View File

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

View File

@ -235,7 +235,7 @@ void FFocusEvent::ignore()
// class FAccelEvent
//----------------------------------------------------------------------
FAccelEvent::FAccelEvent (fc::events ev_type, void* focused) // constructor
FAccelEvent::FAccelEvent (fc::events ev_type, FWidget* focused) // constructor
: FEvent{ev_type}
, focus_widget{focused}
{ }
@ -245,7 +245,7 @@ FAccelEvent::~FAccelEvent() // destructor
{ }
//----------------------------------------------------------------------
void* FAccelEvent::focusedWidget() const
FWidget* FAccelEvent::focusedWidget() const
{ return focus_widget; }
//----------------------------------------------------------------------

View File

@ -644,7 +644,7 @@ void FListBox::adjustSize()
// private methods of FListBox
//----------------------------------------------------------------------
inline FString& FListBox::getString (listBoxItems::iterator iter)
inline FString FListBox::getString (listBoxItems::iterator iter)
{
return iter->getText();
}

View File

@ -24,8 +24,10 @@
#include <strings.h> // need for strcasecmp
#endif
#include <limits>
#include <memory>
#include <unordered_map>
#include <utility>
#include <vector>
#include "final/emptyfstring.h"

View File

@ -45,7 +45,7 @@ FLog::~FLog() // destructor
//----------------------------------------------------------------------
FLog& FLog::operator << (LogLevel l)
{
using namespace std::placeholders;
using std::placeholders::_1;
sync();
switch ( l )

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <string>
#include "final/flogger.h"
namespace finalcut

View File

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

View File

@ -20,12 +20,13 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <new>
#include <stdio.h>
#include <unistd.h>
#include "final/fconfig.h"
#include "final/fkeyboard.h"
@ -843,7 +844,8 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn)
}
//----------------------------------------------------------------------
void FMouseSGR::setPressedButtonState (const int btn, const struct timeval* time)
void FMouseSGR::setPressedButtonState ( const int btn
, const struct timeval* time )
{
// Gets the extended x11 mouse mode (SGR) status for pressed buttons

View File

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

View File

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

View File

@ -21,6 +21,7 @@
***********************************************************************/
#include <algorithm>
#include <utility>
#include "final/fpoint.h"
#include "final/frect.h"

View File

@ -21,6 +21,7 @@
***********************************************************************/
#include <limits>
#include <utility>
#include "final/fpoint.h"
#include "final/fsize.h"

View File

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

View File

@ -25,7 +25,9 @@
#endif
#include <algorithm>
#include <limits>
#include <numeric>
#include <utility>
#include "final/fapplication.h"
#include "final/fcharmap.h"

View File

@ -35,6 +35,7 @@
{ \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \
\
return ret_value; \
}
#endif

View File

@ -32,6 +32,7 @@
{ \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \
\
return ret_value; \
}
#endif

View File

@ -41,6 +41,7 @@
{ \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \
\
return ret_value; \
}

View File

@ -159,8 +159,9 @@ void FToolTip::calculateDimensions()
int x{};
int y{};
const std::size_t h = ( hasBorder() ) ? text_num_lines + 2 : text_num_lines;
const std::size_t w = ( hasBorder() ) ? max_line_width + 4 : max_line_width + 2;
bool border = hasBorder();
const std::size_t h = ( border ) ? text_num_lines + 2 : text_num_lines;
const std::size_t w = ( border ) ? max_line_width + 4 : max_line_width + 2;
const auto& r = getRootWidget();
if ( r )

View File

@ -252,7 +252,7 @@ void FVTerm::putVTerm()
}
//----------------------------------------------------------------------
void FVTerm::updateTerminal()
void FVTerm::updateTerminal() const
{
// Updates pending changes to the terminal
@ -655,7 +655,7 @@ void FVTerm::flush()
while ( ! output_buffer->empty() )
{
const static FTerm::defaultPutChar& FTermPutchar = FTerm::putchar();
static const FTerm::defaultPutChar& FTermPutchar = FTerm::putchar();
FTermPutchar (output_buffer->front());
output_buffer->pop();
}

View File

@ -78,7 +78,7 @@ class FButton : public FWidget
// Accessors
const FString getClassName() const override;
FString& getText();
FString getText() const;
// Mutators
void setForegroundColor (FColor) override;
@ -178,7 +178,7 @@ inline const FString FButton::getClassName() const
{ return "FButton"; }
//----------------------------------------------------------------------
inline FString& FButton::getText()
inline FString FButton::getText() const
{ return text; }
//----------------------------------------------------------------------

View File

@ -35,6 +35,9 @@
#error "Only <final/final.h> can be included directly."
#endif
#include <utility>
#include <vector>
#include "final/fstring.h"
#include "final/ftypes.h"
@ -64,7 +67,7 @@ struct FCallbackData
{ }
FCallbackData (const FCallbackData&) = default;
FCallbackData (FCallbackData&&) noexcept = default;
FCallbackData (FCallbackData&&) = default;
FCallbackData& operator = (const FCallbackData&) = default;
FCallbackData& operator = (FCallbackData&&) noexcept = default;
@ -144,15 +147,8 @@ class FCallback
FCallback& operator = (const FCallback&) = delete;
// Accessors
const FString getClassName() const
{
return "FCallback";
}
std::size_t getCallbackCount() const
{
return callback_objects.size();
}
const FString getClassName() const;
std::size_t getCallbackCount() const;
// Methods
template<typename Object
@ -163,18 +159,7 @@ class FCallback
void addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_member
, Args&&... args)
{
// Add a member function pointer as callback
Object instance = cb_instance;
auto fn = std::bind ( std::forward<Function>(cb_member)
, std::forward<Object>(cb_instance)
, std::forward<Args>(args)... );
FCallbackData obj{ cb_signal, instance, nullptr, fn };
callback_objects.push_back(obj);
}
, Args&&... args);
template<typename Object
, typename Function
, typename ObjectPointer<Object>::type = nullptr
@ -183,52 +168,158 @@ class FCallback
void addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_function
, Args&&... args)
{
// Add a function object to an instance as callback
auto fn = std::bind (std::forward<Function>(cb_function), std::forward<Args>(args)...);
FCallbackData obj{ cb_signal, cb_instance, nullptr, fn };
callback_objects.push_back(obj);
}
, Args&&... args);
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Function&& cb_function
, Args&&... args);
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args);
template<typename Function
, typename FunctionReference<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args);
template<typename Function
, typename FunctionPointer<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Function&& cb_function
, Args&&... args);
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void delCallback (Object&& cb_instance);
void delCallback (const FString& cb_signal);
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void delCallback (const FString& cb_signal, Object&& cb_instance);
template<typename FunctionPtr
, typename FunctionPointer<FunctionPtr>::type = nullptr>
void delCallback (FunctionPtr&& cb_func_ptr);
template<typename Function
, typename FunctionReference<Function>::type = nullptr>
void delCallback (const Function& cb_function);
void delCallback();
void emitCallback (const FString& emit_signal) const;
private:
// Typedefs
typedef std::vector<FCallbackData> FCallbackObjects;
// Data members
FCallbackObjects callback_objects{};
};
// FCallback inline functions
//----------------------------------------------------------------------
inline const FString FCallback::getClassName() const
{ return "FCallback"; }
//----------------------------------------------------------------------
inline std::size_t FCallback::getCallbackCount() const
{ return callback_objects.size(); }
//----------------------------------------------------------------------
template<typename Object
, typename Function
, typename FCallback::ObjectPointer<Object>::type
, typename FCallback::MemberFunctionPointer<Function>::type
, typename... Args>
inline void FCallback::addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_member
, Args&&... args)
{
{
// Add a member function pointer as callback
Object instance = cb_instance;
auto fn = std::bind ( std::forward<Function>(cb_member)
, std::forward<Object>(cb_instance)
, std::forward<Args>(args)... );
FCallbackData obj{ cb_signal, instance, nullptr, fn };
callback_objects.push_back(obj);
}
//----------------------------------------------------------------------
template<typename Object
, typename Function
, typename FCallback::ObjectPointer<Object>::type
, typename FCallback::ClassObject<Function>::type
, typename... Args>
inline void FCallback::addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_function
, Args&&... args)
{
// Add a function object to an instance as callback
auto fn = std::bind (std::forward<Function>(cb_function), std::forward<Args>(args)...);
FCallbackData obj{ cb_signal, cb_instance, nullptr, fn };
callback_objects.push_back(obj);
}
//----------------------------------------------------------------------
template<typename Function
, typename FCallback::ClassObject<Function>::type
, typename... Args>
inline void FCallback::addCallback ( const FString& cb_signal
, Function&& cb_function
, Args&&... args)
{
// Add a function object as callback
auto fn = std::bind ( std::forward<Function>(cb_function)
, std::forward<Args>(args)... );
FCallbackData obj{ cb_signal, nullptr, nullptr, fn };
callback_objects.push_back(obj);
}
}
template<typename Function
, typename FunctionReference<Function>::type = nullptr
//----------------------------------------------------------------------
template<typename Function
, typename FCallback::ClassObject<Function>::type
, typename... Args>
void addCallback ( const FString& cb_signal
inline void FCallback::addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args)
{
// Add a function as callback
{
// Add a function object reference as callback
auto fn = std::bind (cb_function, std::forward<Args>(args)...);
FCallbackData obj{ cb_signal, nullptr, nullptr, fn };
callback_objects.push_back(obj);
}
//----------------------------------------------------------------------
template<typename Function
, typename FCallback::FunctionReference<Function>::type
, typename... Args>
inline void FCallback::addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args)
{
// Add a function reference as callback
auto ptr = reinterpret_cast<void*>(&cb_function);
auto fn = std::bind (cb_function, std::forward<Args>(args)...);
FCallbackData obj{ cb_signal, nullptr, ptr, fn };
callback_objects.push_back(obj);
}
}
template<typename Function
, typename FunctionPointer<Function>::type = nullptr
//----------------------------------------------------------------------
template<typename Function
, typename FCallback::FunctionPointer<Function>::type
, typename... Args>
void addCallback ( const FString& cb_signal
inline void FCallback::addCallback ( const FString& cb_signal
, Function&& cb_function
, Args&&... args)
{
{
// Add a function pointer as callback
auto ptr = reinterpret_cast<void*>(cb_function);
@ -236,26 +327,13 @@ class FCallback
, std::forward<Args>(args)... );
FCallbackData obj{ cb_signal, nullptr, ptr, fn };
callback_objects.push_back(obj);
}
}
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args)
{
// Add a non-union class type as callback
auto fn = std::bind (cb_function, std::forward<Args>(args)...);
FCallbackData obj{ cb_signal, nullptr, nullptr, fn };
callback_objects.push_back(obj);
}
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void delCallback (Object&& cb_instance)
{
//----------------------------------------------------------------------
template<typename Object
, typename FCallback::ObjectPointer<Object>::type>
inline void FCallback::delCallback (Object&& cb_instance)
{
// Deletes entries with the given instance from the callback list
if ( callback_objects.empty() )
@ -270,30 +348,13 @@ class FCallback
else
++iter;
}
}
}
void delCallback (const FString& cb_signal)
{
// Deletes entries with the given signal from the callback list
if ( callback_objects.empty() )
return;
auto iter = callback_objects.begin();
while ( iter != callback_objects.end() )
{
if ( iter->cb_signal == cb_signal )
iter = callback_objects.erase(iter);
else
++iter;
}
}
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void delCallback (const FString& cb_signal, Object&& cb_instance)
{
//----------------------------------------------------------------------
template<typename Object
, typename FCallback::ObjectPointer<Object>::type>
inline void FCallback::delCallback (const FString& cb_signal, Object&& cb_instance)
{
// Deletes entries with the given signal and instance
// from the callback list
@ -310,12 +371,13 @@ class FCallback
else
++iter;
}
}
}
template<typename FunctionPtr
, typename FunctionPointer<FunctionPtr>::type = nullptr>
void delCallback (FunctionPtr&& cb_func_ptr)
{
//----------------------------------------------------------------------
template<typename FunctionPtr
, typename FCallback::FunctionPointer<FunctionPtr>::type>
inline void FCallback::delCallback (FunctionPtr&& cb_func_ptr)
{
// Deletes entries with the given function pointer
// from the callback list
@ -332,13 +394,15 @@ class FCallback
else
++iter;
}
}
}
template<typename Function
, typename FunctionReference<Function>::type = nullptr>
void delCallback (Function& cb_function)
{
// Deletes entries with the given function from the callback list
//----------------------------------------------------------------------
template<typename Function
, typename FCallback::FunctionReference<Function>::type>
inline void FCallback::delCallback (const Function& cb_function)
{
// Deletes entries with the given function reference
// from the callback list
if ( callback_objects.empty() )
return;
@ -353,40 +417,7 @@ class FCallback
else
++iter;
}
}
void delCallback()
{
// Delete all callbacks from this widget
callback_objects.clear(); // function pointer
}
void emitCallback (const FString& emit_signal) const
{
// Initiate callback for the given signal
if ( callback_objects.empty() )
return;
for (auto&& cback : callback_objects)
{
if ( cback.cb_signal == emit_signal )
{
// Calling the stored function pointer
cback.cb_function();
}
}
}
private:
// Typedefs
typedef std::vector<FCallbackData> FCallbackObjects;
// Data members
FCallbackObjects callback_objects{};
};
}
} // namespace finalcut

View File

@ -27,6 +27,8 @@
#error "Only <final/final.h> can be included directly."
#endif
#include <utility>
template<typename T>
struct FData
{

View File

@ -194,7 +194,8 @@ class FDialog : public FWindow
void leaveZoomButton (const mouseStates&);
void pressZoomButton (const mouseStates&);
bool isMouseOverMenu (const FPoint&) const;
void passEventToSubMenu (const mouseStates&, const FMouseEvent*);
void passEventToSubMenu ( const mouseStates&
, const FMouseEvent* );
void moveSizeKey (FKeyEvent*);
void raiseActivateDialog();
void lowerActivateDialog();

View File

@ -218,24 +218,25 @@ class FFocusEvent : public FEvent // focus event
//----------------------------------------------------------------------
// class FAccelEvent
//----------------------------------------------------------------------
class FWidget; // class forward declaration
class FAccelEvent : public FEvent // focus event
{
public:
FAccelEvent() = default;
FAccelEvent (fc::events, void*);
FAccelEvent (fc::events, FWidget*);
FAccelEvent (const FAccelEvent&) = delete;
~FAccelEvent();
FAccelEvent& operator = (const FAccelEvent&) = delete;
void* focusedWidget() const;
FWidget* focusedWidget() const;
bool isAccepted() const;
void accept();
void ignore();
private:
bool accpt{false};
void* focus_widget{};
FWidget* focus_widget{};
};

View File

@ -82,7 +82,7 @@ class FListBoxItem
// Accessors
virtual const FString getClassName() const;
virtual FString& getText();
virtual FString getText() const;
virtual FDataPtr getData() const;
// Mutators
@ -110,7 +110,7 @@ inline const FString FListBoxItem::getClassName() const
{ return "FListBoxItem"; }
//----------------------------------------------------------------------
inline FString& FListBoxItem::getText()
inline FString FListBoxItem::getText() const
{ return text; }
//----------------------------------------------------------------------
@ -247,7 +247,7 @@ class FListBox : public FWidget
};
// Accessors
static FString& getString (listBoxItems::iterator);
static FString getString (listBoxItems::iterator);
// Inquiry
bool isHorizontallyScrollable() const;

View File

@ -49,6 +49,7 @@
#include <list>
#include <stack>
#include <unordered_map>
#include <vector>
#include "final/fscrollbar.h"

View File

@ -54,6 +54,8 @@
#error "Only <final/final.h> can be included directly."
#endif
#include <tuple>
#include "final/fwindow.h"
#include "final/fmenulist.h"

View File

@ -36,6 +36,7 @@
#endif
#include <iostream>
#include <utility>
#include "final/fstring.h"

View File

@ -40,6 +40,7 @@
#endif
#include <algorithm>
#include <utility>
#include "final/fstring.h"

View File

@ -188,7 +188,6 @@ void initScrollbar ( FScrollbarPtr& bar
return;
}
using namespace std::placeholders;
bar->setMinimum(0);
bar->setValue(0);
bar->hide();

View File

@ -37,6 +37,7 @@
#include <limits>
#include <iostream>
#include <utility>
#include "final/fstring.h"
#include "final/ftypes.h"

View File

@ -47,6 +47,8 @@
#error "Only <final/final.h> can be included directly."
#endif
#include <limits>
#include "final/fwidget.h"
namespace finalcut

View File

@ -166,7 +166,7 @@ class FTerm final
typedef FColorPalette::FSetPalette FSetPalette;
// Constructor
explicit FTerm();
FTerm();
// Disable copy constructor
FTerm (const FTerm&) = delete;

View File

@ -35,6 +35,7 @@
#error "Only <final/final.h> can be included directly."
#endif
#include <algorithm>
#include <string>
#include <utility>
#include <vector>

View File

@ -56,6 +56,7 @@
#endif
#include <string>
#include <utility>
#include <vector>
// FTermcap string macro

View File

@ -118,7 +118,7 @@ class FVTerm
};
// Constructor
explicit FVTerm();
FVTerm();
// Disable copy constructor
FVTerm (const FVTerm&) = delete;
@ -148,7 +148,7 @@ class FVTerm
const FTermArea* getVWin() const;
const FPoint getPrintCursor();
static const FChar getAttribute();
FTerm& getFTerm();
FTerm& getFTerm() const;
// Mutators
void setTermXY (int, int) const;
@ -253,7 +253,7 @@ class FVTerm
void createVTerm (const FSize&);
void resizeVTerm (const FSize&) const;
void putVTerm();
void updateTerminal();
void updateTerminal() const;
virtual void addPreprocessingHandler ( const FVTerm*
, const FPreprocessingFunction& );
virtual void delPreprocessingHandler (const FVTerm*);
@ -629,7 +629,7 @@ inline const FChar FVTerm::getAttribute()
{ return next_attribute; }
//----------------------------------------------------------------------
inline FTerm& FVTerm::getFTerm()
inline FTerm& FVTerm::getFTerm() const
{ return *fterm; }
//----------------------------------------------------------------------

View File

@ -95,6 +95,7 @@
#endif
#include <functional>
#include <memory>
#include <utility>
#include <vector>

View File

@ -21,6 +21,7 @@
***********************************************************************/
#include <cstring>
#include <vector>
#include "final/fc.h"
#include "final/sgr_optimizer.h"

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <utility>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -121,12 +123,12 @@ class FCallbackTest : public CPPUNIT_NS::TestFixture
protected:
void classNameTest();
void memberFunctionCallbackTest();
void instanceWithFunctionCallbackTest();
void functionObjectTest();
void functionCallbackTest();
void memberFunctionPointerCallbackTest();
void instanceWithFunctionObjectCallbackTest();
void functionObjectCallbackTest();
void functionObjectReferenceCallbackTest();
void functionReferenceCallbackTest();
void functionPointerCallbackTest();
void nonUnionClassCallbackTest();
void ownWidgetTest();
private:
@ -135,12 +137,12 @@ class FCallbackTest : public CPPUNIT_NS::TestFixture
// Add a methods to the test suite
CPPUNIT_TEST (classNameTest);
CPPUNIT_TEST (memberFunctionCallbackTest);
CPPUNIT_TEST (instanceWithFunctionCallbackTest);
CPPUNIT_TEST (functionObjectTest);
CPPUNIT_TEST (functionCallbackTest);
CPPUNIT_TEST (memberFunctionPointerCallbackTest);
CPPUNIT_TEST (instanceWithFunctionObjectCallbackTest);
CPPUNIT_TEST (functionObjectCallbackTest);
CPPUNIT_TEST (functionObjectReferenceCallbackTest);
CPPUNIT_TEST (functionReferenceCallbackTest);
CPPUNIT_TEST (functionPointerCallbackTest);
CPPUNIT_TEST (nonUnionClassCallbackTest);
CPPUNIT_TEST (ownWidgetTest);
// End of test suite definition
@ -162,7 +164,7 @@ void FCallbackTest::classNameTest()
}
//----------------------------------------------------------------------
void FCallbackTest::memberFunctionCallbackTest()
void FCallbackTest::memberFunctionPointerCallbackTest()
{
finalcut::FCallback cb{};
cb_class c{5, &root_widget};
@ -228,7 +230,7 @@ void FCallbackTest::memberFunctionCallbackTest()
}
//----------------------------------------------------------------------
void FCallbackTest::instanceWithFunctionCallbackTest()
void FCallbackTest::instanceWithFunctionObjectCallbackTest()
{
finalcut::FCallback cb{};
cb_class c{15, &root_widget};
@ -317,7 +319,7 @@ void FCallbackTest::instanceWithFunctionCallbackTest()
}
//----------------------------------------------------------------------
void FCallbackTest::functionObjectTest()
void FCallbackTest::functionObjectCallbackTest()
{
finalcut::FCallback cb{};
int i1{2};
@ -377,7 +379,47 @@ void FCallbackTest::functionObjectTest()
}
//----------------------------------------------------------------------
void FCallbackTest::functionCallbackTest()
void FCallbackTest::functionObjectReferenceCallbackTest()
{
finalcut::FCallback cb{};
int i{4};
auto lambda1 = [] (int* value)
{
*value = *value << 8;
};
auto lambda2 = [] (int& value)
{
value = value >> 4;
};
using NonUnionClass = decltype(lambda1);
CPPUNIT_ASSERT ( 0 == std::is_member_function_pointer<NonUnionClass>::value );
CPPUNIT_ASSERT ( 0 == std::is_function<typename std::remove_pointer<NonUnionClass>::type>::value );
CPPUNIT_ASSERT ( 0 == std::is_function<NonUnionClass>::value );
CPPUNIT_ASSERT ( 0 == std::is_pointer<NonUnionClass>::value );
CPPUNIT_ASSERT ( 1 == std::is_object<NonUnionClass>::value );
CPPUNIT_ASSERT ( 1 == std::is_class<NonUnionClass>::value );
cb.addCallback ("toggled", lambda1, &i);
CPPUNIT_ASSERT ( cb.getCallbackCount() == 1 );
CPPUNIT_ASSERT ( i == 4 );
cb.emitCallback ("toggled");
CPPUNIT_ASSERT ( i == 1024 );
cb.addCallback ("row-selected", lambda2, std::ref(i));
CPPUNIT_ASSERT ( cb.getCallbackCount() == 2 );
CPPUNIT_ASSERT ( i == 1024 );
cb.emitCallback ("row-selected");
CPPUNIT_ASSERT ( i == 64 );
cb.delCallback();
CPPUNIT_ASSERT ( cb.getCallbackCount() == 0 );
}
//----------------------------------------------------------------------
void FCallbackTest::functionReferenceCallbackTest()
{
finalcut::FCallback cb{};
int i1{22};
@ -464,45 +506,6 @@ void FCallbackTest::functionPointerCallbackTest()
}
//----------------------------------------------------------------------
void FCallbackTest::nonUnionClassCallbackTest()
{
finalcut::FCallback cb{};
int i{4};
auto lambda1 = [] (int* value)
{
*value = *value << 8;
};
auto lambda2 = [] (int& value)
{
value = value >> 4;
};
using NonUnionClass = decltype(lambda1);
CPPUNIT_ASSERT ( 0 == std::is_member_function_pointer<NonUnionClass>::value );
CPPUNIT_ASSERT ( 0 == std::is_function<typename std::remove_pointer<NonUnionClass>::type>::value );
CPPUNIT_ASSERT ( 0 == std::is_function<NonUnionClass>::value );
CPPUNIT_ASSERT ( 0 == std::is_pointer<NonUnionClass>::value );
CPPUNIT_ASSERT ( 1 == std::is_object<NonUnionClass>::value );
CPPUNIT_ASSERT ( 1 == std::is_class<NonUnionClass>::value );
cb.addCallback ("toggled", lambda1, &i);
CPPUNIT_ASSERT ( cb.getCallbackCount() == 1 );
CPPUNIT_ASSERT ( i == 4 );
cb.emitCallback ("toggled");
CPPUNIT_ASSERT ( i == 1024 );
cb.addCallback ("row-selected", lambda2, std::ref(i));
CPPUNIT_ASSERT ( cb.getCallbackCount() == 2 );
CPPUNIT_ASSERT ( i == 1024 );
cb.emitCallback ("row-selected");
CPPUNIT_ASSERT ( i == 64 );
cb.delCallback();
CPPUNIT_ASSERT ( cb.getCallbackCount() == 0 );
}
void FCallbackTest::ownWidgetTest()
{
Widget w;

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <string>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -28,7 +30,6 @@
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <string>
#include <final/final.h>
namespace test

View File

@ -20,6 +20,10 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <memory>
#include <sstream>
#include <string>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -28,8 +32,6 @@
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <sstream>
#include <final/final.h>
//----------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2019 Markus Gans *
* Copyright 2018-2020 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
@ -20,6 +20,9 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <iomanip>
#include <string>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -27,12 +30,9 @@
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <cppunit/SourceLine.h>
#include <cppunit/TestAssert.h>
#include <iomanip>
#include <string>
#include <final/final.h>
@ -509,7 +509,7 @@ void FOptiMoveTest::cygwinTest()
om.set_parm_left_cursor (CSI "%p1%dD");
CPPUNIT_ASSERT_CSTRING ( printSequence(om.moveCursor (1, 2, 3, 4)).c_str()
, "Esc [ 5 ; 4 H ") ;
, "Esc [ 5 ; 4 H " );
CPPUNIT_ASSERT_CSTRING (om.moveCursor (0, 0, 5, 5), CSI "6;6H");
CPPUNIT_ASSERT_CSTRING (om.moveCursor (5, 5, 0, 0), CSI "H");
CPPUNIT_ASSERT_CSTRING (om.moveCursor (79, 1, 0, 1), "\r");

View File

@ -328,7 +328,6 @@ void FPointTest::moveTest()
p1.move (-2, -7);
CPPUNIT_ASSERT ( p1.getX() == 4 );
CPPUNIT_ASSERT ( p1.getY() == -1 );
}
//----------------------------------------------------------------------

View File

@ -28,6 +28,7 @@
#include <clocale>
#include <iomanip>
#include <string>
#include <utility>
#include <vector>
#include <cppunit/BriefTestProgressListener.h>

View File

@ -20,6 +20,10 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <sstream>
#include <string>
#include <utility>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -28,8 +32,6 @@
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <sstream>
#include <final/final.h>
//----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2019 Markus Gans *
* Copyright 2018-2020 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <string>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -28,7 +30,6 @@
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <string>
#include <final/final.h>
#define CPPUNIT_ASSERT_CSTRING(expected, actual) \
@ -237,20 +238,20 @@ void FTermcapQuirksTest::generalTest()
CPPUNIT_ASSERT ( finalcut::FTermcap::attr_without_color == 0 );
CPPUNIT_ASSERT ( finalcut::FTermcap::can_change_color_palette );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_set_a_foreground].string
, CSI "3%p1%dm") ;
, CSI "3%p1%dm" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_set_a_background].string
, CSI "4%p1%dm") ;
, CSI "4%p1%dm" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_initialize_color].string
, OSC "P%p1%x"
"%p2%{255}%*%{1000}%/%02x"
"%p3%{255}%*%{1000}%/%02x"
"%p4%{255}%*%{1000}%/%02x" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_enter_ca_mode].string
, ESC "7" CSI "?47h" ) ;
, ESC "7" CSI "?47h" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_ca_mode].string
, CSI "?47l" ESC "8" CSI "m") ;
, CSI "?47l" ESC "8" CSI "m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_cursor_address].string
, CSI "%i%p1%d;%p2%dH") ;
, CSI "%i%p1%d;%p2%dH" );
// Non standard ECMA-48 (ANSI X3.64) terminal
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_enter_dbl_underline_mode].string
, 0 );
@ -258,27 +259,27 @@ void FTermcapQuirksTest::generalTest()
quirks.terminalFixup();
// Standard ECMA-48 (ANSI X3.64) terminal
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_enter_dbl_underline_mode].string
, CSI "21m") ;
, CSI "21m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_dbl_underline_mode].string
, CSI "24m") ;
, CSI "24m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_bold_mode].string
, CSI "22m") ;
, CSI "22m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_dim_mode].string
, CSI "22m") ;
, CSI "22m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_underline_mode].string
, CSI "24m") ;
, CSI "24m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_blink_mode].string
, CSI "25m") ;
, CSI "25m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_reverse_mode].string
, CSI "27m") ;
, CSI "27m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_secure_mode].string
, CSI "28m") ;
, CSI "28m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_enter_crossed_out_mode].string
, CSI "9m") ;
, CSI "9m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_crossed_out_mode].string
, CSI "29m") ;
, CSI "29m" );
CPPUNIT_ASSERT_CSTRING ( printSequence(caps[finalcut::fc::t_enter_ca_mode].string).c_str()
, "Esc 7 Esc [ ? 4 7 h ") ;
, "Esc 7 Esc [ ? 4 7 h " );
}
//----------------------------------------------------------------------
@ -305,9 +306,9 @@ void FTermcapQuirksTest::xtermTest()
"%p3%{255}%*%{1000}%/%2.2X/"
"%p4%{255}%*%{1000}%/%2.2X" ESC "\\");
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_cursor_invisible].string
, CSI "?25l") ;
, CSI "?25l" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_cursor_normal].string
, CSI "?12l" CSI "?25h") ;
, CSI "?12l" CSI "?25h" );
detect.setXTerminal (false);
}
@ -370,9 +371,9 @@ void FTermcapQuirksTest::cygwinTest()
CPPUNIT_ASSERT ( finalcut::FTermcap::background_color_erase == true );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_cursor_invisible].string
, CSI "?25l") ;
, CSI "?25l" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_cursor_visible].string
, CSI "?25h") ;
, CSI "?25h" );
detect.setCygwinTerminal (false);
}
@ -396,9 +397,9 @@ void FTermcapQuirksTest::linuxTest()
// 8 colors
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_set_a_foreground].string
, CSI "3%p1%dm") ;
, CSI "3%p1%dm" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_set_a_background].string
, CSI "4%p1%dm") ;
, CSI "4%p1%dm" );
CPPUNIT_ASSERT ( finalcut::FTermcap::attr_without_color == 18 );
// 16 colors
@ -406,9 +407,9 @@ void FTermcapQuirksTest::linuxTest()
quirks.terminalFixup();
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_set_a_foreground].string
, CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;22%;m") ;
, CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;22%;m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_set_a_background].string
, CSI "4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m") ;
, CSI "4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m" );
CPPUNIT_ASSERT ( finalcut::FTermcap::attr_without_color == 30 );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_set_attributes].string
@ -418,17 +419,17 @@ void FTermcapQuirksTest::linuxTest()
"%?%p4%t;5%;m"
"%?%p9%t\016%e\017%;" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_enter_alt_charset_mode].string
, "\016") ;
, "\016" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_alt_charset_mode].string
, "\017") ;
, "\017" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_attribute_mode].string
, CSI "0m\017") ;
, CSI "0m\017" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_bold_mode].string
, CSI "22m") ;
, CSI "22m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_blink_mode].string
, CSI "25m") ;
, CSI "25m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_reverse_mode].string
, CSI "27m") ;
, CSI "27m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_secure_mode].string
, 0 );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_protected_mode].string
@ -436,7 +437,7 @@ void FTermcapQuirksTest::linuxTest()
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_crossed_out_mode].string
, 0 );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_orig_pair].string
, CSI "39;49;25m") ;
, CSI "39;49;25m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_enter_dim_mode].string
, 0 );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_dim_mode].string
@ -473,17 +474,17 @@ void FTermcapQuirksTest::rxvtTest()
data.setTermType ("rxvt-16color");
quirks.terminalFixup();
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_enter_alt_charset_mode].string
, ESC "(0") ;
, ESC "(0" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_alt_charset_mode].string
, ESC "(B") ;
, ESC "(B" );
// urxvt
detect.setUrxvtTerminal (true);
quirks.terminalFixup();
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_set_a_foreground].string
, CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm") ;
, CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_set_a_background].string
, CSI "%?%p1%{8}%<%t%p1%'('%+%e%p1%{92}%+%;%dm") ;
, CSI "%?%p1%{8}%<%t%p1%'('%+%e%p1%{92}%+%;%dm" );
detect.setUrxvtTerminal (false);
detect.setRxvtTerminal (false);
@ -508,7 +509,7 @@ void FTermcapQuirksTest::vteTest()
CPPUNIT_ASSERT ( finalcut::FTermcap::attr_without_color == 0 );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_underline_mode].string
, CSI "24m") ;
, CSI "24m" );
detect.setGnomeTerminal (false);
}
@ -563,42 +564,42 @@ void FTermcapQuirksTest::puttyTest()
"%?%p4%t;5%;m"
"%?%p9%t\016%e\017%;" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_enter_dim_mode].string
, CSI "2m") ;
, CSI "2m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_dim_mode].string
, CSI "22m") ;
, CSI "22m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_clr_bol].string
, CSI "1K") ;
, CSI "1K" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_orig_pair].string
, CSI "39;49m") ;
, CSI "39;49m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_orig_colors].string
, OSC "R") ;
, OSC "R" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_column_address].string
, CSI "%i%p1%dG") ;
, CSI "%i%p1%dG" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_row_address].string
, CSI "%i%p1%dd") ;
, CSI "%i%p1%dd" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_enable_acs].string
, ESC "(B" ESC ")0") ;
, ESC "(B" ESC ")0" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_enter_am_mode].string
, CSI "?7h") ;
, CSI "?7h" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_am_mode].string
, CSI "?7l") ;
, CSI "?7l" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_enter_pc_charset_mode].string
, CSI "11m") ;
, CSI "11m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_pc_charset_mode].string
, CSI "10m") ;
, CSI "10m" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_key_mouse].string
, CSI "M") ;
, CSI "M" );
detect.setPuttyTerminal (false);
}
@ -622,13 +623,13 @@ void FTermcapQuirksTest::teratermTest()
CPPUNIT_ASSERT ( finalcut::FTermcap::eat_nl_glitch == true );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_set_a_foreground].string
, CSI "38;5;%p1%dm") ;
, CSI "38;5;%p1%dm" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_set_a_background].string
, CSI "48;5;%p1%dm") ;
, CSI "48;5;%p1%dm" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_exit_attribute_mode].string
, CSI "0m" SI) ;
, CSI "0m" SI );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_orig_pair].string
, CSI "39;49m") ;
, CSI "39;49m" );
detect.setTeraTerm (false);
}
@ -652,100 +653,100 @@ void FTermcapQuirksTest::sunTest()
CPPUNIT_ASSERT ( finalcut::FTermcap::eat_nl_glitch == true );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_parm_up_cursor].string
, CSI "%p1%dA") ;
, CSI "%p1%dA" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_parm_down_cursor].string
, CSI "%p1%dB") ;
, CSI "%p1%dB" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_parm_right_cursor].string
, CSI "%p1%dC") ;
, CSI "%p1%dC" );
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_parm_left_cursor].string
, CSI "%p1%dD") ;
, CSI "%p1%dD" );
for (std::size_t i = 0; finalcut::fc::fkey[i].tname[0] != 0; i++)
{
if ( std::strncmp(finalcut::fc::fkey[i].tname, "K2", 2) == 0 ) // center of keypad
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "218z") ;
, CSI "218z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "kb", 2) == 0 ) // backspace key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, "\b") ;
, "\b" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "kD", 2) == 0
&& std::strlen(finalcut::fc::fkey[i].tname) == 2 ) // delete-character key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, "\177") ;
, "\177" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "@7", 2) == 0 ) // end key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "220z") ;
, CSI "220z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "k;", 2) == 0 ) // F10 function key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "233z") ;
, CSI "233z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "F1", 2) == 0 ) // F11 function key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "234z") ;
, CSI "234z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "F2", 2) == 0 ) // F12 function key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "235z") ;
, CSI "235z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "kh", 2) == 0 ) // home key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "214z") ;
, CSI "214z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "kI", 2) == 0 ) // insert-character key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "247z") ;
, CSI "247z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "kN", 2) == 0 ) // next-page key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "222z") ;
, CSI "222z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "%7", 2) == 0 ) // options key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "194z") ;
, CSI "194z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "kP", 2) == 0 ) // prev-page key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "216z") ;
, CSI "216z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "&5", 2) == 0 ) // resume key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "193z") ;
, CSI "193z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "&8", 2) == 0 ) // undo key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "195z") ;
, CSI "195z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "K2", 2) == 0 ) // center of keypad
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "218z") ;
, CSI "218z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "kDx", 3) == 0 ) // keypad delete
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "249z") ;
, CSI "249z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "@8x", 3) == 0 ) // enter/send key
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "250z") ;
, CSI "250z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "KP1", 3) == 0 ) // keypad slash
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "212z") ;
, CSI "212z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "KP2", 3) == 0 ) // keypad asterisk
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "213z") ;
, CSI "213z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "KP3", 3) == 0 ) // keypad minus sign
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "254z") ;
, CSI "254z" );
if ( std::strncmp(finalcut::fc::fkey[i].tname, "KP4", 3) == 0 ) // keypad plus sign
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string
, CSI "253z") ;
, CSI "253z" );
}
detect.setSunTerminal (false);

View File

@ -93,8 +93,8 @@ void FTermDataTest::defaultDataTest()
CPPUNIT_ASSERT ( data.getTermGeometry() == finalcut::FRect() );
CPPUNIT_ASSERT ( data.getTTYFileDescriptor() == -1 );
CPPUNIT_ASSERT ( data.getBaudrate() == 0 );
CPPUNIT_ASSERT_CSTRING ( data.getTermType(), "") ;
CPPUNIT_ASSERT_CSTRING ( data.getTermFileName(), "") ;
CPPUNIT_ASSERT_CSTRING ( data.getTermType(), "" );
CPPUNIT_ASSERT_CSTRING ( data.getTermFileName(), "" );
CPPUNIT_ASSERT ( data.getXtermFont() == finalcut::FString() );
CPPUNIT_ASSERT ( data.getXtermTitle() == finalcut::FString() );
CPPUNIT_ASSERT ( data.getExitMessage() == finalcut::FString() );
@ -178,13 +178,13 @@ void FTermDataTest::dataTest()
CPPUNIT_ASSERT ( data.getBaudrate() != 9600 );
CPPUNIT_ASSERT ( data.getBaudrate() == 38400 );
CPPUNIT_ASSERT_CSTRING ( data.getTermType(), "") ;
CPPUNIT_ASSERT_CSTRING ( data.getTermType(), "" );
data.setTermType("linux");
CPPUNIT_ASSERT_CSTRING ( data.getTermType(), "linux") ;
CPPUNIT_ASSERT_CSTRING ( data.getTermType(), "linux" );
CPPUNIT_ASSERT_CSTRING ( data.getTermFileName(), "") ;
CPPUNIT_ASSERT_CSTRING ( data.getTermFileName(), "" );
data.setTermFileName("/dev/pts/2");
CPPUNIT_ASSERT_CSTRING ( data.getTermFileName(), "/dev/pts/2") ;
CPPUNIT_ASSERT_CSTRING ( data.getTermFileName(), "/dev/pts/2" );
CPPUNIT_ASSERT ( data.getXtermFont() == finalcut::FString() );
data.setXtermFont("terminus-20");

View File

@ -180,14 +180,14 @@ void FTermDetectionTest::ansiTest()
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( ! detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "ansi") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "ansi" );
// Test fallback to vt100 without TERM environment variable
unsetenv("TERM");
detect.setAnsiTerminal(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
@ -310,7 +310,7 @@ void FTermDetectionTest::rxvtTest()
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "rxvt-16color") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "rxvt-16color" );
printConEmuDebug();
closeConEmuStdStreams();
@ -434,13 +434,13 @@ void FTermDetectionTest::mltermTest()
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "mlterm-256color") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "mlterm-256color" );
setenv ("TERM", "mlterm", 1);
unsetenv("COLORFGBG");
detect.detect();
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "xterm-256color") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "xterm-256color" );
printConEmuDebug();
closeConEmuStdStreams();
@ -756,7 +756,7 @@ void FTermDetectionTest::ktermTest()
detect.setKtermTerminal(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
@ -1011,7 +1011,7 @@ void FTermDetectionTest::linuxTest()
detect.setLinuxTerm(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
@ -1083,7 +1083,7 @@ void FTermDetectionTest::freebsdTest()
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
@ -1153,7 +1153,7 @@ void FTermDetectionTest::netbsdTest()
detect.setNetBSDTerm(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
@ -1223,7 +1223,7 @@ void FTermDetectionTest::openbsdTest()
detect.setOpenBSDTerm(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
@ -1291,7 +1291,7 @@ void FTermDetectionTest::sunTest()
detect.setSunTerminal(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
@ -1354,12 +1354,12 @@ void FTermDetectionTest::screenTest()
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen" );
setenv ("XTERM_VERSION", "XTerm(312)", 1);
detect.detect();
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen-256color") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen-256color" );
printConEmuDebug();
closeConEmuStdStreams();
@ -1423,12 +1423,12 @@ void FTermDetectionTest::tmuxTest()
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen" );
setenv ("VTE_VERSION", "3801", 1);
detect.detect();
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen-256color") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen-256color" );
printConEmuDebug();
closeConEmuStdStreams();
@ -1505,17 +1505,17 @@ void FTermDetectionTest::ttytypeTest()
// Test /dev/tty3 with linux
data.setTermFileName("/dev/tty3");
detect.detect();
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "linux") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "linux" );
// Test /dev/ttyp0 with vt100
data.setTermFileName("/dev/ttyp0");
detect.detect();
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
// Test non-existent /dev/tty8 with fallback to vt100
data.setTermFileName("/dev/tty8");
detect.detect();
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100") ;
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
printConEmuDebug();
closeConEmuStdStreams();

View File

@ -20,6 +20,11 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <unistd.h>
#include <limits>
#include <string>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -27,10 +32,6 @@
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <unistd.h>
#include <limits>
#include <string>
#include "conemu.h"
#include <final/final.h>