Reduces the use of raw loops

This commit is contained in:
Markus Gans 2019-07-14 18:30:35 +02:00
parent 7cd169758c
commit ff9673d262
17 changed files with 231 additions and 150 deletions

View File

@ -1,3 +1,6 @@
2019-07-14 Markus Gans <guru.mail@muenster.de>
* Reduces the use of raw loops
2019-06-30 Markus Gans <guru.mail@muenster.de> 2019-06-30 Markus Gans <guru.mail@muenster.de>
* Expanding the unit test for FTermLinux * Expanding the unit test for FTermLinux
* Update the cp437 unicode map * Update the cp437 unicode map

View File

@ -144,7 +144,7 @@ void ColorChooser::draw()
if ( c == bg_color ) if ( c == bg_color )
{ {
print() << ' ' << fc::Times << ' '; print() << L' ' << fc::Times << L' ';
} }
else else
print (" "); print (" ");

View File

@ -679,7 +679,7 @@ void FDialog::onWindowInactive (FEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::onWindowRaised (FEvent*) void FDialog::onWindowRaised (FEvent*)
{ {
if ( ! (isShown() && isShown()) ) if ( ! isShown() )
return; return;
putArea (getTermPos(), vwin); putArea (getTermPos(), vwin);

View File

@ -453,12 +453,14 @@ int FFileDialog::numOfDirs()
if ( dir_entries.empty() ) if ( dir_entries.empty() )
return 0; return 0;
int n = 0; int n = std::count_if ( std::begin(dir_entries)
, std::end(dir_entries)
for (auto&& entry : dir_entries) , [] (dir_entry& entry)
if ( entry.directory && std::strcmp(entry.name, ".") != 0 ) {
n++; return entry.directory
&& std::strcmp(entry.name, ".") != 0;
}
);
return n; return n;
} }
@ -761,25 +763,26 @@ void FFileDialog::cb_processActivate (FWidget*, FDataPtr)
else else
{ {
bool found = false; bool found = false;
const auto& input = filename.getText().trim();
if ( ! dir_entries.empty() ) if ( ! dir_entries.empty() )
{ {
const auto& input = filename.getText().trim(); found = std::any_of ( std::begin(dir_entries)
, std::end(dir_entries)
for (auto&& entry : dir_entries) , [&input] (dir_entry& entry)
{ {
if ( entry.name && input && ! input.isNull() return entry.name
&& std::strcmp(entry.name, input) == 0 && input
&& entry.directory ) && ! input.isNull()
{ && std::strcmp(entry.name, input) == 0
found = true; && entry.directory;
changeDir(input); }
break; );
}
}
} }
if ( ! found ) if ( found )
changeDir(input);
else
done (FDialog::Accept); done (FDialog::Accept);
} }
} }

View File

@ -1426,11 +1426,14 @@ bool FMouseControl::isMoved()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isInputDataPending() bool FMouseControl::isInputDataPending()
{ {
for (auto&& m : mouse_protocol) return std::any_of ( std::begin(mouse_protocol)
if ( m.second && m.second->isInputDataPending() ) , std::end(mouse_protocol)
return true; , [] (FMouseProtocol::const_reference m)
{
return false; return m.second
&& m.second->isInputDataPending();
}
);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1557,21 +1560,33 @@ void FMouseControl::drawGpmPointer()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMouse* FMouseControl::getMouseWithData() FMouse* FMouseControl::getMouseWithData()
{ {
for (auto&& m : mouse_protocol) const auto& iter = \
if ( m.second && m.second->hasData() ) std::find_if ( std::begin(mouse_protocol)
return m.second; , std::end(mouse_protocol)
, [] (FMouseProtocol::const_reference m)
{
return m.second
&& m.second->hasData();
}
);
return 0; return ( iter != mouse_protocol.end() ) ? iter->second : 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMouse* FMouseControl::getMouseWithEvent() FMouse* FMouseControl::getMouseWithEvent()
{ {
for (auto&& m : mouse_protocol) const auto& iter = \
if ( m.second && m.second->hasEvent() ) std::find_if ( std::begin(mouse_protocol)
return m.second; , std::end(mouse_protocol)
, [] (FMouseProtocol::const_reference m)
{
return m.second
&& m.second->hasEvent();
}
);
return 0; return ( iter != mouse_protocol.end() ) ? iter->second : 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -1546,12 +1546,13 @@ inline void FOptiAttr::reset (charData*& attr)
bool FOptiAttr::caused_reset_attributes (char cap[], uChar test) bool FOptiAttr::caused_reset_attributes (char cap[], uChar test)
{ {
// test if "cap" reset all attributes // test if "cap" reset all attributes
auto& ue = F_exit_underline_mode.cap;
auto& se = F_exit_standout_mode.cap;
auto& me = F_exit_attribute_mode.cap;
if ( cap ) if ( cap )
{ {
auto& ue = F_exit_underline_mode.cap;
auto& se = F_exit_standout_mode.cap;
auto& me = F_exit_attribute_mode.cap;
if ( (test & test_ansi_reset) && std::strncmp (cap, CSI "m", 3) == 0 ) if ( (test & test_ansi_reset) && std::strncmp (cap, CSI "m", 3) == 0 )
return true; return true;

View File

@ -51,7 +51,11 @@ FTermXTerminal* FTerm::xterm = nullptr;
FKeyboard* FTerm::keyboard = nullptr; FKeyboard* FTerm::keyboard = nullptr;
FMouseControl* FTerm::mouse = nullptr; FMouseControl* FTerm::mouse = nullptr;
#if defined(__linux__) #if defined(UNIT_TEST)
FTermLinux* FTerm::linux = nullptr;
FTermFreeBSD* FTerm::freebsd = nullptr;
FTermOpenBSD* FTerm::openbsd = nullptr;
#elif defined(__linux__)
FTermLinux* FTerm::linux = nullptr; FTermLinux* FTerm::linux = nullptr;
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
FTermFreeBSD* FTerm::freebsd = nullptr; FTermFreeBSD* FTerm::freebsd = nullptr;
@ -1731,7 +1735,7 @@ inline void FTerm::allocationValues()
linux = new FTermLinux(); linux = new FTermLinux();
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
freebsd = new FTermFreeBSD(); freebsd = new FTermFreeBSD();
#elif defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
openbsd = new FTermOpenBSD(); openbsd = new FTermOpenBSD();
#endif #endif
@ -1754,7 +1758,7 @@ inline void FTerm::deallocationValues()
delete debug_data; delete debug_data;
#endif #endif
#if defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
if ( openbsd ) if ( openbsd )
delete openbsd; delete openbsd;
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
@ -1924,7 +1928,7 @@ void FTerm::initOSspecifics()
freebsd->disableChangeCursorStyle(); freebsd->disableChangeCursorStyle();
freebsd->init(); // Initialize BSD console freebsd->init(); // Initialize BSD console
#elif defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
if ( init_values.meta_sends_escape ) if ( init_values.meta_sends_escape )
openbsd->enableMetaSendsEscape(); openbsd->enableMetaSendsEscape();
else else
@ -2035,7 +2039,7 @@ void FTerm::finishOSspecifics1()
linux->finish(); linux->finish();
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
freebsd->finish(); freebsd->finish();
#elif defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
openbsd->finish(); openbsd->finish();
#endif #endif
} }

View File

@ -846,7 +846,7 @@ inline char* FTermDetection::secDA_Analysis_24 (char current_termtype[])
char* new_termtype = current_termtype; char* new_termtype = current_termtype;
#if defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
if ( secondary_da.terminal_id_version == 20 if ( secondary_da.terminal_id_version == 20
&& FTermOpenBSD::isBSDConsole() ) && FTermOpenBSD::isBSDConsole() )
@ -861,7 +861,7 @@ inline char* FTermDetection::secDA_Analysis_24 (char current_termtype[])
} }
} }
#endif // defined(__NetBSD__) || defined(__OpenBSD__) #endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
return new_termtype; return new_termtype;
} }

View File

@ -21,6 +21,7 @@
***********************************************************************/ ***********************************************************************/
#include "final/fcharmap.h" #include "final/fcharmap.h"
#include "final/fterm.h"
#include "final/ftermfreebsd.h" #include "final/ftermfreebsd.h"
namespace finalcut namespace finalcut
@ -53,7 +54,7 @@ void FTermFreeBSD::setCursorStyle (CursorStyle style, bool hidden)
{ {
// Set cursor style in a BSD console // Set cursor style in a BSD console
if ( ! fsysten || ! isFreeBSDConsole() || ! change_cursorstyle ) if ( ! fsystem || ! isFreeBSDConsole() || ! change_cursorstyle )
return; return;
cursor_style = style; cursor_style = style;
@ -61,7 +62,7 @@ void FTermFreeBSD::setCursorStyle (CursorStyle style, bool hidden)
if ( hidden ) if ( hidden )
return; return;
fsysten->ioctl (0, CONS_CURSORTYPE, &style); fsystem->ioctl (0, CONS_CURSORTYPE, &style);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -71,7 +72,7 @@ bool FTermFreeBSD::isFreeBSDConsole()
keymap_t keymap; keymap_t keymap;
if ( fsysten && fsysten->ioctl(0, GIO_KEYMAP, &keymap) == 0 ) if ( fsystem && fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
return true; return true;
else else
return false; return false;
@ -149,7 +150,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey()
keymap_t keymap; keymap_t keymap;
if ( fsystem ) if ( fsystem )
ret = fsysten->ioctl (0, GIO_KEYMAP, &keymap); ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
if ( ret < 0 ) if ( ret < 0 )
return false; return false;
@ -169,7 +170,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
keymap_t keymap; keymap_t keymap;
if ( fsystem ) if ( fsystem )
ret = fsysten->ioctl (0, GIO_KEYMAP, &keymap); ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
if ( ret < 0 ) if ( ret < 0 )
return false; return false;
@ -178,7 +179,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
keymap.key[left_alt].map[0] = key; keymap.key[left_alt].map[0] = key;
if ( (keymap.n_keys > 0) if ( (keymap.n_keys > 0)
&& fsystem && (fsysten->ioctl(0, PIO_KEYMAP, &keymap) < 0) ) && fsystem && (fsystem->ioctl(0, PIO_KEYMAP, &keymap) < 0) )
return false; return false;
else else
return true; return true;

View File

@ -46,8 +46,8 @@ namespace finalcut
FSystem* FTermLinux::fsystem = nullptr; FSystem* FTermLinux::fsystem = nullptr;
FTermDetection* FTermLinux::term_detection = nullptr; FTermDetection* FTermLinux::term_detection = nullptr;
fc::linuxConsoleCursorStyle FTermLinux::linux_console_cursor_style; fc::linuxConsoleCursorStyle FTermLinux::linux_console_cursor_style;
FTermLinux::ColorMap FTermLinux::saved_color_map; FTermLinux::ColorMap FTermLinux::saved_color_map{};
FTermLinux::ColorMap FTermLinux::cmap; FTermLinux::ColorMap FTermLinux::cmap{};
int FTermLinux::framebuffer_bpp = -1; int FTermLinux::framebuffer_bpp = -1;
#endif // defined(__linux__) #endif // defined(__linux__)
@ -152,6 +152,9 @@ void FTermLinux::init()
{ {
// initialize Linux console // initialize Linux console
if ( ! fsystem )
fsystem = FTerm::getFSystem();
fterm_data = FTerm::getFTermData(); fterm_data = FTerm::getFTermData();
fsystem = FTerm::getFSystem(); fsystem = FTerm::getFSystem();
term_detection = FTerm::getFTermDetection(); term_detection = FTerm::getFTermDetection();
@ -159,6 +162,7 @@ void FTermLinux::init()
screen_font.data = nullptr; screen_font.data = nullptr;
fterm_data->supportShadowCharacter (true); fterm_data->supportShadowCharacter (true);
fterm_data->supportHalfBlockCharacter (true); fterm_data->supportHalfBlockCharacter (true);
getVGAPalette();
if ( FTerm::openConsole() == 0 ) if ( FTerm::openConsole() == 0 )
{ {
@ -505,8 +509,8 @@ int FTermLinux::getFramebuffer_bpp()
return -1; return -1;
} }
if ( ! fsystem->ioctl(fd, FBIOGET_VSCREENINFO, &fb_var) if ( fsystem->ioctl(fd, FBIOGET_VSCREENINFO, &fb_var) == 0
&& ! fsystem->ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix) ) && fsystem->ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix) == 0 )
{ {
fsystem->close(fd); fsystem->close(fd);
return int(fb_var.bits_per_pixel); return int(fb_var.bits_per_pixel);
@ -864,6 +868,36 @@ int FTermLinux::setBlinkAsIntensity (bool enable)
return 0; return 0;
} }
//----------------------------------------------------------------------
void FTermLinux::getVGAPalette()
{
if ( fsystem && fsystem->ioctl(0, GIO_CMAP, &cmap) != 0 )
setVGADefaultPalette(); // Fallback, if GIO_CMAP does not work
}
//----------------------------------------------------------------------
void FTermLinux::setVGADefaultPalette()
{
constexpr rgb defaultColor[16] =
{
{0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00},
{0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00},
{0x00, 0x00, 0xaa}, {0xaa, 0x00, 0xaa},
{0x00, 0xaa, 0xaa}, {0xaa, 0xaa, 0xaa},
{0x55, 0x55, 0x55}, {0xff, 0x55, 0x55},
{0x55, 0xff, 0x55}, {0xff, 0xff, 0x55},
{0x55, 0x55, 0xff}, {0xff, 0x55, 0xff},
{0x55, 0xff, 0xff}, {0xff, 0xff, 0xff}
};
for (std::size_t index = 0; index < 16; index++)
{
cmap.color[index].red = defaultColor[index].red;
cmap.color[index].green = defaultColor[index].green;
cmap.color[index].blue = defaultColor[index].blue;
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b) bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b)
{ {
@ -878,10 +912,10 @@ bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b)
cmap.color[index].blue = uChar(b); cmap.color[index].blue = uChar(b);
} }
if ( fsystem && fsystem->ioctl (0, PIO_CMAP, &cmap) ) if ( fsystem && fsystem->ioctl(0, PIO_CMAP, &cmap) == 0 )
return false;
else
return true; return true;
else
return false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -889,10 +923,10 @@ bool FTermLinux::saveVGAPalette()
{ {
// Save the current vga color map // Save the current vga color map
if ( fsystem && fsystem->ioctl (0, GIO_CMAP, &saved_color_map) ) if ( fsystem && fsystem->ioctl(0, GIO_CMAP, &saved_color_map) == 0 )
has_saved_palette = false;
else
has_saved_palette = true; has_saved_palette = true;
else
has_saved_palette = false;
return has_saved_palette; return has_saved_palette;
} }
@ -902,36 +936,16 @@ bool FTermLinux::resetVGAPalette()
{ {
// Reset the vga color map // Reset the vga color map
if ( ! fsystem )
fsystem = FTerm::getFSystem();
if ( has_saved_palette ) if ( has_saved_palette )
{ {
if ( fsystem->ioctl (0, PIO_CMAP, &saved_color_map) ) if ( fsystem && fsystem->ioctl (0, PIO_CMAP, &saved_color_map) )
return false; return false;
} }
else else
{ {
constexpr rgb defaultColor[16] = setVGADefaultPalette();
{
{0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00},
{0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00},
{0x00, 0x00, 0xaa}, {0xaa, 0x00, 0xaa},
{0x00, 0xaa, 0xaa}, {0xaa, 0xaa, 0xaa},
{0x55, 0x55, 0x55}, {0xff, 0x55, 0x55},
{0x55, 0xff, 0x55}, {0xff, 0xff, 0x55},
{0x55, 0x55, 0xff}, {0xff, 0x55, 0xff},
{0x55, 0xff, 0xff}, {0xff, 0xff, 0xff}
};
for (std::size_t index = 0; index < 16; index++) if ( fsystem && fsystem->ioctl(0, PIO_CMAP, &cmap) != 0 )
{
cmap.color[index].red = defaultColor[index].red;
cmap.color[index].green = defaultColor[index].green;
cmap.color[index].blue = defaultColor[index].blue;
}
if ( fsystem->ioctl (0, PIO_CMAP, &cmap) )
return false; return false;
} }

View File

@ -2063,7 +2063,7 @@ inline void FWidget::insufficientSpaceAdjust()
if ( getHeight() < size_hints.min_height ) if ( getHeight() < size_hints.min_height )
adjust_wsize.setWidth(size_hints.min_height); adjust_wsize.setWidth(size_hints.min_height);
if ( getHeight() <= 0 ) if ( getHeight() == 0 )
adjust_wsize.setHeight(1); adjust_wsize.setHeight(1);
} }

View File

@ -92,7 +92,7 @@ class FListViewItem : public FObject
FListViewItem& operator = (const FListViewItem&); FListViewItem& operator = (const FListViewItem&);
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const override;
uInt getColumnCount() const; uInt getColumnCount() const;
int getSortColumn() const; int getSortColumn() const;
FString getText (int) const; FString getText (int) const;
@ -580,8 +580,15 @@ FObject::FObjectIterator
{ {
FStringList str_cols; FStringList str_cols;
for (auto& col : list) std::transform ( std::begin(list)
str_cols.push_back (FString() << col); , std::end(list)
, std::back_inserter(str_cols)
, [] (const T& col) -> const FString
{
const FString s = FString() << col;
return std::move(s);
}
);
auto item_iter = insert (str_cols, d, parent_iter); auto item_iter = insert (str_cols, d, parent_iter);
return item_iter; return item_iter;
@ -609,8 +616,15 @@ FObject::FObjectIterator
{ {
FStringList str_cols; FStringList str_cols;
for (auto& col : cols) std::transform ( std::begin(cols)
str_cols.push_back (FString() << col); , std::end(cols)
, std::back_inserter(str_cols)
, [] (const ColT& col) -> const FString
{
const FString s = FString() << col;
return std::move(s);
}
);
auto item_iter = insert (str_cols, d, parent_iter); auto item_iter = insert (str_cols, d, parent_iter);
return item_iter; return item_iter;

View File

@ -502,6 +502,9 @@ class FMouseControl
void drawGpmPointer(); void drawGpmPointer();
private: private:
// Typedef
typedef std::map<FMouse::mouse_type, FMouse*> FMouseProtocol;
// Accessor // Accessor
FMouse* getMouseWithData(); FMouse* getMouseWithData();
FMouse* getMouseWithEvent(); FMouse* getMouseWithEvent();
@ -510,10 +513,10 @@ class FMouseControl
void disableXTermMouse(); void disableXTermMouse();
// Data Member // Data Member
std::map<FMouse::mouse_type, FMouse*> mouse_protocol{}; FMouseProtocol mouse_protocol{};
FPoint zero_point{0, 0}; FPoint zero_point{0, 0};
bool use_gpm_mouse{false}; bool use_gpm_mouse{false};
bool use_xterm_mouse{false}; bool use_xterm_mouse{false};
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -94,18 +94,18 @@ class FSystemImpl : public FSystem
// Methods // Methods
#if defined(__linux__) #if defined(__linux__)
#if defined(__x86_64__) || defined(__i386) || defined(__arm__) #if defined(__x86_64__) || defined(__i386) || defined(__arm__)
virtual uChar inPortByte (uShort port) virtual uChar inPortByte (uShort port) override
{ {
return ::inb (port); return ::inb (port);
} }
#else #else
virtual uChar inPortByte (uShort) virtual uChar inPortByte (uShort) override
{ {
return 0; return 0;
} }
#endif #endif
#else #else
virtual uChar inPortByte (uShort) virtual uChar inPortByte (uShort) override
{ {
return 0; return 0;
} }
@ -114,26 +114,26 @@ class FSystemImpl : public FSystem
#if defined(__linux__) #if defined(__linux__)
#if defined(__x86_64__) || defined(__i386) || defined(__arm__) #if defined(__x86_64__) || defined(__i386) || defined(__arm__)
virtual void outPortByte (uChar value, uShort port) virtual void outPortByte (uChar value, uShort port) override
{ {
::outb (value, port); ::outb (value, port);
} }
#else #else
virtual void outPortByte (uChar, uShort) virtual void outPortByte (uChar, uShort) override
{ } { }
#endif #endif
#else #else
virtual void outPortByte (uChar, uShort) virtual void outPortByte (uChar, uShort) override
{ } { }
#endif #endif
virtual int isTTY (int fd) virtual int isTTY (int fd) override
{ {
return ::isatty(fd); return ::isatty(fd);
} }
virtual int ioctl (int fd, uLong request, ...) virtual int ioctl (int fd, uLong request, ...) override
{ {
va_list args; va_list args;
va_start (args, request); va_start (args, request);
@ -143,7 +143,7 @@ class FSystemImpl : public FSystem
return ret; return ret;
} }
virtual int open (const char* pathname, int flags, ...) virtual int open (const char* pathname, int flags, ...) override
{ {
va_list args; va_list args;
va_start (args, flags); va_start (args, flags);
@ -153,22 +153,22 @@ class FSystemImpl : public FSystem
return ret; return ret;
} }
virtual int close (int fildes) virtual int close (int fildes) override
{ {
return ::close(fildes); return ::close(fildes);
} }
virtual FILE* fopen (const char* path, const char* mode) virtual FILE* fopen (const char* path, const char* mode) override
{ {
return std::fopen (path, mode); return std::fopen (path, mode);
} }
virtual int fclose (FILE* fp) virtual int fclose (FILE* fp) override
{ {
return std::fclose (fp); return std::fclose (fp);
} }
virtual int putchar (int c) virtual int putchar (int c) override
{ {
#if defined(__sun) && defined(__SVR4) #if defined(__sun) && defined(__SVR4)
return std::putchar(char(c)); return std::putchar(char(c));
@ -177,7 +177,7 @@ class FSystemImpl : public FSystem
#endif #endif
} }
virtual int tputs (const char* str, int affcnt, int (*putc)(int)) virtual int tputs (const char* str, int affcnt, int (*putc)(int)) override
{ {
#if defined(__sun) && defined(__SVR4) #if defined(__sun) && defined(__SVR4)
return ::tputs (C_STR(str), affcnt, reinterpret_cast<int (*)(char)>(putc)); return ::tputs (C_STR(str), affcnt, reinterpret_cast<int (*)(char)>(putc));
@ -186,7 +186,7 @@ class FSystemImpl : public FSystem
#endif #endif
} }
virtual uid_t getuid() virtual uid_t getuid() override
{ {
return ::getuid(); return ::getuid();
} }

View File

@ -132,7 +132,11 @@
#include "final/ftermdebugdata.h" #include "final/ftermdebugdata.h"
#include "final/ftermdetection.h" #include "final/ftermdetection.h"
#if defined(__linux__) #if defined(UNIT_TEST)
#include "final/ftermlinux.h"
#include "final/ftermfreebsd.h"
#include "final/ftermopenbsd.h"
#elif defined(__linux__)
#include "final/ftermlinux.h" #include "final/ftermlinux.h"
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
#include "final/ftermfreebsd.h" #include "final/ftermfreebsd.h"
@ -196,7 +200,11 @@ class FTerm final
static FKeyboard* getFKeyboard(); static FKeyboard* getFKeyboard();
static FMouseControl* getFMouseControl(); static FMouseControl* getFMouseControl();
#if defined(__linux__) #if defined(UNIT_TEST)
static FTermLinux* getFTermLinux();
static FTermFreeBSD* getFTermFreeBSD();
static FTermOpenBSD* getFTermOpenBSD();
#elif defined(__linux__)
static FTermLinux* getFTermLinux(); static FTermLinux* getFTermLinux();
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
static FTermFreeBSD* getFTermFreeBSD(); static FTermFreeBSD* getFTermFreeBSD();
@ -323,7 +331,7 @@ class FTerm final
newfont = false; newfont = false;
encoding = fc::UNKNOWN; encoding = fc::UNKNOWN;
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
meta_sends_escape = true; meta_sends_escape = true;
change_cursorstyle = true; change_cursorstyle = true;
#elif defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__NetBSD__) || defined(__OpenBSD__)
@ -340,7 +348,7 @@ class FTerm final
uInt8 : 2; // padding bits uInt8 : 2; // padding bits
fc::encoding encoding; fc::encoding encoding;
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
uInt8 meta_sends_escape : 1; uInt8 meta_sends_escape : 1;
uInt8 change_cursorstyle : 1; uInt8 change_cursorstyle : 1;
uInt8 : 6; // padding bits uInt8 : 6; // padding bits
@ -413,7 +421,12 @@ class FTerm final
static FKeyboard* keyboard; static FKeyboard* keyboard;
static FMouseControl* mouse; static FMouseControl* mouse;
#if defined(__linux__) #if defined(UNIT_TEST)
#undef linux
static FTermLinux* linux;
static FTermFreeBSD* freebsd;
static FTermOpenBSD* openbsd;
#elif defined(__linux__)
#undef linux #undef linux
static FTermLinux* linux; static FTermLinux* linux;
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
@ -631,7 +644,7 @@ inline FTermLinux* FTerm::getFTermLinux()
return linux; return linux;
} }
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FTermFreeBSD* FTerm::getFTermFreeBSD() inline FTermFreeBSD* FTerm::getFTermFreeBSD()
{ {
@ -651,7 +664,7 @@ inline FTermFreeBSD* FTerm::getFTermFreeBSD()
return freebsd; return freebsd;
} }
#elif defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FTermOpenBSD* FTerm::getFTermOpenBSD() inline FTermOpenBSD* FTerm::getFTermOpenBSD()
{ {

View File

@ -155,6 +155,8 @@ class FTermLinux final
static uChar getAttributeMode(); static uChar getAttributeMode();
static void setAttributeMode (uChar); static void setAttributeMode (uChar);
static int setBlinkAsIntensity (bool); static int setBlinkAsIntensity (bool);
static void getVGAPalette();
static void setVGADefaultPalette();
static bool setVGAPalette (FColor, int, int, int); static bool setVGAPalette (FColor, int, int, int);
static bool saveVGAPalette(); static bool saveVGAPalette();
static bool resetVGAPalette(); static bool resetVGAPalette();

View File

@ -104,17 +104,17 @@ class FSystemTest : public finalcut::FSystem
virtual ~FSystemTest(); virtual ~FSystemTest();
// Methods // Methods
virtual uChar inPortByte (uShort); virtual uChar inPortByte (uShort) override;
virtual void outPortByte (uChar, uShort); virtual void outPortByte (uChar, uShort) override;
virtual int isTTY (int); virtual int isTTY (int) override;
virtual int ioctl (int, uLong, ...); virtual int ioctl (int, uLong, ...) override;
virtual int open (const char*, int, ...); virtual int open (const char*, int, ...) override;
virtual int close (int); virtual int close (int) override;
virtual FILE* fopen (const char*, const char*); virtual FILE* fopen (const char*, const char*) override;
virtual int fclose (FILE*); virtual int fclose (FILE*) override;
virtual int putchar (int); virtual int putchar (int) override;
virtual int tputs (const char*, int, int (*)(int)); virtual int tputs (const char*, int, int (*)(int)) override;
virtual uid_t getuid(); virtual uid_t getuid() override;
rgb& getRGB (std::size_t); rgb& getRGB (std::size_t);
console_font_op& getConsoleFont(); console_font_op& getConsoleFont();
shiftstate& getShiftState(); shiftstate& getShiftState();
@ -1282,7 +1282,7 @@ int FSystemTest::ioctl (int fd, uLong request, ...)
std::cerr << "Call: ioctl (fd=" << fd std::cerr << "Call: ioctl (fd=" << fd
<< ", request=" << req_string << ", request=" << req_string
<< "(0x" << std::hex << request << ")" << "(0x" << std::hex << request << ")"
<< ", argp=" << argp << ")\n"; << ", argp=" << argp << std::dec << ")\n";
return ret_val; return ret_val;
} }
@ -1837,7 +1837,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB0.red == 0x00 ); CPPUNIT_ASSERT ( RGB0.red == 0x00 );
CPPUNIT_ASSERT ( RGB0.green == 0x00 ); CPPUNIT_ASSERT ( RGB0.green == 0x00 );
CPPUNIT_ASSERT ( RGB0.blue == 0x00 ); CPPUNIT_ASSERT ( RGB0.blue == 0x00 );
linux.setPalette (index, 0x01, 0x02, 0x03); CPPUNIT_ASSERT ( linux.setPalette (index, 0x01, 0x02, 0x03) );
CPPUNIT_ASSERT ( RGB0.red == 0x01 ); CPPUNIT_ASSERT ( RGB0.red == 0x01 );
CPPUNIT_ASSERT ( RGB0.green == 0x02 ); CPPUNIT_ASSERT ( RGB0.green == 0x02 );
CPPUNIT_ASSERT ( RGB0.blue == 0x03 ); CPPUNIT_ASSERT ( RGB0.blue == 0x03 );
@ -1847,7 +1847,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB1.red == 0x00 ); CPPUNIT_ASSERT ( RGB1.red == 0x00 );
CPPUNIT_ASSERT ( RGB1.green == 0x00 ); CPPUNIT_ASSERT ( RGB1.green == 0x00 );
CPPUNIT_ASSERT ( RGB1.blue == 0xaa ); CPPUNIT_ASSERT ( RGB1.blue == 0xaa );
linux.setPalette (index, 0x04, 0x05, 0x06); CPPUNIT_ASSERT ( linux.setPalette (index, 0x04, 0x05, 0x06) );
CPPUNIT_ASSERT ( RGB1.red == 0x04 ); CPPUNIT_ASSERT ( RGB1.red == 0x04 );
CPPUNIT_ASSERT ( RGB1.green == 0x05 ); CPPUNIT_ASSERT ( RGB1.green == 0x05 );
CPPUNIT_ASSERT ( RGB1.blue == 0x06 ); CPPUNIT_ASSERT ( RGB1.blue == 0x06 );
@ -1857,7 +1857,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB2.red == 0x00 ); CPPUNIT_ASSERT ( RGB2.red == 0x00 );
CPPUNIT_ASSERT ( RGB2.green == 0xaa ); CPPUNIT_ASSERT ( RGB2.green == 0xaa );
CPPUNIT_ASSERT ( RGB2.blue == 0x00 ); CPPUNIT_ASSERT ( RGB2.blue == 0x00 );
linux.setPalette (index, 0x07, 0x08, 0x09); CPPUNIT_ASSERT ( linux.setPalette (index, 0x07, 0x08, 0x09) );
CPPUNIT_ASSERT ( RGB2.red == 0x07 ); CPPUNIT_ASSERT ( RGB2.red == 0x07 );
CPPUNIT_ASSERT ( RGB2.green == 0x08 ); CPPUNIT_ASSERT ( RGB2.green == 0x08 );
CPPUNIT_ASSERT ( RGB2.blue == 0x09 ); CPPUNIT_ASSERT ( RGB2.blue == 0x09 );
@ -1867,7 +1867,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB3.red == 0x00 ); CPPUNIT_ASSERT ( RGB3.red == 0x00 );
CPPUNIT_ASSERT ( RGB3.green == 0xaa ); CPPUNIT_ASSERT ( RGB3.green == 0xaa );
CPPUNIT_ASSERT ( RGB3.blue == 0xaa ); CPPUNIT_ASSERT ( RGB3.blue == 0xaa );
linux.setPalette (index, 0x0a, 0x0b, 0x0c); CPPUNIT_ASSERT ( linux.setPalette (index, 0x0a, 0x0b, 0x0c) );
CPPUNIT_ASSERT ( RGB3.red == 0x0a ); CPPUNIT_ASSERT ( RGB3.red == 0x0a );
CPPUNIT_ASSERT ( RGB3.green == 0x0b ); CPPUNIT_ASSERT ( RGB3.green == 0x0b );
CPPUNIT_ASSERT ( RGB3.blue == 0x0c ); CPPUNIT_ASSERT ( RGB3.blue == 0x0c );
@ -1877,7 +1877,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB4.red == 0xaa ); CPPUNIT_ASSERT ( RGB4.red == 0xaa );
CPPUNIT_ASSERT ( RGB4.green == 0x00 ); CPPUNIT_ASSERT ( RGB4.green == 0x00 );
CPPUNIT_ASSERT ( RGB4.blue == 0x00 ); CPPUNIT_ASSERT ( RGB4.blue == 0x00 );
linux.setPalette (index, 0x0d, 0x0e, 0x0f); CPPUNIT_ASSERT ( linux.setPalette (index, 0x0d, 0x0e, 0x0f) );
CPPUNIT_ASSERT ( RGB4.red == 0x0d ); CPPUNIT_ASSERT ( RGB4.red == 0x0d );
CPPUNIT_ASSERT ( RGB4.green == 0x0e ); CPPUNIT_ASSERT ( RGB4.green == 0x0e );
CPPUNIT_ASSERT ( RGB4.blue == 0x0f ); CPPUNIT_ASSERT ( RGB4.blue == 0x0f );
@ -1887,7 +1887,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB5.red == 0xaa ); CPPUNIT_ASSERT ( RGB5.red == 0xaa );
CPPUNIT_ASSERT ( RGB5.green == 0x00 ); CPPUNIT_ASSERT ( RGB5.green == 0x00 );
CPPUNIT_ASSERT ( RGB5.blue == 0xaa ); CPPUNIT_ASSERT ( RGB5.blue == 0xaa );
linux.setPalette (index, 0x10, 0x11, 0x12); CPPUNIT_ASSERT ( linux.setPalette (index, 0x10, 0x11, 0x12) );
CPPUNIT_ASSERT ( RGB5.red == 0x10 ); CPPUNIT_ASSERT ( RGB5.red == 0x10 );
CPPUNIT_ASSERT ( RGB5.green == 0x11 ); CPPUNIT_ASSERT ( RGB5.green == 0x11 );
CPPUNIT_ASSERT ( RGB5.blue == 0x12 ); CPPUNIT_ASSERT ( RGB5.blue == 0x12 );
@ -1897,7 +1897,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB6.red == 0xaa ); CPPUNIT_ASSERT ( RGB6.red == 0xaa );
CPPUNIT_ASSERT ( RGB6.green == 0x55 ); CPPUNIT_ASSERT ( RGB6.green == 0x55 );
CPPUNIT_ASSERT ( RGB6.blue == 0x00 ); CPPUNIT_ASSERT ( RGB6.blue == 0x00 );
linux.setPalette (index, 0x13, 0x14, 0x15); CPPUNIT_ASSERT ( linux.setPalette (index, 0x13, 0x14, 0x15) );
CPPUNIT_ASSERT ( RGB6.red == 0x13 ); CPPUNIT_ASSERT ( RGB6.red == 0x13 );
CPPUNIT_ASSERT ( RGB6.green == 0x14 ); CPPUNIT_ASSERT ( RGB6.green == 0x14 );
CPPUNIT_ASSERT ( RGB6.blue == 0x15 ); CPPUNIT_ASSERT ( RGB6.blue == 0x15 );
@ -1907,7 +1907,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB7.red == 0xaa ); CPPUNIT_ASSERT ( RGB7.red == 0xaa );
CPPUNIT_ASSERT ( RGB7.green == 0xaa ); CPPUNIT_ASSERT ( RGB7.green == 0xaa );
CPPUNIT_ASSERT ( RGB7.blue == 0xaa ); CPPUNIT_ASSERT ( RGB7.blue == 0xaa );
linux.setPalette (index, 0x16, 0x17, 0x18); CPPUNIT_ASSERT ( linux.setPalette (index, 0x16, 0x17, 0x18) );
CPPUNIT_ASSERT ( RGB7.red == 0x16 ); CPPUNIT_ASSERT ( RGB7.red == 0x16 );
CPPUNIT_ASSERT ( RGB7.green == 0x17 ); CPPUNIT_ASSERT ( RGB7.green == 0x17 );
CPPUNIT_ASSERT ( RGB7.blue == 0x18 ); CPPUNIT_ASSERT ( RGB7.blue == 0x18 );
@ -1917,7 +1917,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB8.red == 0x55 ); CPPUNIT_ASSERT ( RGB8.red == 0x55 );
CPPUNIT_ASSERT ( RGB8.green == 0x55 ); CPPUNIT_ASSERT ( RGB8.green == 0x55 );
CPPUNIT_ASSERT ( RGB8.blue == 0x55 ); CPPUNIT_ASSERT ( RGB8.blue == 0x55 );
linux.setPalette (index, 0x19, 0x20, 0x21); CPPUNIT_ASSERT ( linux.setPalette (index, 0x19, 0x20, 0x21) );
CPPUNIT_ASSERT ( RGB8.red == 0x19 ); CPPUNIT_ASSERT ( RGB8.red == 0x19 );
CPPUNIT_ASSERT ( RGB8.green == 0x20 ); CPPUNIT_ASSERT ( RGB8.green == 0x20 );
CPPUNIT_ASSERT ( RGB8.blue == 0x21 ); CPPUNIT_ASSERT ( RGB8.blue == 0x21 );
@ -1927,7 +1927,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB9.red == 0x55 ); CPPUNIT_ASSERT ( RGB9.red == 0x55 );
CPPUNIT_ASSERT ( RGB9.green == 0x55 ); CPPUNIT_ASSERT ( RGB9.green == 0x55 );
CPPUNIT_ASSERT ( RGB9.blue == 0xff ); CPPUNIT_ASSERT ( RGB9.blue == 0xff );
linux.setPalette (index, 0x22, 0x23, 0x24); CPPUNIT_ASSERT ( linux.setPalette (index, 0x22, 0x23, 0x24) );
CPPUNIT_ASSERT ( RGB9.red == 0x22 ); CPPUNIT_ASSERT ( RGB9.red == 0x22 );
CPPUNIT_ASSERT ( RGB9.green == 0x23 ); CPPUNIT_ASSERT ( RGB9.green == 0x23 );
CPPUNIT_ASSERT ( RGB9.blue == 0x24 ); CPPUNIT_ASSERT ( RGB9.blue == 0x24 );
@ -1937,7 +1937,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB10.red == 0x55 ); CPPUNIT_ASSERT ( RGB10.red == 0x55 );
CPPUNIT_ASSERT ( RGB10.green == 0xff ); CPPUNIT_ASSERT ( RGB10.green == 0xff );
CPPUNIT_ASSERT ( RGB10.blue == 0x55 ); CPPUNIT_ASSERT ( RGB10.blue == 0x55 );
linux.setPalette (index, 0x25, 0x26, 0x27); CPPUNIT_ASSERT ( linux.setPalette (index, 0x25, 0x26, 0x27) );
CPPUNIT_ASSERT ( RGB10.red == 0x25 ); CPPUNIT_ASSERT ( RGB10.red == 0x25 );
CPPUNIT_ASSERT ( RGB10.green == 0x26 ); CPPUNIT_ASSERT ( RGB10.green == 0x26 );
CPPUNIT_ASSERT ( RGB10.blue == 0x27 ); CPPUNIT_ASSERT ( RGB10.blue == 0x27 );
@ -1947,7 +1947,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB11.red == 0x55 ); CPPUNIT_ASSERT ( RGB11.red == 0x55 );
CPPUNIT_ASSERT ( RGB11.green == 0xff ); CPPUNIT_ASSERT ( RGB11.green == 0xff );
CPPUNIT_ASSERT ( RGB11.blue == 0xff ); CPPUNIT_ASSERT ( RGB11.blue == 0xff );
linux.setPalette (index, 0x28, 0x29, 0x30); CPPUNIT_ASSERT ( linux.setPalette (index, 0x28, 0x29, 0x30) );
CPPUNIT_ASSERT ( RGB11.red == 0x28 ); CPPUNIT_ASSERT ( RGB11.red == 0x28 );
CPPUNIT_ASSERT ( RGB11.green == 0x29 ); CPPUNIT_ASSERT ( RGB11.green == 0x29 );
CPPUNIT_ASSERT ( RGB11.blue == 0x30 ); CPPUNIT_ASSERT ( RGB11.blue == 0x30 );
@ -1957,7 +1957,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB12.red == 0xff ); CPPUNIT_ASSERT ( RGB12.red == 0xff );
CPPUNIT_ASSERT ( RGB12.green == 0x55 ); CPPUNIT_ASSERT ( RGB12.green == 0x55 );
CPPUNIT_ASSERT ( RGB12.blue == 0x55 ); CPPUNIT_ASSERT ( RGB12.blue == 0x55 );
linux.setPalette (index, 0x31, 0x32, 0x33); CPPUNIT_ASSERT ( linux.setPalette (index, 0x31, 0x32, 0x33) );
CPPUNIT_ASSERT ( RGB12.red == 0x31 ); CPPUNIT_ASSERT ( RGB12.red == 0x31 );
CPPUNIT_ASSERT ( RGB12.green == 0x32 ); CPPUNIT_ASSERT ( RGB12.green == 0x32 );
CPPUNIT_ASSERT ( RGB12.blue == 0x33 ); CPPUNIT_ASSERT ( RGB12.blue == 0x33 );
@ -1967,7 +1967,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB13.red == 0xff ); CPPUNIT_ASSERT ( RGB13.red == 0xff );
CPPUNIT_ASSERT ( RGB13.green == 0x55 ); CPPUNIT_ASSERT ( RGB13.green == 0x55 );
CPPUNIT_ASSERT ( RGB13.blue == 0xff ); CPPUNIT_ASSERT ( RGB13.blue == 0xff );
linux.setPalette (index, 0x34, 0x35, 0x36); CPPUNIT_ASSERT ( linux.setPalette (index, 0x34, 0x35, 0x36) );
CPPUNIT_ASSERT ( RGB13.red == 0x34 ); CPPUNIT_ASSERT ( RGB13.red == 0x34 );
CPPUNIT_ASSERT ( RGB13.green == 0x35 ); CPPUNIT_ASSERT ( RGB13.green == 0x35 );
CPPUNIT_ASSERT ( RGB13.blue == 0x36 ); CPPUNIT_ASSERT ( RGB13.blue == 0x36 );
@ -1977,7 +1977,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB14.red == 0xff ); CPPUNIT_ASSERT ( RGB14.red == 0xff );
CPPUNIT_ASSERT ( RGB14.green == 0xff ); CPPUNIT_ASSERT ( RGB14.green == 0xff );
CPPUNIT_ASSERT ( RGB14.blue == 0x55 ); CPPUNIT_ASSERT ( RGB14.blue == 0x55 );
linux.setPalette (index, 0x37, 0x38, 0x39); CPPUNIT_ASSERT ( linux.setPalette (index, 0x37, 0x38, 0x39) );
CPPUNIT_ASSERT ( RGB14.red == 0x37 ); CPPUNIT_ASSERT ( RGB14.red == 0x37 );
CPPUNIT_ASSERT ( RGB14.green == 0x38 ); CPPUNIT_ASSERT ( RGB14.green == 0x38 );
CPPUNIT_ASSERT ( RGB14.blue == 0x39 ); CPPUNIT_ASSERT ( RGB14.blue == 0x39 );
@ -1987,35 +1987,43 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( RGB15.red == 0xff ); CPPUNIT_ASSERT ( RGB15.red == 0xff );
CPPUNIT_ASSERT ( RGB15.green == 0xff ); CPPUNIT_ASSERT ( RGB15.green == 0xff );
CPPUNIT_ASSERT ( RGB15.blue == 0xff ); CPPUNIT_ASSERT ( RGB15.blue == 0xff );
linux.setPalette (index, 0x40, 0x41, 0x42); CPPUNIT_ASSERT ( linux.setPalette (index, 0x40, 0x41, 0x42) );
CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.red == 0x40 );
CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 );
CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 );
linux.setPalette (index, -1, 0, 0); // Out of range -> no change // Out of range -> no change
CPPUNIT_ASSERT ( linux.setPalette (index, -1, 0, 0) );
CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.red == 0x40 );
CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 );
CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 );
linux.setPalette (index, 0, -1, 0); // Out of range -> no change // Out of range -> no change
CPPUNIT_ASSERT ( linux.setPalette (index, 0, -1, 0) );
CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.red == 0x40 );
CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 );
CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 );
linux.setPalette (index, 0, 0, -1); // Out of range -> no change // Out of range -> no change
CPPUNIT_ASSERT ( linux.setPalette (index, 0, 0, -1) );
CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.red == 0x40 );
CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 );
CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 );
linux.setPalette (index, 256, 0, 0); // Out of range -> no change // Out of range -> no change
CPPUNIT_ASSERT ( linux.setPalette (index, 256, 0, 0) );
CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.red == 0x40 );
CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 );
CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 );
linux.setPalette (index, 0, 256, 0); // Out of range -> no change // Out of range -> no change
CPPUNIT_ASSERT ( linux.setPalette (index, 0, 256, 0) );
CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.red == 0x40 );
CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 );
CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 );
linux.setPalette (index, 0, 0, 256); // Out of range -> no change // Out of range -> no change
CPPUNIT_ASSERT ( linux.setPalette (index, 0, 0, 256) );
CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.red == 0x40 );
CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 );
CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 );
CPPUNIT_ASSERT ( linux.resetColorMap() == true );
closeConEmuStdStreams(); closeConEmuStdStreams();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }