Move all termcap code into FTermcap
This commit is contained in:
parent
19239df5d1
commit
0b51df32b5
|
@ -1,3 +1,6 @@
|
||||||
|
2018-10-08 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Move all termcap code into FTermcap
|
||||||
|
|
||||||
2018-10-05 Markus Gans <guru.mail@muenster.de>
|
2018-10-05 Markus Gans <guru.mail@muenster.de>
|
||||||
* Remove redundant program code from FString
|
* Remove redundant program code from FString
|
||||||
|
|
||||||
|
|
|
@ -346,9 +346,7 @@ void FApplication::showParameterUsage()
|
||||||
<< " Do not send a ESC prefix for the alt/meta key" << std::endl
|
<< " Do not send a ESC prefix for the alt/meta key" << std::endl
|
||||||
<< " --no-cursorstyle-change"
|
<< " --no-cursorstyle-change"
|
||||||
<< " Do not change the current cursor style" << std::endl
|
<< " Do not change the current cursor style" << std::endl
|
||||||
#endif
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< "NetBSD/OpenBSD console options:" << std::endl
|
<< "NetBSD/OpenBSD console options:" << std::endl
|
||||||
<< " --no-esc-for-alt-meta "
|
<< " --no-esc-for-alt-meta "
|
||||||
|
@ -436,9 +434,7 @@ void FApplication::cmd_options (const int& argc, char* argv[])
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
{C_STR("no-esc-for-alt-meta"), no_argument, 0, 0 },
|
{C_STR("no-esc-for-alt-meta"), no_argument, 0, 0 },
|
||||||
{C_STR("no-cursorstyle-change"), no_argument, 0, 0 },
|
{C_STR("no-cursorstyle-change"), no_argument, 0, 0 },
|
||||||
#endif
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
{C_STR("no-esc-for-alt-meta"), no_argument, 0, 0 },
|
{C_STR("no-esc-for-alt-meta"), no_argument, 0, 0 },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -497,9 +493,7 @@ void FApplication::cmd_options (const int& argc, char* argv[])
|
||||||
|
|
||||||
if ( std::strcmp(long_options[idx].name, "no-cursorstyle-change") == 0 )
|
if ( std::strcmp(long_options[idx].name, "no-cursorstyle-change") == 0 )
|
||||||
init_values.change_cursorstyle = false;
|
init_values.change_cursorstyle = false;
|
||||||
#endif
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
|
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
|
||||||
init_values.meta_sends_escape = false;
|
init_values.meta_sends_escape = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -290,7 +290,7 @@ void FButton::hide()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(size) + 1];
|
blank = new char[std::size_t(size) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -298,7 +298,7 @@ void FButton::hide()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset(blank, ' ', uLong(size));
|
std::memset(blank, ' ', std::size_t(size));
|
||||||
blank[size] = '\0';
|
blank[size] = '\0';
|
||||||
|
|
||||||
for (int y = 0; y < getHeight() + s + (f << 1); y++)
|
for (int y = 0; y < getHeight() + s + (f << 1); y++)
|
||||||
|
@ -489,19 +489,19 @@ void FButton::getButtonState()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
uChar FButton::getHotkey()
|
uChar FButton::getHotkey()
|
||||||
{
|
{
|
||||||
int length;
|
uInt length;
|
||||||
|
|
||||||
if ( text.isEmpty() )
|
if ( text.isEmpty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
length = int(text.getLength());
|
length = text.getLength();
|
||||||
|
|
||||||
for (int i = 0; i < length; i++)
|
for (uInt i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( i + 1 < length && text[uInt(i)] == '&' )
|
if ( i + 1 < length && text[i] == '&' )
|
||||||
return uChar(text[uInt(++i)]);
|
return uChar(text[++i]);
|
||||||
}
|
}
|
||||||
catch (const std::out_of_range&)
|
catch (const std::out_of_range&)
|
||||||
{
|
{
|
||||||
|
@ -754,7 +754,7 @@ void FButton::draw()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
button_text = new wchar_t[uInt(txtlength) + 1]();
|
button_text = new wchar_t[std::size_t(txtlength) + 1]();
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -228,7 +228,7 @@ void FButtonGroup::hide()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(size) + 1];
|
blank = new char[std::size_t(size) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -236,7 +236,7 @@ void FButtonGroup::hide()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset(blank, ' ', uLong(size));
|
std::memset(blank, ' ', std::size_t(size));
|
||||||
blank[size] = '\0';
|
blank[size] = '\0';
|
||||||
|
|
||||||
for (int y = 0; y < getHeight(); y++)
|
for (int y = 0; y < getHeight(); y++)
|
||||||
|
|
|
@ -267,7 +267,7 @@ void FLabel::hide()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(size) + 1];
|
blank = new char[std::size_t(size) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -275,7 +275,7 @@ void FLabel::hide()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset(blank, ' ', uLong(size));
|
std::memset(blank, ' ', std::size_t(size));
|
||||||
blank[getWidth()] = '\0';
|
blank[getWidth()] = '\0';
|
||||||
setPrintPos (1,1);
|
setPrintPos (1,1);
|
||||||
print (blank);
|
print (blank);
|
||||||
|
|
|
@ -308,7 +308,7 @@ void FLineEdit::hide()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(size) + 1];
|
blank = new char[std::size_t(size) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -316,7 +316,7 @@ void FLineEdit::hide()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset(blank, ' ', uLong(size));
|
std::memset(blank, ' ', std::size_t(size));
|
||||||
blank[size] = '\0';
|
blank[size] = '\0';
|
||||||
|
|
||||||
for (int y = 0; y < getHeight() + s; y++)
|
for (int y = 0; y < getHeight() + s; y++)
|
||||||
|
|
|
@ -267,7 +267,7 @@ void FListBox::hide()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(size) + 1];
|
blank = new char[std::size_t(size) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -275,7 +275,7 @@ void FListBox::hide()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset (blank, ' ', uLong(size));
|
std::memset (blank, ' ', std::size_t(size));
|
||||||
blank[size] = '\0';
|
blank[size] = '\0';
|
||||||
|
|
||||||
for (int y = 0; y < getHeight(); y++)
|
for (int y = 0; y < getHeight(); y++)
|
||||||
|
@ -402,7 +402,7 @@ void FListBox::clear()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(size) + 1];
|
blank = new char[std::size_t(size) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -410,7 +410,7 @@ void FListBox::clear()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset (blank, ' ', uLong(size));
|
std::memset (blank, ' ', std::size_t(size));
|
||||||
blank[size] = '\0';
|
blank[size] = '\0';
|
||||||
|
|
||||||
for (int y = 0; y < getHeight() - 2; y++)
|
for (int y = 0; y < getHeight() - 2; y++)
|
||||||
|
|
|
@ -237,8 +237,9 @@ FString FListViewItem::getText (int column) const
|
||||||
|| column > int(column_list.size()) )
|
|| column > int(column_list.size()) )
|
||||||
return fc::emptyFString::get();
|
return fc::emptyFString::get();
|
||||||
|
|
||||||
column--; // Convert column position to address offset (index)
|
// Convert column position to address offset (index)
|
||||||
return column_list[uInt(column)];
|
std::size_t index = uInt(column - 1);
|
||||||
|
return column_list[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -263,23 +264,24 @@ void FListViewItem::setText (int column, const FString& text)
|
||||||
|| column > int(column_list.size()) )
|
|| column > int(column_list.size()) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Convert column position to address offset (index)
|
||||||
|
std::size_t index = uInt(column - 1);
|
||||||
FObject* parent = getParent();
|
FObject* parent = getParent();
|
||||||
column--; // Convert column position to address offset (index)
|
|
||||||
|
|
||||||
if ( parent && parent->isInstanceOf("FListView") )
|
if ( parent && parent->isInstanceOf("FListView") )
|
||||||
{
|
{
|
||||||
FListView* listview = static_cast<FListView*>(parent);
|
FListView* listview = static_cast<FListView*>(parent);
|
||||||
|
|
||||||
if ( ! listview->header[uInt(column)].fixed_width )
|
if ( ! listview->header[index].fixed_width )
|
||||||
{
|
{
|
||||||
int length = int(text.getLength());
|
int length = int(text.getLength());
|
||||||
|
|
||||||
if ( length > listview->header[uInt(column)].width )
|
if ( length > listview->header[index].width )
|
||||||
listview->header[uInt(column)].width = length;
|
listview->header[index].width = length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
column_list[uInt(column)] = text;
|
column_list[index] = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -346,15 +348,15 @@ void FListViewItem::sort (Compare cmp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Sort the top level
|
// Sort the top level
|
||||||
FObject::FObjectList& children_list = getChildren();
|
FObject::FObjectList& children = getChildren();
|
||||||
|
|
||||||
if ( ! children_list.empty() )
|
if ( ! children.empty() )
|
||||||
children_list.sort(cmp);
|
children.sort(cmp);
|
||||||
|
|
||||||
// Sort the sublevels
|
// Sort the sublevels
|
||||||
FListViewIterator iter = children_list.begin();
|
FListViewIterator iter = begin();
|
||||||
|
|
||||||
while ( iter != children_list.end() )
|
while ( iter != end() )
|
||||||
{
|
{
|
||||||
if ( *iter )
|
if ( *iter )
|
||||||
{
|
{
|
||||||
|
@ -652,8 +654,9 @@ fc::text_alignment FListView::getColumnAlignment (int column) const
|
||||||
if ( column < 1 || header.empty() || column > int(header.size()) )
|
if ( column < 1 || header.empty() || column > int(header.size()) )
|
||||||
return fc::alignLeft;
|
return fc::alignLeft;
|
||||||
|
|
||||||
column--; // Convert column position to address offset (index)
|
// Convert column position to address offset (index)
|
||||||
return header[uInt(column)].alignment;
|
std::size_t index = uInt(column - 1);
|
||||||
|
return header[index].alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -664,19 +667,20 @@ FString FListView::getColumnText (int column) const
|
||||||
if ( column < 1 || header.empty() || column > int(header.size()) )
|
if ( column < 1 || header.empty() || column > int(header.size()) )
|
||||||
return fc::emptyFString::get();
|
return fc::emptyFString::get();
|
||||||
|
|
||||||
column--; // Convert column position to address offset (index)
|
// Convert column position to address offset (index)
|
||||||
return header[uInt(column)].name;
|
std::size_t index = uInt(column - 1);
|
||||||
|
return header[index].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
fc::sorting_type FListView::getColumnSortType (int column) const
|
fc::sorting_type FListView::getColumnSortType (int column) const
|
||||||
{
|
{
|
||||||
fc::sorting_type type;
|
fc::sorting_type type;
|
||||||
std::size_t size = uInt(column);
|
std::size_t col = uInt(column);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
type = sort_type.at(size);
|
type = sort_type.at(col);
|
||||||
}
|
}
|
||||||
catch (const std::out_of_range&)
|
catch (const std::out_of_range&)
|
||||||
{
|
{
|
||||||
|
@ -713,8 +717,9 @@ void FListView::setColumnAlignment (int column, fc::text_alignment align)
|
||||||
if ( column < 1 || header.empty() || column > int(header.size()) )
|
if ( column < 1 || header.empty() || column > int(header.size()) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
column--; // Convert column position to address offset (index)
|
// Convert column position to address offset (index)
|
||||||
header[uInt(column)].alignment = align;
|
std::size_t index = uInt(column - 1);
|
||||||
|
header[index].alignment = align;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -725,17 +730,18 @@ void FListView::setColumnText (int column, const FString& label)
|
||||||
if ( column < 1 || header.empty() || column > int(header.size()) )
|
if ( column < 1 || header.empty() || column > int(header.size()) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
column--; // Convert column position to address offset (index)
|
// Convert column position to address offset (index)
|
||||||
|
std::size_t index = uInt(column - 1);
|
||||||
|
|
||||||
if ( ! header[uInt(column)].fixed_width )
|
if ( ! header[index].fixed_width )
|
||||||
{
|
{
|
||||||
int length = int(label.getLength());
|
int length = int(label.getLength());
|
||||||
|
|
||||||
if ( length > header[uInt(column)].width )
|
if ( length > header[index].width )
|
||||||
header[uInt(column)].width = length;
|
header[index].width = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
header[uInt(column)].name = label;
|
header[index].name = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -77,7 +77,7 @@ void FMenuBar::hide()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(screenWidth) + 1];
|
blank = new char[std::size_t(screenWidth) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -85,7 +85,7 @@ void FMenuBar::hide()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset(blank, ' ', uLong(screenWidth));
|
std::memset(blank, ' ', std::size_t(screenWidth));
|
||||||
blank[screenWidth] = '\0';
|
blank[screenWidth] = '\0';
|
||||||
setPrintPos (1,1);
|
setPrintPos (1,1);
|
||||||
print (blank);
|
print (blank);
|
||||||
|
|
|
@ -1487,13 +1487,11 @@ bool FMouseControl::isGpmMouseEnabled()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef F_HAVE_LIBGPM
|
#ifdef F_HAVE_LIBGPM
|
||||||
|
|
||||||
FMouse* mouse = mouse_protocol[FMouse::gpm];
|
FMouse* mouse = mouse_protocol[FMouse::gpm];
|
||||||
FMouseGPM* gpm_mouse = static_cast<FMouseGPM*>(mouse);
|
FMouseGPM* gpm_mouse = static_cast<FMouseGPM*>(mouse);
|
||||||
|
|
||||||
if ( gpm_mouse )
|
if ( gpm_mouse )
|
||||||
return gpm_mouse->isGpmMouseEnabled();
|
return gpm_mouse->isGpmMouseEnabled();
|
||||||
|
|
||||||
#endif // F_HAVE_LIBGPM
|
#endif // F_HAVE_LIBGPM
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -126,7 +126,7 @@ void FProgressbar::hide()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(size) + 1];
|
blank = new char[std::size_t(size) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -134,7 +134,7 @@ void FProgressbar::hide()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset(blank, ' ', uLong(size));
|
std::memset(blank, ' ', std::size_t(size));
|
||||||
blank[size] = '\0';
|
blank[size] = '\0';
|
||||||
|
|
||||||
for (int y = 0; y < getHeight() + s; y++)
|
for (int y = 0; y < getHeight() + s; y++)
|
||||||
|
|
|
@ -210,7 +210,7 @@ void FStatusBar::hide()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(screenWidth) + 1];
|
blank = new char[std::size_t(screenWidth) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -218,7 +218,7 @@ void FStatusBar::hide()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset(blank, ' ', uLong(screenWidth));
|
std::memset(blank, ' ', std::size_t(screenWidth));
|
||||||
blank[screenWidth] = '\0';
|
blank[screenWidth] = '\0';
|
||||||
setPrintPos (1, 1);
|
setPrintPos (1, 1);
|
||||||
print (blank);
|
print (blank);
|
||||||
|
|
|
@ -1750,7 +1750,7 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
c_string = new char[uInt(dest_size)]();
|
c_string = new char[std::size_t(dest_size)]();
|
||||||
|
|
||||||
// pre-initialiaze the whole string with '\0'
|
// pre-initialiaze the whole string with '\0'
|
||||||
std::memset (c_string, '\0', std::size_t(dest_size));
|
std::memset (c_string, '\0', std::size_t(dest_size));
|
||||||
|
@ -1761,7 +1761,7 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mblength = int(std::wcsrtombs (c_string, &src, uLong(dest_size), &state));
|
mblength = int(std::wcsrtombs (c_string, &src, std::size_t(dest_size), &state));
|
||||||
|
|
||||||
if ( mblength == -1 && errno != EILSEQ )
|
if ( mblength == -1 && errno != EILSEQ )
|
||||||
{
|
{
|
||||||
|
@ -1807,7 +1807,7 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dest = new wchar_t[uInt(size)]();
|
dest = new wchar_t[std::size_t(size)]();
|
||||||
// pre-initialiaze the whole string with '\0'
|
// pre-initialiaze the whole string with '\0'
|
||||||
std::wmemset (dest, L'\0', std::size_t(size));
|
std::wmemset (dest, L'\0', std::size_t(size));
|
||||||
}
|
}
|
||||||
|
@ -1817,7 +1817,7 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wclength = int(std::mbsrtowcs (dest, &src, uLong(dest_size), &state));
|
wclength = int(std::mbsrtowcs (dest, &src, std::size_t(dest_size), &state));
|
||||||
|
|
||||||
if ( wclength == -1 )
|
if ( wclength == -1 )
|
||||||
{
|
{
|
||||||
|
|
318
src/fterm.cpp
318
src/fterm.cpp
|
@ -53,13 +53,9 @@ FMouseControl* FTerm::mouse = 0;
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
FTermLinux* FTerm::linux = 0;
|
FTermLinux* FTerm::linux = 0;
|
||||||
#endif
|
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
FTermFreeBSD* FTerm::freebsd = 0;
|
FTermFreeBSD* FTerm::freebsd = 0;
|
||||||
#endif
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
FTermOpenBSD* FTerm::openbsd = 0;
|
FTermOpenBSD* FTerm::openbsd = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -840,9 +836,7 @@ void FTerm::initScreenSettings()
|
||||||
linux->initCharMap (fc::character);
|
linux->initCharMap (fc::character);
|
||||||
data->supportShadowCharacter (linux->hasShadowCharacter());
|
data->supportShadowCharacter (linux->hasShadowCharacter());
|
||||||
data->supportHalfBlockCharacter (linux->hasHalfBlockCharacter());
|
data->supportHalfBlockCharacter (linux->hasHalfBlockCharacter());
|
||||||
#endif
|
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
freebsd->initCharMap (fc::character);
|
freebsd->initCharMap (fc::character);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1091,269 +1085,32 @@ void FTerm::init_keyboard()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
/* Terminal capability data base
|
|
||||||
* -----------------------------
|
|
||||||
* Info under: man 5 terminfo
|
|
||||||
*
|
|
||||||
* Importent shell commands:
|
|
||||||
* captoinfo - convert all termcap descriptions into terminfo descriptions
|
|
||||||
* infocmp - print out terminfo description from the current terminal
|
|
||||||
*/
|
|
||||||
void FTerm::init_termcap()
|
void FTerm::init_termcap()
|
||||||
{
|
{
|
||||||
std::vector<std::string> terminals;
|
// Initialize the terminal capabilities
|
||||||
std::vector<std::string>::iterator iter;
|
|
||||||
static const int success = 1;
|
FTermcap termcap;
|
||||||
static const int uninitialized = -2;
|
termcap.setTermData(data);
|
||||||
static char term_buffer[2048];
|
termcap.setFTermDetection(term_detection);
|
||||||
static char string_buf[2048];
|
termcap.init();
|
||||||
char* buffer = string_buf;
|
|
||||||
int status = uninitialized;
|
|
||||||
bool color256 = term_detection->canDisplay256Colors();
|
|
||||||
|
|
||||||
// Share the terminal capabilities
|
// Share the terminal capabilities
|
||||||
tcap = FTermcap::getTermcapMap();
|
tcap = termcap.getTermcapMap();
|
||||||
|
|
||||||
// Open termcap file
|
|
||||||
const char* termtype = data->getTermType();
|
|
||||||
terminals.push_back(termtype); // available terminal type
|
|
||||||
|
|
||||||
if ( color256 ) // 1st fallback if not found
|
|
||||||
terminals.push_back("xterm-256color");
|
|
||||||
|
|
||||||
terminals.push_back("xterm"); // 2nd fallback if not found
|
|
||||||
terminals.push_back("ansi"); // 3rd fallback if not found
|
|
||||||
terminals.push_back("vt100"); // 4th fallback if not found
|
|
||||||
iter = terminals.begin();
|
|
||||||
|
|
||||||
while ( iter != terminals.end() )
|
|
||||||
{
|
|
||||||
data->setTermType(iter->c_str());
|
|
||||||
|
|
||||||
// Open the termcap file + load entry for termtype
|
|
||||||
status = tgetent(term_buffer, termtype);
|
|
||||||
|
|
||||||
if ( status == success || ! term_detection->hasTerminalDetection() )
|
|
||||||
break;
|
|
||||||
|
|
||||||
++iter;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "ansi", 4) == 0 )
|
|
||||||
term_detection->setAnsiTerminal (true);
|
|
||||||
|
|
||||||
init_termcap_error (status);
|
|
||||||
init_termcap_variables (buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTerm::init_termcap_error (int status)
|
void FTerm::init_quirks()
|
||||||
{
|
{
|
||||||
static const int no_entry = 0;
|
// Initialize terminal quirks
|
||||||
static const int db_not_found = -1;
|
|
||||||
static const int uninitialized = -2;
|
|
||||||
|
|
||||||
if ( status == no_entry || status == uninitialized )
|
|
||||||
{
|
|
||||||
const char* termtype = data->getTermType();
|
|
||||||
std::cerr << "Unknown terminal: " << termtype << "\n"
|
|
||||||
<< "Check the TERM environment variable\n"
|
|
||||||
<< "Also make sure that the terminal\n"
|
|
||||||
<< "is defined in the termcap/terminfo database.\n";
|
|
||||||
std::abort();
|
|
||||||
}
|
|
||||||
else if ( status == db_not_found )
|
|
||||||
{
|
|
||||||
std::cerr << "The termcap/terminfo database could not be found.\n";
|
|
||||||
std::abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void FTerm::init_termcap_variables (char*& buffer)
|
|
||||||
{
|
|
||||||
// Get termcap booleans
|
|
||||||
init_termcap_booleans();
|
|
||||||
|
|
||||||
// Get termcap numerics
|
|
||||||
init_termcap_numerics();
|
|
||||||
|
|
||||||
// Get termcap strings
|
|
||||||
init_termcap_strings(buffer);
|
|
||||||
|
|
||||||
// Terminal quirks
|
|
||||||
FTermcapQuirks quirks;
|
FTermcapQuirks quirks;
|
||||||
quirks.setTermData (data);
|
quirks.setTermData (data);
|
||||||
quirks.setFTermDetection (term_detection);
|
quirks.setFTermDetection (term_detection);
|
||||||
quirks.terminalFixup(); // Fix terminal quirks
|
quirks.terminalFixup(); // Fix terminal quirks
|
||||||
|
|
||||||
// Get termcap keys
|
|
||||||
init_termcap_keys(buffer);
|
|
||||||
|
|
||||||
// Initialize cursor movement optimization
|
|
||||||
init_OptiMove();
|
|
||||||
|
|
||||||
// Initialize video attributes optimization
|
|
||||||
init_OptiAttr();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTerm::init_termcap_booleans()
|
void FTerm::init_optiMove()
|
||||||
{
|
|
||||||
// Get termcap booleans
|
|
||||||
|
|
||||||
// Screen erased with the background color
|
|
||||||
FTermcap::background_color_erase = tgetflag(C_STR("ut"));
|
|
||||||
|
|
||||||
// t_cursor_left wraps from column 0 to last column
|
|
||||||
FTermcap::automatic_left_margin = tgetflag(C_STR("bw"));
|
|
||||||
|
|
||||||
// Terminal has auto-matic margins
|
|
||||||
FTermcap::automatic_right_margin = tgetflag(C_STR("am"));
|
|
||||||
|
|
||||||
// NewLine ignored after 80 cols
|
|
||||||
FTermcap::eat_nl_glitch = tgetflag(C_STR("xn"));
|
|
||||||
|
|
||||||
// Terminal supports ANSI set default fg and bg color
|
|
||||||
FTermcap::ansi_default_color = tgetflag(C_STR("AX"));
|
|
||||||
|
|
||||||
// Terminal supports operating system commands (OSC)
|
|
||||||
// OSC = Esc + ']'
|
|
||||||
FTermcap::osc_support = tgetflag(C_STR("XT"));
|
|
||||||
|
|
||||||
// U8 is nonzero for terminals with no VT100 line-drawing in UTF-8 mode
|
|
||||||
FTermcap::no_utf8_acs_chars = bool(tgetnum(C_STR("U8")) != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void FTerm::init_termcap_numerics()
|
|
||||||
{
|
|
||||||
// Get termcap numeric
|
|
||||||
|
|
||||||
// Maximum number of colors on screen
|
|
||||||
FTermcap::max_color = std::max( FTermcap::max_color
|
|
||||||
, tgetnum(C_STR("Co")) );
|
|
||||||
|
|
||||||
if ( getMaxColor() < 0 )
|
|
||||||
FTermcap::max_color = 1;
|
|
||||||
|
|
||||||
if ( getMaxColor() < 8 )
|
|
||||||
data->setMonochron(true);
|
|
||||||
else
|
|
||||||
data->setMonochron(false);
|
|
||||||
|
|
||||||
// Get initial spacing for hardware tab stop
|
|
||||||
FTermcap::tabstop = tgetnum(C_STR("it"));
|
|
||||||
|
|
||||||
// Get video attributes that cannot be used with colors
|
|
||||||
FTermcap::attr_without_color = tgetnum(C_STR("NC"));
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void FTerm::init_termcap_strings (char*& buffer)
|
|
||||||
{
|
|
||||||
// Get termcap strings
|
|
||||||
|
|
||||||
// Read termcap output strings
|
|
||||||
for (int i = 0; tcap[i].tname[0] != 0; i++)
|
|
||||||
tcap[i].string = tgetstr(tcap[i].tname, &buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void FTerm::init_termcap_keys_vt100 (char*& buffer)
|
|
||||||
{
|
|
||||||
// Some terminals (e.g. PuTTY) send vt100 key codes for
|
|
||||||
// the arrow and function keys.
|
|
||||||
|
|
||||||
char* key_up_string = tgetstr(C_STR("ku"), &buffer);
|
|
||||||
|
|
||||||
if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0))
|
|
||||||
|| ( TCAP(fc::t_cursor_up)
|
|
||||||
&& (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
|
|
||||||
{
|
|
||||||
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
|
|
||||||
{
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "kux", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(CSI "A"); // Key up
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "kdx", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(CSI "B"); // Key down
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "krx", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(CSI "C"); // Key right
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "klx", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(CSI "D"); // Key left
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "k1X", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(ESC "OP"); // PF1
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "k2X", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(ESC "OQ"); // PF2
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "k3X", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(ESC "OR"); // PF3
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "k4X", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(ESC "OS"); // PF4
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void FTerm::init_termcap_keys (char*& buffer)
|
|
||||||
{
|
|
||||||
// Read termcap key strings
|
|
||||||
|
|
||||||
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
|
|
||||||
{
|
|
||||||
fc::Fkey[i].string = tgetstr(fc::Fkey[i].tname, &buffer);
|
|
||||||
|
|
||||||
// Fallback for rxvt with TERM=xterm
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "khx", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(CSI "7~"); // Home key
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "@7x", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(CSI "8~"); // End key
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "k1x", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(CSI "11~"); // F1
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "k2x", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(CSI "12~"); // F2
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "k3x", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(CSI "13~"); // F3
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "k4x", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(CSI "14~"); // F4
|
|
||||||
|
|
||||||
// Fallback for TERM=ansi
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "@7X", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(CSI "K"); // End key
|
|
||||||
|
|
||||||
// Keypad keys
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "@8x", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(ESC "OM"); // Enter key
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "KP1", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(ESC "Oo"); // Keypad slash
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "KP2", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(ESC "Oj"); // Keypad asterisk
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "KP3", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(ESC "Om"); // Keypad minus sign
|
|
||||||
|
|
||||||
if ( std::strncmp(fc::Fkey[i].tname, "KP4", 3) == 0 )
|
|
||||||
fc::Fkey[i].string = C_STR(ESC "Ok"); // Keypad plus sign
|
|
||||||
}
|
|
||||||
|
|
||||||
// VT100 key codes for the arrow and function keys
|
|
||||||
init_termcap_keys_vt100(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void FTerm::init_OptiMove()
|
|
||||||
{
|
{
|
||||||
// Duration precalculation of the cursor movement strings
|
// Duration precalculation of the cursor movement strings
|
||||||
|
|
||||||
|
@ -1388,7 +1145,7 @@ void FTerm::init_OptiMove()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTerm::init_OptiAttr()
|
void FTerm::init_optiAttr()
|
||||||
{
|
{
|
||||||
// Setting video attribute optimization
|
// Setting video attribute optimization
|
||||||
|
|
||||||
|
@ -1719,9 +1476,7 @@ void FTerm::setInsertCursorStyle()
|
||||||
, data->isCursorHidden() );
|
, data->isCursorHidden() );
|
||||||
putstring (cstyle);
|
putstring (cstyle);
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
#endif
|
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
freebsd->setCursorStyle ( fc::destructive_cursor
|
freebsd->setCursorStyle ( fc::destructive_cursor
|
||||||
, data->isCursorHidden() );
|
, data->isCursorHidden() );
|
||||||
#endif
|
#endif
|
||||||
|
@ -1742,9 +1497,7 @@ void FTerm::setOverwriteCursorStyle()
|
||||||
, data->isCursorHidden() );
|
, data->isCursorHidden() );
|
||||||
putstring (cstyle);
|
putstring (cstyle);
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
#endif
|
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
freebsd->setCursorStyle ( fc::normal_cursor
|
freebsd->setCursorStyle ( fc::normal_cursor
|
||||||
, data->isCursorHidden() );
|
, data->isCursorHidden() );
|
||||||
#endif
|
#endif
|
||||||
|
@ -1846,13 +1599,9 @@ inline void FTerm::allocationValues()
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
linux = new FTermLinux();
|
linux = new FTermLinux();
|
||||||
#endif
|
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
freebsd = new FTermFreeBSD();
|
freebsd = new FTermFreeBSD();
|
||||||
#endif
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
openbsd = new FTermOpenBSD();
|
openbsd = new FTermOpenBSD();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1870,14 +1619,10 @@ inline void FTerm::deallocationValues()
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
if ( openbsd )
|
if ( openbsd )
|
||||||
delete openbsd;
|
delete openbsd;
|
||||||
#endif
|
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
if ( freebsd )
|
if ( freebsd )
|
||||||
delete freebsd;
|
delete freebsd;
|
||||||
#endif
|
#elif defined(__linux__)
|
||||||
|
|
||||||
#if defined(__linux__)
|
|
||||||
if ( linux )
|
if ( linux )
|
||||||
delete linux;
|
delete linux;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1943,6 +1688,17 @@ void FTerm::init (bool disable_alt_screen)
|
||||||
|
|
||||||
// Initializes variables for the current terminal
|
// Initializes variables for the current terminal
|
||||||
init_termcap();
|
init_termcap();
|
||||||
|
|
||||||
|
// Initialize terminal quirks
|
||||||
|
init_quirks();
|
||||||
|
|
||||||
|
// Initialize cursor movement optimization
|
||||||
|
init_optiMove();
|
||||||
|
|
||||||
|
// Initialize video attributes optimization
|
||||||
|
init_optiAttr();
|
||||||
|
|
||||||
|
// Initialize vt100 alternate character set
|
||||||
init_alt_charset();
|
init_alt_charset();
|
||||||
|
|
||||||
// Pass the terminal capabilities to the keyboard object
|
// Pass the terminal capabilities to the keyboard object
|
||||||
|
@ -2043,9 +1799,7 @@ void FTerm::initOSspecifics()
|
||||||
freebsd->disableChangeCursorStyle();
|
freebsd->disableChangeCursorStyle();
|
||||||
|
|
||||||
freebsd->init(); // Initialize BSD console
|
freebsd->init(); // Initialize BSD console
|
||||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__)
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
if ( init_values.meta_sends_escape )
|
if ( init_values.meta_sends_escape )
|
||||||
openbsd->enableMetaSendsEscape();
|
openbsd->enableMetaSendsEscape();
|
||||||
else
|
else
|
||||||
|
@ -2150,13 +1904,9 @@ void FTerm::finishOSspecifics1()
|
||||||
{
|
{
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
linux->finish();
|
linux->finish();
|
||||||
#endif
|
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
freebsd->finish();
|
freebsd->finish();
|
||||||
#endif
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
openbsd->finish();
|
openbsd->finish();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
272
src/ftermcap.cpp
272
src/ftermcap.cpp
|
@ -36,6 +36,8 @@ bool FTermcap::no_utf8_acs_chars = false;
|
||||||
int FTermcap::max_color = 1;
|
int FTermcap::max_color = 1;
|
||||||
int FTermcap::tabstop = 8;
|
int FTermcap::tabstop = 8;
|
||||||
int FTermcap::attr_without_color = 0;
|
int FTermcap::attr_without_color = 0;
|
||||||
|
FTermData* FTermcap::fterm_data = 0;
|
||||||
|
FTermDetection* FTermcap::term_detection = 0;
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -51,6 +53,276 @@ FTermcap::FTermcap()
|
||||||
FTermcap::~FTermcap() // destructor
|
FTermcap::~FTermcap() // destructor
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
/* Terminal capability data base
|
||||||
|
* -----------------------------
|
||||||
|
* Info under: man 5 terminfo
|
||||||
|
*
|
||||||
|
* Importent shell commands:
|
||||||
|
* captoinfo - convert all termcap descriptions into terminfo descriptions
|
||||||
|
* infocmp - print out terminfo description from the current terminal
|
||||||
|
*/
|
||||||
|
|
||||||
|
// public methods of FTermcap
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermcap::setTermData (FTermData* data)
|
||||||
|
{
|
||||||
|
fterm_data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermcap::setFTermDetection (FTermDetection* td)
|
||||||
|
{
|
||||||
|
term_detection = td;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermcap::init()
|
||||||
|
{
|
||||||
|
termcap();
|
||||||
|
}
|
||||||
|
|
||||||
|
// private methods of FTermcap
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermcap::termcap()
|
||||||
|
{
|
||||||
|
std::vector<std::string> terminals;
|
||||||
|
std::vector<std::string>::iterator iter;
|
||||||
|
static const int success = 1;
|
||||||
|
static const int uninitialized = -2;
|
||||||
|
static char term_buffer[2048];
|
||||||
|
static char string_buf[2048];
|
||||||
|
char* buffer = string_buf;
|
||||||
|
int status = uninitialized;
|
||||||
|
bool color256 = term_detection->canDisplay256Colors();
|
||||||
|
|
||||||
|
// Open termcap file
|
||||||
|
const char* termtype = fterm_data->getTermType();
|
||||||
|
terminals.push_back(termtype); // available terminal type
|
||||||
|
|
||||||
|
if ( color256 ) // 1st fallback if not found
|
||||||
|
terminals.push_back("xterm-256color");
|
||||||
|
|
||||||
|
terminals.push_back("xterm"); // 2nd fallback if not found
|
||||||
|
terminals.push_back("ansi"); // 3rd fallback if not found
|
||||||
|
terminals.push_back("vt100"); // 4th fallback if not found
|
||||||
|
iter = terminals.begin();
|
||||||
|
|
||||||
|
while ( iter != terminals.end() )
|
||||||
|
{
|
||||||
|
fterm_data->setTermType(iter->c_str());
|
||||||
|
|
||||||
|
// Open the termcap file + load entry for termtype
|
||||||
|
status = tgetent(term_buffer, termtype);
|
||||||
|
|
||||||
|
if ( status == success || ! term_detection->hasTerminalDetection() )
|
||||||
|
break;
|
||||||
|
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( std::strncmp(termtype, "ansi", 4) == 0 )
|
||||||
|
term_detection->setAnsiTerminal (true);
|
||||||
|
|
||||||
|
termcapError (status);
|
||||||
|
termcapVariables (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermcap::termcapError (int status)
|
||||||
|
{
|
||||||
|
static const int no_entry = 0;
|
||||||
|
static const int db_not_found = -1;
|
||||||
|
static const int uninitialized = -2;
|
||||||
|
|
||||||
|
if ( status == no_entry || status == uninitialized )
|
||||||
|
{
|
||||||
|
const char* termtype = fterm_data->getTermType();
|
||||||
|
std::cerr << "Unknown terminal: " << termtype << "\n"
|
||||||
|
<< "Check the TERM environment variable\n"
|
||||||
|
<< "Also make sure that the terminal\n"
|
||||||
|
<< "is defined in the termcap/terminfo database.\n";
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
else if ( status == db_not_found )
|
||||||
|
{
|
||||||
|
std::cerr << "The termcap/terminfo database could not be found.\n";
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermcap::termcapVariables (char*& buffer)
|
||||||
|
{
|
||||||
|
// Get termcap booleans
|
||||||
|
termcapBoleans();
|
||||||
|
|
||||||
|
// Get termcap numerics
|
||||||
|
termcapNumerics();
|
||||||
|
|
||||||
|
// Get termcap strings
|
||||||
|
termcapStrings (buffer);
|
||||||
|
|
||||||
|
// Get termcap keys
|
||||||
|
termcapKeys (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermcap::termcapBoleans()
|
||||||
|
{
|
||||||
|
// Get termcap booleans
|
||||||
|
|
||||||
|
// Screen erased with the background color
|
||||||
|
background_color_erase = tgetflag(C_STR("ut"));
|
||||||
|
|
||||||
|
// t_cursor_left wraps from column 0 to last column
|
||||||
|
automatic_left_margin = tgetflag(C_STR("bw"));
|
||||||
|
|
||||||
|
// Terminal has auto-matic margins
|
||||||
|
automatic_right_margin = tgetflag(C_STR("am"));
|
||||||
|
|
||||||
|
// NewLine ignored after 80 cols
|
||||||
|
eat_nl_glitch = tgetflag(C_STR("xn"));
|
||||||
|
|
||||||
|
// Terminal supports ANSI set default fg and bg color
|
||||||
|
ansi_default_color = tgetflag(C_STR("AX"));
|
||||||
|
|
||||||
|
// Terminal supports operating system commands (OSC)
|
||||||
|
// OSC = Esc + ']'
|
||||||
|
osc_support = tgetflag(C_STR("XT"));
|
||||||
|
|
||||||
|
// U8 is nonzero for terminals with no VT100 line-drawing in UTF-8 mode
|
||||||
|
no_utf8_acs_chars = bool(tgetnum(C_STR("U8")) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermcap::termcapNumerics()
|
||||||
|
{
|
||||||
|
// Get termcap numeric
|
||||||
|
|
||||||
|
// Maximum number of colors on screen
|
||||||
|
max_color = std::max(max_color, tgetnum(C_STR("Co")));
|
||||||
|
|
||||||
|
if ( max_color < 0 )
|
||||||
|
max_color = 1;
|
||||||
|
|
||||||
|
if ( max_color < 8 )
|
||||||
|
fterm_data->setMonochron(true);
|
||||||
|
else
|
||||||
|
fterm_data->setMonochron(false);
|
||||||
|
|
||||||
|
// Get initial spacing for hardware tab stop
|
||||||
|
tabstop = tgetnum(C_STR("it"));
|
||||||
|
|
||||||
|
// Get video attributes that cannot be used with colors
|
||||||
|
attr_without_color = tgetnum(C_STR("NC"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermcap::termcapStrings (char*& buffer)
|
||||||
|
{
|
||||||
|
// Get termcap strings
|
||||||
|
|
||||||
|
// Read termcap output strings
|
||||||
|
for (int i = 0; tcap[i].tname[0] != 0; i++)
|
||||||
|
tcap[i].string = tgetstr(tcap[i].tname, &buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermcap::termcapKeys (char*& buffer)
|
||||||
|
{
|
||||||
|
// Read termcap key strings
|
||||||
|
|
||||||
|
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
|
||||||
|
{
|
||||||
|
fc::Fkey[i].string = tgetstr(fc::Fkey[i].tname, &buffer);
|
||||||
|
|
||||||
|
// Fallback for rxvt with TERM=xterm
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "khx", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(CSI "7~"); // Home key
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "@7x", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(CSI "8~"); // End key
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "k1x", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(CSI "11~"); // F1
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "k2x", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(CSI "12~"); // F2
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "k3x", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(CSI "13~"); // F3
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "k4x", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(CSI "14~"); // F4
|
||||||
|
|
||||||
|
// Fallback for TERM=ansi
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "@7X", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(CSI "K"); // End key
|
||||||
|
|
||||||
|
// Keypad keys
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "@8x", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(ESC "OM"); // Enter key
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "KP1", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(ESC "Oo"); // Keypad slash
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "KP2", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(ESC "Oj"); // Keypad asterisk
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "KP3", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(ESC "Om"); // Keypad minus sign
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "KP4", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(ESC "Ok"); // Keypad plus sign
|
||||||
|
}
|
||||||
|
|
||||||
|
// VT100 key codes for the arrow and function keys
|
||||||
|
termcapKeysVt100 (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FTermcap::termcapKeysVt100 (char*& buffer)
|
||||||
|
{
|
||||||
|
// Some terminals (e.g. PuTTY) send vt100 key codes for
|
||||||
|
// the arrow and function keys.
|
||||||
|
|
||||||
|
char* key_up_string = tgetstr(C_STR("ku"), &buffer);
|
||||||
|
|
||||||
|
if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0))
|
||||||
|
|| ( TCAP(fc::t_cursor_up)
|
||||||
|
&& (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
|
||||||
|
{
|
||||||
|
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
|
||||||
|
{
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "kux", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(CSI "A"); // Key up
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "kdx", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(CSI "B"); // Key down
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "krx", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(CSI "C"); // Key right
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "klx", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(CSI "D"); // Key left
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "k1X", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(ESC "OP"); // PF1
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "k2X", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(ESC "OQ"); // PF2
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "k3X", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(ESC "OR"); // PF3
|
||||||
|
|
||||||
|
if ( std::strncmp(fc::Fkey[i].tname, "k4X", 3) == 0 )
|
||||||
|
fc::Fkey[i].string = C_STR(ESC "OS"); // PF4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// private Data Member of FTermcap - termcap capabilities
|
// private Data Member of FTermcap - termcap capabilities
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -69,54 +69,54 @@ void FTermcapQuirks::terminalFixup()
|
||||||
|
|
||||||
if ( td->isCygwinTerminal() )
|
if ( td->isCygwinTerminal() )
|
||||||
{
|
{
|
||||||
init_termcap_cygwin_quirks();
|
cygwin();
|
||||||
}
|
}
|
||||||
else if ( td->isLinuxTerm() )
|
else if ( td->isLinuxTerm() )
|
||||||
{
|
{
|
||||||
init_termcap_linux_quirks();
|
linux();
|
||||||
}
|
}
|
||||||
else if ( td->isRxvtTerminal() )
|
else if ( td->isRxvtTerminal() )
|
||||||
{
|
{
|
||||||
init_termcap_rxvt_quirks();
|
rxvt();
|
||||||
}
|
}
|
||||||
else if ( td->isGnomeTerminal() )
|
else if ( td->isGnomeTerminal() )
|
||||||
{
|
{
|
||||||
init_termcap_vte_quirks();
|
vte();
|
||||||
}
|
}
|
||||||
else if ( td->isTeraTerm() )
|
else if ( td->isTeraTerm() )
|
||||||
{
|
{
|
||||||
init_termcap_teraterm_quirks();
|
teraterm();
|
||||||
}
|
}
|
||||||
else if ( td->isSunTerminal() )
|
else if ( td->isSunTerminal() )
|
||||||
{
|
{
|
||||||
init_termcap_sun_quirks();
|
sun();
|
||||||
}
|
}
|
||||||
else if ( td->isPuttyTerminal() )
|
else if ( td->isPuttyTerminal() )
|
||||||
{
|
{
|
||||||
init_termcap_putty_quirks();
|
putty();
|
||||||
}
|
}
|
||||||
else if ( td->isScreenTerm() )
|
else if ( td->isScreenTerm() )
|
||||||
{
|
{
|
||||||
init_termcap_screen_quirks();
|
screen();
|
||||||
}
|
}
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
else if ( td->isFreeBSDTerm() )
|
else if ( td->isFreeBSDTerm() )
|
||||||
{
|
{
|
||||||
init_termcap_freebsd_quirks();
|
freebsd();
|
||||||
}
|
}
|
||||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__)
|
#endif // defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
|
||||||
// xterm and compatible terminals
|
// xterm and compatible terminals
|
||||||
if ( td->isXTerminal() && ! td->isPuttyTerminal() )
|
if ( td->isXTerminal() && ! td->isPuttyTerminal() )
|
||||||
init_termcap_xterm_quirks();
|
xterm();
|
||||||
|
|
||||||
// Fixes general quirks
|
// Fixes general quirks
|
||||||
init_termcap_general_quirks();
|
general();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::init_termcap_freebsd_quirks()
|
void FTermcapQuirks::freebsd()
|
||||||
{
|
{
|
||||||
// FreeBSD console fixes
|
// FreeBSD console fixes
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ void FTermcapQuirks::init_termcap_freebsd_quirks()
|
||||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__)
|
#endif // defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::init_termcap_cygwin_quirks()
|
void FTermcapQuirks::cygwin()
|
||||||
{
|
{
|
||||||
// Set invisible cursor for cygwin terminal
|
// Set invisible cursor for cygwin terminal
|
||||||
if ( ! TCAP(fc::t_cursor_invisible) )
|
if ( ! TCAP(fc::t_cursor_invisible) )
|
||||||
|
@ -168,11 +168,11 @@ void FTermcapQuirks::init_termcap_cygwin_quirks()
|
||||||
FTermcap::background_color_erase = true;
|
FTermcap::background_color_erase = true;
|
||||||
|
|
||||||
// Include the Linux console quirks
|
// Include the Linux console quirks
|
||||||
init_termcap_linux_quirks();
|
linux();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::init_termcap_linux_quirks()
|
void FTermcapQuirks::linux()
|
||||||
{
|
{
|
||||||
/* Same settings are used by cygwin */
|
/* Same settings are used by cygwin */
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ void FTermcapQuirks::init_termcap_linux_quirks()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::init_termcap_xterm_quirks()
|
void FTermcapQuirks::xterm()
|
||||||
{
|
{
|
||||||
// Fallback if "Ic" is not found
|
// Fallback if "Ic" is not found
|
||||||
if ( ! TCAP(fc::t_initialize_color) )
|
if ( ! TCAP(fc::t_initialize_color) )
|
||||||
|
@ -247,7 +247,7 @@ void FTermcapQuirks::init_termcap_xterm_quirks()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::init_termcap_rxvt_quirks()
|
void FTermcapQuirks::rxvt()
|
||||||
{
|
{
|
||||||
// Set enter/exit alternative charset mode for rxvt terminal
|
// Set enter/exit alternative charset mode for rxvt terminal
|
||||||
const char* termtype = fterm_data->getTermType();
|
const char* termtype = fterm_data->getTermType();
|
||||||
|
@ -271,7 +271,7 @@ void FTermcapQuirks::init_termcap_rxvt_quirks()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::init_termcap_vte_quirks()
|
void FTermcapQuirks::vte()
|
||||||
{
|
{
|
||||||
// gnome-terminal has NC=16 however, it can use the dim attribute
|
// gnome-terminal has NC=16 however, it can use the dim attribute
|
||||||
FTermcap::attr_without_color = 0;
|
FTermcap::attr_without_color = 0;
|
||||||
|
@ -282,7 +282,7 @@ void FTermcapQuirks::init_termcap_vte_quirks()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::init_termcap_putty_quirks()
|
void FTermcapQuirks::putty()
|
||||||
{
|
{
|
||||||
FTermcap::background_color_erase = true;
|
FTermcap::background_color_erase = true;
|
||||||
FTermcap::osc_support = true;
|
FTermcap::osc_support = true;
|
||||||
|
@ -368,7 +368,7 @@ void FTermcapQuirks::init_termcap_putty_quirks()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::init_termcap_teraterm_quirks()
|
void FTermcapQuirks::teraterm()
|
||||||
{
|
{
|
||||||
// Tera Term eat_nl_glitch fix
|
// Tera Term eat_nl_glitch fix
|
||||||
FTermcap::eat_nl_glitch = true;
|
FTermcap::eat_nl_glitch = true;
|
||||||
|
@ -385,14 +385,14 @@ void FTermcapQuirks::init_termcap_teraterm_quirks()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::init_termcap_sun_quirks()
|
void FTermcapQuirks::sun()
|
||||||
{
|
{
|
||||||
// Sun Microsystems workstation console eat_nl_glitch fix
|
// Sun Microsystems workstation console eat_nl_glitch fix
|
||||||
FTermcap::eat_nl_glitch = true;
|
FTermcap::eat_nl_glitch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::init_termcap_screen_quirks()
|
void FTermcapQuirks::screen()
|
||||||
{
|
{
|
||||||
// Fallback if "Ic" is not found
|
// Fallback if "Ic" is not found
|
||||||
if ( ! TCAP(fc::t_initialize_color) )
|
if ( ! TCAP(fc::t_initialize_color) )
|
||||||
|
@ -417,7 +417,7 @@ void FTermcapQuirks::init_termcap_screen_quirks()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::init_termcap_general_quirks()
|
void FTermcapQuirks::general()
|
||||||
{
|
{
|
||||||
static const int not_available = -1;
|
static const int not_available = -1;
|
||||||
|
|
||||||
|
|
|
@ -589,7 +589,7 @@ bool FTermLinux::getUnicodeMap()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
screen_unicode_map.entries = new struct unipair[uInt(count)]();
|
screen_unicode_map.entries = new struct unipair[std::size_t(count)]();
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -220,7 +220,7 @@ void FTextView::hide()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(size) + 1];
|
blank = new char[std::size_t(size) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -228,7 +228,7 @@ void FTextView::hide()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset(blank, ' ', uLong(size));
|
std::memset(blank, ' ', std::size_t(size));
|
||||||
blank[size] = '\0';
|
blank[size] = '\0';
|
||||||
|
|
||||||
for (int y = 0; y < getHeight(); y++)
|
for (int y = 0; y < getHeight(); y++)
|
||||||
|
@ -355,7 +355,7 @@ void FTextView::clear()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(size) + 1];
|
blank = new char[std::size_t(size) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -363,7 +363,7 @@ void FTextView::clear()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset(blank, ' ', uLong(size));
|
std::memset(blank, ' ', std::size_t(size));
|
||||||
blank[size] = '\0';
|
blank[size] = '\0';
|
||||||
|
|
||||||
for (int y = 0; y < getTextHeight(); y++)
|
for (int y = 0; y < getTextHeight(); y++)
|
||||||
|
|
|
@ -243,7 +243,7 @@ void FToggleButton::hide()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blank = new char[uInt(size) + 1];
|
blank = new char[std::size_t(size) + 1];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -251,7 +251,7 @@ void FToggleButton::hide()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset(blank, ' ', uLong(size));
|
std::memset(blank, ' ', std::size_t(size));
|
||||||
blank[size] = '\0';
|
blank[size] = '\0';
|
||||||
setPrintPos (1, 1);
|
setPrintPos (1, 1);
|
||||||
print (blank);
|
print (blank);
|
||||||
|
|
|
@ -653,7 +653,7 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
|
||||||
assert ( height > 0 );
|
assert ( height > 0 );
|
||||||
assert ( rsw >= 0 );
|
assert ( rsw >= 0 );
|
||||||
assert ( bsh >= 0 );
|
assert ( bsh >= 0 );
|
||||||
int area_size;
|
std::size_t area_size;
|
||||||
bool realloc_success = false;
|
bool realloc_success = false;
|
||||||
|
|
||||||
if ( ! area )
|
if ( ! area )
|
||||||
|
@ -673,11 +673,13 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
area_size = (width + rsw) * (height + bsh);
|
area_size = std::size_t((width + rsw) * (height + bsh));
|
||||||
|
|
||||||
if ( area->height + area->bottom_shadow != height + bsh )
|
if ( area->height + area->bottom_shadow != height + bsh )
|
||||||
{
|
{
|
||||||
realloc_success = reallocateTextArea (area, height + bsh, area_size);
|
realloc_success = reallocateTextArea ( area
|
||||||
|
, std::size_t(height + bsh)
|
||||||
|
, area_size );
|
||||||
}
|
}
|
||||||
else if ( area->width + area->right_shadow != width + rsw )
|
else if ( area->width + area->right_shadow != width + rsw )
|
||||||
{
|
{
|
||||||
|
@ -727,12 +729,9 @@ inline void FVTerm::setTextToDefault ( term_area* area
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FVTerm::reallocateTextArea ( term_area* area
|
inline bool FVTerm::reallocateTextArea ( term_area* area
|
||||||
, int height
|
, std::size_t height
|
||||||
, int size )
|
, std::size_t size )
|
||||||
{
|
{
|
||||||
assert ( height > 0 );
|
|
||||||
assert ( size > 0 );
|
|
||||||
|
|
||||||
if ( area->changes != 0 )
|
if ( area->changes != 0 )
|
||||||
delete[] area->changes;
|
delete[] area->changes;
|
||||||
|
|
||||||
|
@ -741,8 +740,8 @@ inline bool FVTerm::reallocateTextArea ( term_area* area
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
area->changes = new line_changes[uInt(height)];
|
area->changes = new line_changes[height];
|
||||||
area->text = new charData[uInt(size)];
|
area->text = new charData[size];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
@ -754,16 +753,14 @@ inline bool FVTerm::reallocateTextArea ( term_area* area
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FVTerm::reallocateTextArea (term_area* area, int size)
|
inline bool FVTerm::reallocateTextArea (term_area* area, std::size_t size)
|
||||||
{
|
{
|
||||||
assert ( size > 0 );
|
|
||||||
|
|
||||||
if ( area->text != 0 )
|
if ( area->text != 0 )
|
||||||
delete[] area->text;
|
delete[] area->text;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
area->text = new charData[uInt(size)];
|
area->text = new charData[size];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc& ex)
|
catch (const std::bad_alloc& ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,7 +73,6 @@
|
||||||
|
|
||||||
#ifdef F_HAVE_LIBGPM
|
#ifdef F_HAVE_LIBGPM
|
||||||
#include <gpm.h>
|
#include <gpm.h>
|
||||||
#undef buttons // from term.h
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
|
|
|
@ -103,26 +103,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#if F_HAVE_GETTTYNAM && F_HAVE_TTYENT_H
|
#if F_HAVE_GETTTYNAM && F_HAVE_TTYENT_H
|
||||||
#include <ttyent.h>
|
#include <ttyent.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -151,13 +131,9 @@
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
#include "final/ftermlinux.h"
|
#include "final/ftermlinux.h"
|
||||||
#endif
|
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
#include "final/ftermfreebsd.h"
|
#include "final/ftermfreebsd.h"
|
||||||
#endif
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
#include "final/ftermopenbsd.h"
|
#include "final/ftermopenbsd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -336,9 +312,7 @@ class FTerm
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
meta_sends_escape = true;
|
meta_sends_escape = true;
|
||||||
change_cursorstyle = true;
|
change_cursorstyle = true;
|
||||||
#endif
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
meta_sends_escape = true;
|
meta_sends_escape = true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -356,9 +330,7 @@ class FTerm
|
||||||
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
|
||||||
#endif
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
uInt8 meta_sends_escape : 1;
|
uInt8 meta_sends_escape : 1;
|
||||||
uInt8 : 7; // padding bits
|
uInt8 : 7; // padding bits
|
||||||
#endif
|
#endif
|
||||||
|
@ -382,15 +354,9 @@ class FTerm
|
||||||
static void init_fixed_max_color();
|
static void init_fixed_max_color();
|
||||||
static void init_keyboard();
|
static void init_keyboard();
|
||||||
static void init_termcap();
|
static void init_termcap();
|
||||||
static void init_termcap_error (int);
|
static void init_quirks();
|
||||||
static void init_termcap_variables(char*&);
|
static void init_optiMove();
|
||||||
static void init_termcap_booleans();
|
static void init_optiAttr();
|
||||||
static void init_termcap_numerics();
|
|
||||||
static void init_termcap_strings (char*&);
|
|
||||||
static void init_termcap_keys_vt100 (char*&);
|
|
||||||
static void init_termcap_keys (char*&);
|
|
||||||
static void init_OptiMove();
|
|
||||||
static void init_OptiAttr();
|
|
||||||
static void init_font();
|
static void init_font();
|
||||||
static void init_locale();
|
static void init_locale();
|
||||||
static void init_encoding();
|
static void init_encoding();
|
||||||
|
@ -435,13 +401,9 @@ class FTerm
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
#undef linux
|
#undef linux
|
||||||
static FTermLinux* linux;
|
static FTermLinux* linux;
|
||||||
#endif
|
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
static FTermFreeBSD* freebsd;
|
static FTermFreeBSD* freebsd;
|
||||||
#endif
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
static FTermOpenBSD* openbsd;
|
static FTermOpenBSD* openbsd;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,10 +35,36 @@
|
||||||
#error "Only <final/final.h> can be included directly."
|
#error "Only <final/final.h> can be included directly."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FTermcap string macro
|
#if defined(__sun) && defined(__SVR4)
|
||||||
#define TCAP(s) tcap[(s)].string
|
#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 <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "final/emptyfstring.h"
|
||||||
|
#include "final/fkey_map.h"
|
||||||
|
#include "final/ftermdetection.h"
|
||||||
|
|
||||||
|
|
||||||
|
// FTermcap string macro
|
||||||
|
#define TCAP(s) tcap[(s)].string
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
{
|
{
|
||||||
|
@ -74,6 +100,13 @@ class FTermcap
|
||||||
return tcap;
|
return tcap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mutator
|
||||||
|
static void setTermData (FTermData*);
|
||||||
|
static void setFTermDetection (FTermDetection*);
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
static void init();
|
||||||
|
|
||||||
// Data Members
|
// Data Members
|
||||||
static bool background_color_erase;
|
static bool background_color_erase;
|
||||||
static bool automatic_left_margin;
|
static bool automatic_left_margin;
|
||||||
|
@ -87,8 +120,20 @@ class FTermcap
|
||||||
static int attr_without_color;
|
static int attr_without_color;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Methods
|
||||||
|
static void termcap();
|
||||||
|
static void termcapError (int);
|
||||||
|
static void termcapVariables (char*&);
|
||||||
|
static void termcapBoleans();
|
||||||
|
static void termcapNumerics();
|
||||||
|
static void termcapStrings (char*&);
|
||||||
|
static void termcapKeys (char*&);
|
||||||
|
static void termcapKeysVt100 (char*&);
|
||||||
|
|
||||||
// Data Member
|
// Data Member
|
||||||
static tcap_map tcap[];
|
static tcap_map tcap[];
|
||||||
|
static FTermData* fterm_data;
|
||||||
|
static FTermDetection* term_detection;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|
|
@ -73,18 +73,18 @@ class FTermcapQuirks
|
||||||
private:
|
private:
|
||||||
// Methods
|
// Methods
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
static void init_termcap_freebsd_quirks();
|
static void freebsd();
|
||||||
#endif
|
#endif
|
||||||
static void init_termcap_cygwin_quirks();
|
static void cygwin();
|
||||||
static void init_termcap_linux_quirks();
|
static void linux();
|
||||||
static void init_termcap_xterm_quirks();
|
static void xterm();
|
||||||
static void init_termcap_rxvt_quirks();
|
static void rxvt();
|
||||||
static void init_termcap_vte_quirks();
|
static void vte();
|
||||||
static void init_termcap_putty_quirks();
|
static void putty();
|
||||||
static void init_termcap_teraterm_quirks();
|
static void teraterm();
|
||||||
static void init_termcap_sun_quirks();
|
static void sun();
|
||||||
static void init_termcap_screen_quirks();
|
static void screen();
|
||||||
static void init_termcap_general_quirks();
|
static void general();
|
||||||
|
|
||||||
// Data Members
|
// Data Members
|
||||||
static FTermcap::tcap_map* tcap;
|
static FTermcap::tcap_map* tcap;
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
|
|
||||||
#include "final/fterm.h"
|
#include "final/fterm.h"
|
||||||
|
|
||||||
|
|
||||||
// Preprocessing handler macro
|
// Preprocessing handler macro
|
||||||
#define F_PREPROC_HANDLER(i,h) \
|
#define F_PREPROC_HANDLER(i,h) \
|
||||||
static_cast<FVTerm*>((i)) \
|
static_cast<FVTerm*>((i)) \
|
||||||
|
@ -283,8 +284,8 @@ class FVTerm : public FTerm
|
||||||
static void restoreVTerm (const FRect&);
|
static void restoreVTerm (const FRect&);
|
||||||
static void restoreVTerm (int, int, int, int);
|
static void restoreVTerm (int, int, int, int);
|
||||||
static void setTextToDefault (term_area*, int, int);
|
static void setTextToDefault (term_area*, int, int);
|
||||||
static bool reallocateTextArea (term_area*, int, int);
|
static bool reallocateTextArea (term_area*, std::size_t, std::size_t);
|
||||||
static bool reallocateTextArea (term_area*, int);
|
static bool reallocateTextArea (term_area*, std::size_t);
|
||||||
|
|
||||||
static covered_state isCovered ( const FPoint&
|
static covered_state isCovered ( const FPoint&
|
||||||
, term_area* );
|
, term_area* );
|
||||||
|
@ -417,7 +418,6 @@ class FVTerm : public FTerm
|
||||||
#endif
|
#endif
|
||||||
static int appendOutputBuffer (int);
|
static int appendOutputBuffer (int);
|
||||||
|
|
||||||
|
|
||||||
// Data Members
|
// Data Members
|
||||||
static std::queue<int>* output_buffer;
|
static std::queue<int>* output_buffer;
|
||||||
static charData term_attribute;
|
static charData term_attribute;
|
||||||
|
|
Loading…
Reference in New Issue