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>
* Expanding the unit test for FTermLinux
* Update the cp437 unicode map

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -846,7 +846,7 @@ inline char* FTermDetection::secDA_Analysis_24 (char 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
&& 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;
}

View File

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

View File

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

View File

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

View File

@ -92,7 +92,7 @@ class FListViewItem : public FObject
FListViewItem& operator = (const FListViewItem&);
// Accessors
virtual const char* getClassName() const;
virtual const char* getClassName() const override;
uInt getColumnCount() const;
int getSortColumn() const;
FString getText (int) const;
@ -580,8 +580,15 @@ FObject::FObjectIterator
{
FStringList str_cols;
for (auto& col : list)
str_cols.push_back (FString() << col);
std::transform ( std::begin(list)
, 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);
return item_iter;
@ -609,8 +616,15 @@ FObject::FObjectIterator
{
FStringList str_cols;
for (auto& col : cols)
str_cols.push_back (FString() << col);
std::transform ( std::begin(cols)
, 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);
return item_iter;

View File

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

View File

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

View File

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

View File

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

View File

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