Expanding the Unit Test for FTermLinux

This commit is contained in:
Markus Gans 2019-07-01 01:07:54 +02:00
parent 73293da481
commit 340d78e433
12 changed files with 860 additions and 224 deletions

View File

@ -1,3 +1,8 @@
2019-06-30 Markus Gans <guru.mail@muenster.de>
* Expanding the Unit Test for FTermLinux
* Update the cp437 unicode map
* Reducing the special cases for Solaris
2019-06-19 Markus Gans <guru.mail@muenster.de>
* Add a unit test for FTermLinux with a Linux console emulation
and a dedicated FSystem test instance

View File

@ -14,7 +14,6 @@ static struct unipair unicode_cp437_pairs[] =
// .----------- unicode
// | .---- fontpos
// | |
{0x0000, 0x00},
{0x0020, 0x20},
{0x0021, 0x21},
{0x0022, 0x22},
@ -114,65 +113,34 @@ static struct unipair unicode_cp437_pairs[] =
{0x00a1, 0xad},
{0x00a2, 0x9b},
{0x00a3, 0x9c},
{0x00a4, 0x0f},
{0x00a5, 0x9d},
{0x00a6, 0x7c},
{0x00a7, 0x15},
{0x00a8, 0x22},
{0x00a9, 0x43},
{0x00aa, 0xa6},
{0x00ab, 0xae},
{0x00ac, 0xaa},
{0x00ad, 0x2d},
{0x00ae, 0x52},
{0x00b0, 0xf8},
{0x00b1, 0xf1},
{0x00b2, 0xfd},
{0x00b4, 0x27},
{0x00b5, 0xe6},
{0x00b6, 0x14},
{0x00b7, 0xfa},
{0x00b8, 0x2c},
{0x00ba, 0xa7},
{0x00bb, 0xaf},
{0x00bc, 0xac},
{0x00bd, 0xab},
{0x00bf, 0xa8},
{0x00c0, 0x41},
{0x00c1, 0x41},
{0x00c2, 0x41},
{0x00c3, 0x41},
{0x00c4, 0x8e},
{0x00c5, 0x8f},
{0x00c6, 0x92},
{0x00c7, 0x80},
{0x00c8, 0x45},
{0x00c9, 0x90},
{0x00ca, 0x45},
{0x00cb, 0x45},
{0x00cc, 0x49},
{0x00cd, 0x49},
{0x00ce, 0x49},
{0x00cf, 0x49},
{0x00d0, 0x44},
{0x00d1, 0xa5},
{0x00d2, 0x4f},
{0x00d3, 0x4f},
{0x00d4, 0x4f},
{0x00d5, 0x4f},
{0x00d6, 0x99},
{0x00d7, 0x78},
{0x00d8, 0xe8},
{0x00d9, 0x55},
{0x00da, 0x55},
{0x00db, 0x55},
{0x00dc, 0x9a},
{0x00dd, 0x59},
{0x00df, 0xe1},
{0x00e0, 0x85},
{0x00e1, 0xa0},
{0x00e2, 0x83},
{0x00e3, 0x61},
{0x00e4, 0x84},
{0x00e5, 0x86},
{0x00e6, 0x91},
@ -185,20 +153,16 @@ static struct unipair unicode_cp437_pairs[] =
{0x00ed, 0xa1},
{0x00ee, 0x8c},
{0x00ef, 0x8b},
{0x00f0, 0xeb},
{0x00f1, 0xa4},
{0x00f2, 0x95},
{0x00f3, 0xa2},
{0x00f4, 0x93},
{0x00f5, 0x6f},
{0x00f6, 0x94},
{0x00f7, 0xf6},
{0x00f8, 0xed},
{0x00f9, 0x97},
{0x00fa, 0xa3},
{0x00fb, 0x96},
{0x00fc, 0x81},
{0x00fd, 0x79},
{0x00ff, 0x98},
{0x0192, 0x9f},
{0x0393, 0xe2},
@ -215,12 +179,23 @@ static struct unipair unicode_cp437_pairs[] =
{0x03c3, 0xe5},
{0x03c4, 0xe7},
{0x03c6, 0xed},
{0x2000, 0x20},
{0x2001, 0x20},
{0x2002, 0x20},
{0x2003, 0x20},
{0x2004, 0x20},
{0x2005, 0x20},
{0x2006, 0x20},
{0x2007, 0x20},
{0x2008, 0x20},
{0x2009, 0x20},
{0x200a, 0x20},
{0x2022, 0x07},
{0x202f, 0x20},
{0x203c, 0x13},
{0x207f, 0xfc},
{0x20a7, 0x9e},
{0x2126, 0xea},
{0x212a, 0x4b},
{0x212b, 0x8f},
{0x2190, 0x1b},
{0x2191, 0x18},
@ -229,7 +204,9 @@ static struct unipair unicode_cp437_pairs[] =
{0x2194, 0x1d},
{0x2195, 0x12},
{0x21a8, 0x17},
{0x2205, 0xed},
{0x2208, 0xee},
{0x220e, 0xfe},
{0x2219, 0xf9},
{0x221a, 0xfb},
{0x221e, 0xec},
@ -239,11 +216,13 @@ static struct unipair unicode_cp437_pairs[] =
{0x2261, 0xf0},
{0x2264, 0xf3},
{0x2265, 0xf2},
{0x22c5, 0xf9},
{0x2300, 0xed},
{0x2302, 0x7f},
{0x2310, 0xa9},
{0x2319, 0x1c},
{0x2320, 0xf4},
{0x2321, 0xf5},
{0x23bd, 0x5f},
{0x2500, 0xc4},
{0x2502, 0xb3},
{0x250c, 0xda},
@ -300,7 +279,6 @@ static struct unipair unicode_cp437_pairs[] =
{0x25bc, 0x1f},
{0x25c0, 0x11},
{0x25c4, 0x11},
{0x25c6, 0x04},
{0x25cb, 0x09},
{0x25d8, 0x08},
{0x25d9, 0x0a},
@ -315,8 +293,7 @@ static struct unipair unicode_cp437_pairs[] =
{0x2666, 0x04},
{0x266a, 0x0d},
{0x266b, 0x0e},
{0xf804, 0x5f},
{0xfffd, 0xfe}
{0x266c, 0x0e}
};
} // namespace fc

View File

@ -823,42 +823,27 @@ void FTerm::putstringf (const char format[], ...)
{
assert ( format != 0 );
char buf[512];
char* buffer;
char* str;
va_list args;
buffer = buf;
str = buf;
va_start (args, format);
vsnprintf (buffer, sizeof(buf), format, args);
vsnprintf (str, sizeof(buf), format, args);
va_end (args);
tputs (buffer, 1, FTerm::putchar_ASCII);
fsys->tputs (str, 1, FTerm::putchar_ASCII);
}
//----------------------------------------------------------------------
void FTerm::putstring (const char s[], int affcnt)
void FTerm::putstring (const char str[], int affcnt)
{
#if defined(__sun) && defined(__SVR4)
tputs (C_STR(s), affcnt, FTerm::putchar_ASCII);
#else
tputs (s, affcnt, FTerm::putchar_ASCII);
#endif
fsys->tputs (str, affcnt, FTerm::putchar_ASCII);
}
#if defined(__sun) && defined(__SVR4)
//----------------------------------------------------------------------
int FTerm::putchar_ASCII (char c)
{
if ( std::putchar(c) == EOF )
return 0;
else
return 1;
}
#endif // defined(__sun) && defined(__SVR4)
//----------------------------------------------------------------------
int FTerm::putchar_ASCII (int c)
{
if ( std::putchar(char(c)) == EOF )
if ( fsys->putchar(char(c)) == EOF )
return 0;
else
return 1;
@ -870,31 +855,31 @@ int FTerm::putchar_UTF8 (int c)
if ( c < 0x80 )
{
// 1 Byte (7-bit): 0xxxxxxx
std::putchar (c);
fsys->putchar (c);
return 1;
}
else if ( c < 0x800 )
{
// 2 byte (11-bit): 110xxxxx 10xxxxxx
std::putchar (0xc0 | (c >> 6) );
std::putchar (0x80 | (c & 0x3f) );
fsys->putchar (0xc0 | (c >> 6) );
fsys->putchar (0x80 | (c & 0x3f) );
return 2;
}
else if ( c < 0x10000 )
{
// 3 byte (16-bit): 1110xxxx 10xxxxxx 10xxxxxx
std::putchar (0xe0 | (c >> 12) );
std::putchar (0x80 | ((c >> 6) & 0x3f) );
std::putchar (0x80 | (c & 0x3f) );
fsys->putchar (0xe0 | (c >> 12) );
fsys->putchar (0x80 | ((c >> 6) & 0x3f) );
fsys->putchar (0x80 | (c & 0x3f) );
return 3;
}
else if ( c < 0x200000 )
{
// 4 byte (21-bit): 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
std::putchar (0xf0 | (c >> 18) );
std::putchar (0x80 | ((c >> 12) & 0x3f) );
std::putchar (0x80 | ((c >> 6) & 0x3f) );
std::putchar (0x80 | (c & 0x3f));
fsys->putchar (0xf0 | (c >> 18) );
fsys->putchar (0x80 | ((c >> 12) & 0x3f) );
fsys->putchar (0x80 | ((c >> 6) & 0x3f) );
fsys->putchar (0x80 | (c & 0x3f));
return 4;
}
else

View File

@ -86,6 +86,7 @@ char* FTermLinux::setCursorStyle ( fc::linuxConsoleCursorStyle style
// Set cursor style in linux console
static char buf[16] = { };
std::fill (std::begin(buf), std::end(buf), '\0');
if ( ! FTerm::isLinuxTerm() )
return buf;
@ -204,7 +205,7 @@ void FTermLinux::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS])
if ( new_font || vga_font )
return;
if ( screen_unicode_map.entry_ct != 0 )
if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries )
{
for (std::size_t i = 0; i <= fc::lastCharItem; i++ )
{
@ -318,7 +319,7 @@ bool FTermLinux::loadNewFont()
else
new_font = false;
if ( vga_font )
if ( new_font )
{
fterm_data->supportShadowCharacter (true);
fterm_data->supportHalfBlockCharacter (true);

View File

@ -41,6 +41,7 @@ const FString* FTermXTerminal::cursor_color = nullptr;
const FString* FTermXTerminal::mouse_foreground_color = nullptr;
const FString* FTermXTerminal::mouse_background_color = nullptr;
const FString* FTermXTerminal::highlight_background_color = nullptr;
FSystem* FTermXTerminal::fsystem = nullptr;
FTermDetection* FTermXTerminal::term_detection = nullptr;
fc::xtermCursorStyle FTermXTerminal::cursor_style = fc::unknown_cursor_style;
@ -57,6 +58,8 @@ FTermXTerminal::FTermXTerminal()
mouse_support = \
meta_sends_esc = \
xterm_default_colors = false;
// Get FSystem object
fsystem = FTerm::getFSystem();
}
//----------------------------------------------------------------------
@ -867,6 +870,9 @@ void FTermXTerminal::enableXTermMouse()
if ( mouse_support )
return;
if ( ! fsystem )
fsystem = FTerm::getFSystem();
FTerm::putstring (CSI "?1001s" // save old highlight mouse tracking
CSI "?1000h" // enable x11 mouse tracking
CSI "?1002h" // enable cell motion mouse tracking

View File

@ -50,6 +50,7 @@ uInt FVTerm::clr_eol_length;
uInt FVTerm::cursor_address_length;
std::queue<int>* FVTerm::output_buffer = nullptr;
FPoint* FVTerm::term_pos = nullptr;
FSystem* FVTerm::fsystem = nullptr;
FTerm* FVTerm::fterm = nullptr;
FVTerm::term_area* FVTerm::vterm = nullptr;
FVTerm::term_area* FVTerm::vdesktop = nullptr;
@ -1843,6 +1844,7 @@ void FVTerm::init (bool disable_alt_screen)
init_object = this;
vterm = nullptr;
vdesktop = nullptr;
fsystem = FTerm::getFSystem();
try
{
@ -2804,39 +2806,16 @@ inline void FVTerm::characterFilter (charData*& next_char)
//----------------------------------------------------------------------
inline void FVTerm::appendOutputBuffer (const std::string& s)
{
#if defined(__sun) && defined(__SVR4)
char* c_string = C_STR(s.c_str());
#else
const char* const& c_string = s.c_str();
#endif
tputs (c_string, 1, appendOutputBuffer);
fsystem->tputs (c_string, 1, appendOutputBuffer);
}
//----------------------------------------------------------------------
inline void FVTerm::appendOutputBuffer (const char s[])
{
#if defined(__sun) && defined(__SVR4)
tputs (C_STR(s), 1, appendOutputBuffer);
#else
tputs (s, 1, appendOutputBuffer);
#endif
fsystem->tputs (s, 1, appendOutputBuffer);
}
#if defined(__sun) && defined(__SVR4)
//----------------------------------------------------------------------
int FVTerm::appendOutputBuffer (char ch)
{
// This method is required by tputs under Solaris
output_buffer->push(ch);
if ( output_buffer->size() >= TERMINAL_OUTPUT_BUFFER_SIZE )
flush_out();
return ch;
}
#endif // defined(__sun) && defined(__SVR4)
//----------------------------------------------------------------------
int FVTerm::appendOutputBuffer (int ch)
{

View File

@ -65,6 +65,8 @@ class FSystem
virtual int close (int) = 0;
virtual FILE* fopen (const char*, const char*) = 0;
virtual int fclose (FILE*) = 0;
virtual int putchar (int) = 0;
virtual int tputs (const char*, int, int (*)(int)) = 0;
};
#pragma pack(pop)

View File

@ -41,6 +41,26 @@
#endif // defined(__x86_64__) || defined(__i386) || defined(__arm__)
#endif // defined(__linux__)
#if defined(__sun) && defined(__SVR4)
#include <termio.h>
typedef struct termio SGTTY;
typedef struct termios SGTTYS;
#ifdef _LP64
typedef unsigned int chtype;
#else
typedef unsigned long chtype;
#endif // _LP64
#include <term.h> // termcap
#else
#include <term.h> // termcap
#endif // defined(__sun) && defined(__SVR4)
#ifdef F_HAVE_LIBGPM
#undef buttons // from term.h
#endif
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
@ -72,27 +92,41 @@ class FSystemImpl : public FSystem
virtual ~FSystemImpl();
// Methods
#if defined(__linux__)
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
virtual uChar inPortByte (uShort port)
{
return ::inb (port);
}
#else
virtual uChar inPortByte (uShort)
{
return 0;
}
#endif
#else
virtual uChar inPortByte (uShort)
{
return 0;
}
#endif
#if defined(__linux__)
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
return ::inb (port);
#else
return 0;
#endif
#else
return 0;
#endif
}
virtual void outPortByte (uChar value, uShort port)
{
#if defined(__linux__)
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
::outb (value, port);
#endif
#endif
}
#else
virtual void outPortByte (uChar, uShort)
{ }
#endif
#else
virtual void outPortByte (uChar, uShort)
{ }
#endif
virtual int isTTY (int fd)
{
@ -133,6 +167,25 @@ class FSystemImpl : public FSystem
{
return std::fclose (fp);
}
virtual int putchar (int c)
{
#if defined(__sun) && defined(__SVR4)
return std::putchar(char(c));
#else
return std::putchar(c);
#endif
}
virtual int tputs (const char* str, int affcnt, int (*putc)(int))
{
#if defined(__sun) && defined(__SVR4)
return ::tputs (C_STR(str), affcnt, reinterpret_cast<int (*)(char)>(putc));
#else
return ::tputs (str, affcnt, putc);
#endif
}
};
#pragma pack(pop)

View File

@ -297,11 +297,6 @@ class FTerm final
#endif
;
static void putstring (const char[], int = 1);
#if defined(__sun) && defined(__SVR4)
static int putchar_ASCII (char);
#endif
static int putchar_ASCII (int);
static int putchar_UTF8 (int);

View File

@ -150,6 +150,7 @@ class FTermXTerminal final
static const FString* mouse_foreground_color;
static const FString* mouse_background_color;
static const FString* highlight_background_color;
static FSystem* fsystem;
static FTermDetection* term_detection;
static fc::xtermCursorStyle cursor_style;
};

View File

@ -134,6 +134,7 @@ class FVTerm
// Overloaded operators
template <typename typeT>
FVTerm& operator << (const typeT&);
FVTerm& operator << (fc::SpecialCharacter);
FVTerm& operator << (const std::string&);
FVTerm& operator << (const FTermBuffer&);
FVTerm& operator << (const std::vector<charData>&);
@ -468,13 +469,10 @@ class FVTerm
static void characterFilter (charData*&);
static void appendOutputBuffer (const std::string&);
static void appendOutputBuffer (const char[]);
#if defined(__sun) && defined(__SVR4)
static int appendOutputBuffer (char);
#endif
static int appendOutputBuffer (int);
// Data Members
static FSystem* fsystem;
static FTerm* fterm;
static std::queue<int>* output_buffer;
static charData term_attribute;
@ -552,6 +550,13 @@ inline FVTerm& FVTerm::operator << (const typeT& s)
return *this;
}
//----------------------------------------------------------------------
inline FVTerm& FVTerm::operator << (fc::SpecialCharacter c)
{
print (static_cast<wchar_t>(c)); // Required under Solaris
return *this;
}
//----------------------------------------------------------------------
inline FVTerm& FVTerm::operator << (const std::string& string)
{

File diff suppressed because it is too large Load Diff