More use of direct initializations

This commit is contained in:
Markus Gans 2019-08-25 22:16:00 +02:00
parent 43de8d6150
commit 37ed970319
73 changed files with 979 additions and 1205 deletions

View File

@ -1,3 +1,6 @@
2019-08-25 Markus Gans <guru.mail@muenster.de>
* More use of direct initializations
2019-08-18 Markus Gans <guru.mail@muenster.de>
* Solved problem detecting terminal size on quick changes
* Update VTerm information only in case of changes

View File

@ -136,7 +136,7 @@ void SegmentView::hexEncoding()
//----------------------------------------------------------------------
void SegmentView::get7Segment (const wchar_t c)
{
for (int i = 0; i < 3; i++)
for (int i{0}; i < 3; i++)
line[i].clear();
switch ( c )
@ -207,7 +207,7 @@ void SegmentView::draw()
FColorPair color(fc::LightRed, fc::Black);
get7Segment(ch);
for (std::size_t i = 0; i < 3; i++)
for (std::size_t i{0}; i < 3; i++)
tbuffer[i] << color << line[i] << " ";
}

View File

@ -35,7 +35,7 @@ using finalcut::FPoint;
using finalcut::FSize;
using finalcut::FColorPair;
constexpr lDouble PI = 3.141592653589793238L;
constexpr lDouble PI{3.141592653589793238L};
//----------------------------------------------------------------------
@ -255,7 +255,7 @@ Calc::Calc (FWidget* parent)
setText ("Calculator");
setGeometry (FPoint(19, 6), FSize(37, 18));
for (std::size_t key = 0; key < Calc::NUM_OF_BUTTONS; key++)
for (std::size_t key{0}; key < Calc::NUM_OF_BUTTONS; key++)
{
auto btn = std::make_shared<Button>(this);
button_no[key] = key;
@ -264,11 +264,9 @@ Calc::Calc (FWidget* parent)
btn->setGeometry(FPoint(30, 15), FSize(5, 3));
else
{
int x, y;
std::size_t n;
( key <= Three ) ? n = 0 : n = 1;
x = int(key + n) % 5 * 7 + 2;
y = int(key + n) / 5 * 2 + 3;
std::size_t n = ( key <= Three ) ? 0 : 1;
int x = int(key + n) % 5 * 7 + 2;
int y = int(key + n) / 5 * 2 + 3;
btn->setGeometry(FPoint(x, y), FSize(5, 1));
}
@ -311,7 +309,7 @@ Calc::~Calc()
//----------------------------------------------------------------------
void Calc::drawDispay()
{
finalcut::FString display = input;
finalcut::FString display(input);
if ( display.isNull() || display.isEmpty() )
display = L'0';
@ -346,11 +344,11 @@ void Calc::drawDispay()
if ( isNewFont() )
{
wchar_t bottom_line = fc::NF_border_line_bottom;
wchar_t top_bottom_line = fc::NF_border_line_up_and_down;
wchar_t top_line = fc::NF_border_line_upper;
wchar_t right_line = fc::NF_rev_border_line_right;
wchar_t left_line = fc::NF_border_line_left;
wchar_t bottom_line {fc::NF_border_line_bottom};
wchar_t top_bottom_line {fc::NF_border_line_up_and_down};
wchar_t top_line {fc::NF_border_line_upper};
wchar_t right_line {fc::NF_rev_border_line_right};
wchar_t left_line {fc::NF_border_line_left};
print() << FPoint(3, 2) << finalcut::FString(33, bottom_line);
print() << FPoint(2, 3) << right_line;
print() << FPoint(36, 3) << left_line;
@ -365,12 +363,12 @@ void Calc::drawDispay()
}
else
{
wchar_t vertical_and_right = fc::BoxDrawingsVerticalAndRight;
wchar_t horizontal = fc::BoxDrawingsHorizontal;
wchar_t vertical_and_left = fc::BoxDrawingsVerticalAndLeft;
finalcut::FString separator = finalcut::FString(vertical_and_right)
wchar_t vertical_and_right {fc::BoxDrawingsVerticalAndRight};
wchar_t horizontal {fc::BoxDrawingsHorizontal};
wchar_t vertical_and_left {fc::BoxDrawingsVerticalAndLeft};
finalcut::FString separator ( finalcut::FString(vertical_and_right)
+ finalcut::FString(35, horizontal)
+ finalcut::FString(vertical_and_left);
+ finalcut::FString(vertical_and_left) );
print() << FPoint(1, 4) << separator;
}
}
@ -609,7 +607,7 @@ void Calc::pi (lDouble& x)
//----------------------------------------------------------------------
void Calc::open_bracket (lDouble&)
{
stack_data d = { a, infix_operator };
stack_data d{ a, infix_operator };
bracket_stack.push(d);
clearInfixOperator();
input = "";
@ -906,7 +904,7 @@ lDouble& Calc::getValue()
//----------------------------------------------------------------------
void Calc::setDisplay (lDouble d)
{
char buffer[33];
char buffer[33]{};
snprintf (buffer, sizeof(buffer), "%32.11Lg", d);
input = buffer;
}

View File

@ -132,7 +132,7 @@ void CheckList::populate()
constexpr int lastItem = int(sizeof(list) / sizeof(list[0])) - 1;
for (int i = 0; i <= lastItem; i++)
for (int i{0}; i <= lastItem; i++)
{
const finalcut::FStringList line (&list[i][0], &list[i][0] + 2);
auto iter = listView.insert (line);

View File

@ -97,7 +97,7 @@ void preset (std::vector<FRadioButtonPtr>& os)
//----------------------------------------------------------------------
int main (int argc, char* argv[])
{
finalcut::FString label_text = "no OS";
finalcut::FString label_text("no OS");
// Create the application object
finalcut::FApplication app(argc, argv);
@ -106,8 +106,8 @@ int main (int argc, char* argv[])
finalcut::FDialog dgl(&app);
dgl.setModal();
dgl.setText ("UNIX select");
std::size_t w = 20;
std::size_t h = 13;
std::size_t w{20};
std::size_t h{13};
int x = int(app.getDesktopWidth() - w) / 2;
int y = int(app.getDesktopHeight() - h) / 2;
dgl.setGeometry (FPoint(x, y), FSize(w, h));
@ -123,7 +123,7 @@ int main (int argc, char* argv[])
// Set the radio button geometry
// => checkButtonGroup.setScrollSize(...) is not required
// because a FButtonGroup is self-adjusting
for (uInt i = 0; i < os.size(); i++)
for (uInt i{0}; i < os.size(); i++)
os[i]->setGeometry(FPoint(1, int(1 + i)), FSize(12, 1));
preset(os);
@ -148,7 +148,7 @@ int main (int argc, char* argv[])
dgl.show();
// Get the checked radio button text
for (int n = 1; n <= int(checkButtonGroup.getCount()); n++)
for (int n{1}; n <= int(checkButtonGroup.getCount()); n++)
{
if ( checkButtonGroup.isChecked(n) )
{

View File

@ -54,7 +54,7 @@ Keyboard::Keyboard (finalcut::FWidget* parent)
void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
{
FKey key_id = ev->key();
bool is_last_line = false;
bool is_last_line{false};
if ( getPrintPos().getY() == int(getDesktopHeight()) )
is_last_line = true;

View File

@ -119,12 +119,12 @@ Listbox::Listbox (FWidget* parent)
list1.setGeometry(FPoint(2, 1), FSize(18, 10));
list1.setText ("FListBoxItem");
for (int i = 1; i < 30; i++)
for (int i{1}; i < 30; i++)
list1.insert (L"----- " + (FString() << i) + L" -----");
// listbox 2
//----------
for (double i = 1; i<=15; i++)
for (double i{1.0}; i <= 15.0; i++)
double_list.push_back(2 * i + (i / 100));
list2.setGeometry(FPoint(21, 1), FSize(10, 10));

View File

@ -179,7 +179,7 @@ void Listview::populate()
constexpr int lastItem = int(sizeof(weather) / sizeof(weather[0])) - 1;
for (int i = 0; i <= lastItem; i++)
for (int i{0}; i <= lastItem; i++)
{
finalcut::FStringList line (&weather[i][0], &weather[i][0] + 5);
listView.insert (line);

View File

@ -68,42 +68,37 @@ Mandelbrot::~Mandelbrot()
//----------------------------------------------------------------------
void Mandelbrot::draw()
{
int iter, max_iter;
int Cols, Lines, xoffset, yoffset, current_line;
double x, y, xtemp, x0, y0, dX, dY;
double x_min, x_max, y_min, y_max;
finalcut::FDialog::draw();
x_min = -2.20;
x_max = 1.00;
y_min = -1.05;
y_max = 1.05;
max_iter = 99;
double x_min{-2.20};
double x_max{+1.00};
double y_min{-1.05};
double y_max{+1.05};
int max_iter{99};
xoffset = 2;
yoffset = 2;
current_line = 0;
Cols = int(getClientWidth());
Lines = int(getClientHeight());
int xoffset{2};
int yoffset{2};
int current_line{0};
int Cols = int(getClientWidth());
int Lines = int(getClientHeight());
dX = (x_max - x_min) / (Cols - 1);
dY = (y_max - y_min) / Lines;
double dX = (x_max - x_min) / (Cols - 1);
double dY = (y_max - y_min) / Lines;
for (y0 = y_min; y0 < y_max && current_line < Lines; y0 += dY)
for (double y0 = y_min; y0 < y_max && current_line < Lines; y0 += dY)
{
current_line++;
print() << FPoint(xoffset, yoffset + current_line);
for (x0 = x_min; x0 < x_max; x0 += dX)
for (double x0 = x_min; x0 < x_max; x0 += dX)
{
x = 0.0;
y = 0.0;
iter = 0;
double x{0.0};
double y{0.0};
int iter{0};
while ( x * x + y * y < 4 && iter < max_iter )
{
xtemp = x * x - y * y + x0;
double xtemp = x * x - y * y + x0;
y = 2 * x * y + y0;
x = xtemp;
iter++;

View File

@ -264,7 +264,7 @@ void Menu::configureBorderMenuItems()
//----------------------------------------------------------------------
void Menu::defaultCallback (finalcut::FMenuList* mb)
{
for (uInt i = 1; i <= mb->getCount(); i++)
for (uInt i{1}; i <= mb->getCount(); i++)
{
auto item = mb->getItem(int(i));

View File

@ -108,7 +108,7 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev)
if ( ev->getButton() == fc::MiddleButton )
return;
for (int c = 0; c < 16; c++)
for (int c{0}; c < 16; c++)
{
int xmin = 2 + (c / 8) * 3;
int xmax = 4 + (c / 8) * 3;
@ -133,7 +133,7 @@ void ColorChooser::draw()
setColor();
drawBorder();
for (FColor c = 0; c < 16; c++)
for (FColor c{0}; c < 16; c++)
{
print() << FPoint(2 + (c / 8) * 3, 3 + c % 8);
@ -249,7 +249,7 @@ Brushes::~Brushes()
//----------------------------------------------------------------------
void Brushes::draw()
{
int pos;
int pos{};
setColor();
drawBorder();
print() << FPoint(2, 3)
@ -439,7 +439,7 @@ void MouseDraw::draw()
if ( isNewFont() )
{
for (int y = 2; y < y_max; y++)
for (int y{2}; y < y_max; y++)
{
print() << FPoint(10, y)
<< fc::NF_rev_border_line_right;
@ -453,7 +453,7 @@ void MouseDraw::draw()
print() << FPoint(10, 2)
<< fc::BoxDrawingsDownAndHorizontal;
for (int y = 3; y < y_max; y++)
for (int y{3}; y < y_max; y++)
{
print() << FPoint(10, y) << fc::BoxDrawingsVertical;
}
@ -503,10 +503,10 @@ void MouseDraw::drawCanvas()
, x_end = canvas->width
, w_line_len = print_area->width + print_area->right_shadow;
for (int y = 0; y < y_end; y++) // line loop
for (int y{0}; y < y_end; y++) // line loop
{
finalcut::charData* canvaschar; // canvas character
finalcut::charData* winchar; // window character
finalcut::charData* canvaschar{}; // canvas character
finalcut::charData* winchar{}; // window character
canvaschar = &canvas->text[y * x_end];
winchar = &print_area->text[(ay + y) * w_line_len + ax];
std::memcpy ( winchar
@ -526,7 +526,7 @@ void MouseDraw::drawCanvas()
//----------------------------------------------------------------------
void MouseDraw::adjustSize()
{
std::size_t w = 60, h = 18;
std::size_t w{60}, h{18};
int x = 1 + int((getParentWidget()->getWidth() - w) / 2);
int y = 1 + int((getParentWidget()->getHeight() - h) / 2);
setGeometry (FPoint(x, y), FSize(w, h), false);

View File

@ -30,7 +30,7 @@
static finalcut::FVTerm* terminal;
// Global FApplication object
static finalcut::FApplication* app = nullptr;
static finalcut::FApplication* app{nullptr};
// function prototype
bool keyPressed();
@ -44,12 +44,13 @@ void move (int, int, int, int);
bool keyPressed()
{
// Waiting for keypress
struct termios save, t;
bool ret;
struct termios save{};
bool ret{false};
std::cout << "\nPress any key to continue...";
fflush(stdout);
tcgetattr (STDIN_FILENO, &save);
t = save;
struct termios t = save;
t.c_lflag &= uInt(~(ICANON | ECHO));
tcsetattr (STDIN_FILENO, TCSANOW, &t);
@ -89,10 +90,8 @@ void term_boundaries (int& x, int& y)
void move (int xold, int yold, int xnew, int ynew)
{
// prints the cursor move escape sequence
std::string sequence;
char* buffer;
char from[26], to[26], byte[20];
uInt len;
std::string sequence{};
char from[26]{}, to[26]{}, byte[20]{};
const std::string ctrl_character[] =
{
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
@ -111,8 +110,8 @@ void move (int xold, int yold, int xnew, int ynew)
<< std::left << std::setw(10) << to
<< " ";
// get the move string
buffer = finalcut::FTerm::moveCursorString (xold, yold, xnew, ynew);
len = uInt(std::strlen(buffer));
char* buffer = finalcut::FTerm::moveCursorString (xold, yold, xnew, ynew);
uInt len = uInt(std::strlen(buffer));
for (uInt i = 0; i < len; i++)
{
@ -142,8 +141,6 @@ void move (int xold, int yold, int xnew, int ynew)
//----------------------------------------------------------------------
int main (int argc, char* argv[])
{
int xmax, ymax;
// Create the application object
finalcut::FApplication TermApp(argc, argv);
@ -152,8 +149,8 @@ int main (int argc, char* argv[])
app = &TermApp;
// Get screen dimension
xmax = int(TermApp.getDesktopWidth() - 1);
ymax = int(TermApp.getDesktopHeight() - 1);
int xmax = int(TermApp.getDesktopWidth() - 1);
int ymax = int(TermApp.getDesktopHeight() - 1);
finalcut::FString line(std::size_t(xmax) + 1, '-');
// Place the cursor in the upper left corner

View File

@ -138,11 +138,11 @@ void Scrollview::draw()
setColor (wc.label_inactive_fg, wc.dialog_bg);
clearArea();
for (int y = 0; y < int(getScrollHeight()); y++)
for (int y{0}; y < int(getScrollHeight()); y++)
{
print() << FPoint(1, 1 + y);
for (int x = 0; x < int(getScrollWidth()); x++)
for (int x{0}; x < int(getScrollWidth()); x++)
print (32 + ((x + y) % 0x5f));
}

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2012-2018 Markus Gans *
* Copyright 2012-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -101,7 +101,7 @@ void inputStreamExample()
void outputStreamExample()
{
// Test: output stream (operator <<)
const finalcut::FString& out = L"A test string for 0 \x20ac";
const finalcut::FString out{L"A test string for 0 \x20ac"};
std::cout << " outstream << " << out << std::endl;
}
@ -187,7 +187,7 @@ void streamingFromFStringExample()
std::wcout << "stream out: " << stream_wstring << std::endl;
// ...to wide character
wchar_t stream_wchar_t = L'\0';
wchar_t stream_wchar_t{L'\0'};
finalcut::FString("w") >> stream_wchar_t;
std::wcout << "stream out: " << stream_wchar_t << std::endl;
@ -302,7 +302,7 @@ void streamToFloat()
void CStringOutputExample()
{
// Test: c-string output
const finalcut::FString& out = L"A test string for 0 \x20ac";
const finalcut::FString out{L"A test string for 0 \x20ac"};
printf (" c_str: \"%s\"\n", out.c_str());
}
@ -326,7 +326,7 @@ void copyIntoFString()
void utf8StringOutputExample()
{
// Test: utf-8 string
const finalcut::FString& len = "длина́";
const finalcut::FString len{"длина́"};
std::cout << " length: \"" << len << "\" has "
<< len.getLength() << " characters" << std::endl;
}
@ -335,11 +335,11 @@ void utf8StringOutputExample()
void letterCaseExample()
{
// Test: convert uppercase letter to lowercase
const finalcut::FString& lower = finalcut::FString(L"InPut").toLower();
const finalcut::FString lower{finalcut::FString(L"InPut").toLower()};
std::wcout << L" toLower: " << lower << std::endl;
// Test: convert lowercase letter to uppercase
const finalcut::FString& upper = finalcut::FString("inPut").toUpper();
const finalcut::FString upper{finalcut::FString("inPut").toUpper()};
std::cout << " toUpper: " << upper << std::endl;
}
@ -414,7 +414,7 @@ void stringConcatenationExample()
void stringCompareExample()
{
// Test: compare operators ==, <=, <, >=, >, !=
const finalcut::FString& cmp = "compare";
const finalcut::FString cmp{"compare"};
if ( cmp == finalcut::FString("compare") )
std::cout << " cmp: == Ok" << std::endl;
@ -451,10 +451,10 @@ void stringCompareExample()
void stringSplittingExample()
{
// Test: split a string with a delimiter and returns a vector (array)
finalcut::FString split_str = "a,b,c,d";
finalcut::FString split_str{"a,b,c,d"};
std::cout << " split: \""
<< split_str << "\" into substrings ->";
finalcut::FStringList parts = split_str.split(",");
finalcut::FStringList parts{ split_str.split(",") };
finalcut::FStringList::iterator it, end;
end = parts.end();
@ -468,7 +468,7 @@ void stringSplittingExample()
void fromatStringExample()
{
// Test: format a string with sprintf
finalcut::FString formatStr = "";
finalcut::FString formatStr{""};
std::cout << " formatted: "
<< formatStr.sprintf("sqrt(%d) = %d", 16, 4)
<< std::endl;
@ -533,7 +533,7 @@ void convertToNumberExample()
void convertNumberToStringExample()
{
// Test: convert integer and double value to a string
finalcut::FString num1, num2, num3;
finalcut::FString num1{}, num2{}, num3{};
num1.setNumber(137u);
num2.setNumber(-512);
num3.setNumber(3.141592653589793238L, 12);
@ -550,7 +550,7 @@ void formatedNumberExample()
{
// Test: convert and format a integer number with thousand separator
std::setlocale (LC_NUMERIC, "");
finalcut::FString fnum1, fnum2;
finalcut::FString fnum1{}, fnum2{};
#if defined(__LP64__) || defined(_LP64)
// 64-bit architecture
fnum1.setFormatedNumber(0xffffffffffffffffu, '\'');
@ -570,7 +570,7 @@ void formatedNumberExample()
void trimExample()
{
// Test: remove whitespace from the end of a string
const finalcut::FString& trim_str = " A string \t";
const finalcut::FString& trim_str{" A string \t"};
std::wcout << " rtrim: \""
<< trim_str.rtrim() << "\"" << std::endl;
@ -587,8 +587,8 @@ void trimExample()
void substringExample()
{
// Test: 11 characters from the left of the string
const finalcut::FString& alphabet = "a b c d e f g h i j k l m "
"n o p q r s t u v w x y z";
const finalcut::FString alphabet{ "a b c d e f g h i j k l m "
"n o p q r s t u v w x y z" };
std::cout << " left: \""
<< alphabet.left(11) << "\"" << std::endl;
@ -605,7 +605,7 @@ void substringExample()
void insertExample()
{
// Test: insert a string at index position 7
finalcut::FString insert_str = "I am a string";
finalcut::FString insert_str{"I am a string"};
try
{
@ -622,7 +622,7 @@ void insertExample()
void indexExample()
{
// Test: get character access at a specified index position
finalcut::FString index(5); // string with five characters
finalcut::FString index{5}; // string with five characters
index = "index";
try
@ -642,7 +642,7 @@ void indexExample()
void iteratorExample()
{
// Test: character access with std::iterator
const finalcut::FString& stringIterator = "iterator";
const finalcut::FString stringIterator{"iterator"};
finalcut::FString::iterator iter;
iter = stringIterator.begin();
std::cout << " " << stringIterator << ": ";
@ -662,7 +662,7 @@ void iteratorExample()
void overwriteExample()
{
// Test: overwrite string at position 10 with "for t"
finalcut::FString overwrite_std = "Overwrite the rest";
finalcut::FString overwrite_std{"Overwrite the rest"};
std::cout << "overwrite: "
<< overwrite_std.overwrite("for t", 10) << std::endl;
}
@ -671,7 +671,7 @@ void overwriteExample()
void removeExample()
{
// Test: remove 2 characters at position 7
finalcut::FString remove_std = "A fast remove";
finalcut::FString remove_std{"A fast remove"};
std::cout << " remove: "
<< remove_std.remove(7, 2) << std::endl;
}
@ -680,7 +680,7 @@ void removeExample()
void substringIncludeExample()
{
// Test: includes a substring (positive test)
finalcut::FString include_std = "string";
finalcut::FString include_std{"string"};
if ( include_std.includes("ring") )
std::cout << " includes: \""
@ -706,7 +706,7 @@ void substringIncludeExample()
void replaceExample()
{
// Test: find and replace a substring
finalcut::FString source_str = "computer and software";
finalcut::FString source_str{"computer and software"};
const finalcut::FString& replace_str = \
source_str.replace("computer", "hard-");
std::cout << " replace: "
@ -717,7 +717,7 @@ void replaceExample()
void tabToSpaceExample()
{
// Test: convert tabs to spaces
const finalcut::FString& tab_str = "1234\t5678";
const finalcut::FString tab_str{"1234\t5678"};
std::cout << " tab: "
<< tab_str.expandTabs() << std::endl;
}
@ -726,7 +726,7 @@ void tabToSpaceExample()
void backspaceControlCharacterExample()
{
// Test: backspaces remove characters in the string
const finalcut::FString& bs_str = "t\b\bTesT\bt";
const finalcut::FString bs_str{"t\b\bTesT\bt"};
std::cout << "backspace: "
<< bs_str.removeBackspaces() << std::endl;
}
@ -735,7 +735,7 @@ void backspaceControlCharacterExample()
void deleteControlCharacterExample()
{
// Test: delete characters remove characters in the string
const finalcut::FString& del_str = "apple \177\177\177pietree";
const finalcut::FString del_str{"apple \177\177\177pietree"};
std::cout << " delete: "
<< del_str.removeDel() << std::endl;
}

View File

@ -261,7 +261,7 @@ void AttribDemo::printColorLine()
{
auto parent = static_cast<AttribDlg*>(getParent());
for (FColor color = 0; color < colors; color++)
for (FColor color{0}; color < colors; color++)
{
print() << FColorPair(color, parent->bgcolor) << " # ";
}
@ -439,7 +439,7 @@ void AttribDemo::draw()
[&] { printProtected(); },
};
for (std::size_t y = 0; y < getParentWidget()->getHeight() - 7; y++)
for (std::size_t y{0}; y < getParentWidget()->getHeight() - 7; y++)
{
print() << FPoint(1, 2 + int(y));

View File

@ -181,8 +181,7 @@ void tcapNumeric (const std::string& name, int cap_num)
//----------------------------------------------------------------------
void tcapString (const std::string& name, const char cap_str[])
{
uInt len;
std::string sequence;
std::string sequence{};
std::cout << name << ": ";
if ( cap_str == 0 )
@ -191,9 +190,9 @@ void tcapString (const std::string& name, const char cap_str[])
return;
}
len = uInt(std::strlen(cap_str));
uInt len = uInt(std::strlen(cap_str));
for (uInt i = 0; i < len; i++)
for (uInt i{0}; i < len; i++)
{
uChar c = uChar(cap_str[i]);
@ -298,7 +297,7 @@ void string()
finalcut::FTermcap::tcap_map (&tcap_strings)[] \
= finalcut::FTermcap::strings;
for (int n = 0; n <= data::getNumberOfItems(); n++ )
for (int n{0}; n <= data::getNumberOfItems(); n++ )
{
const std::string name = data::strings[n].name;
const fc::termcaps cap = data::strings[n].cap;
@ -311,7 +310,7 @@ void string()
//----------------------------------------------------------------------
int main (int argc, char* argv[])
{
bool disable_alt_screen = true;
bool disable_alt_screen{true};
finalcut::FApplication TermApp (argc, argv, disable_alt_screen);
// Pointer to the global virtual terminal object

View File

@ -71,7 +71,7 @@ void Timer::draw()
//----------------------------------------------------------------------
void Timer::onTimer (finalcut::FTimerEvent* ev)
{
bool is_last_line = false;
bool is_last_line{false};
int timer_id = ev->getTimerId();
if ( getPrintPos().getY() == int(getDesktopHeight()) )

View File

@ -110,7 +110,7 @@ void Transparent::draw()
finalcut::FString line(getClientWidth(), '.');
for (int n = 1; n <= int(getClientHeight()); n++)
for (int n{1}; n <= int(getClientHeight()); n++)
{
print() << FPoint(2, 2 + n) << line;
}

View File

@ -572,7 +572,7 @@ void MyDialog::initWidgets()
myList.setMultiSelection();
myList.reserve(100);
for (int z = 1; z < 100; z++)
for (int z{1}; z < 100; z++)
myList.insert (finalcut::FString() << z << L" placeholder");
// Text labels
@ -930,7 +930,7 @@ void MyDialog::cb_updateNumber (finalcut::FWidget* widget, FDataPtr data)
const auto& count = list.getCount();
int select_num = 0;
for (std::size_t n = 1; n <= count; n++)
for (std::size_t n{1}; n <= count; n++)
if ( list.isSelected(n) )
select_num++;
@ -1006,10 +1006,10 @@ void MyDialog::cb_setInput (finalcut::FWidget* widget, FDataPtr data)
int main (int argc, char* argv[])
{
const finalcut::FString ver = F_VERSION; // Library version
const finalcut::FString title = "The FINAL CUT "
const finalcut::FString ver{F_VERSION}; // Library version
const finalcut::FString title { "The FINAL CUT "
+ ver
+ " (C) 2019 by Markus Gans";
+ " (C) 2019 by Markus Gans" };
// Create the application object app
finalcut::FApplication app(argc, argv);

View File

@ -127,11 +127,10 @@ Watch::~Watch()
//----------------------------------------------------------------------
void Watch::printTime()
{
finalcut::FString str;
std::tm now;
std::time_t t;
finalcut::FString str{};
std::tm now{};
t = std::time(0); // get current time
std::time_t t = std::time(0); // get current time
localtime_r(&t, &now);
if ( sec )

View File

@ -98,8 +98,8 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
top_right_label.setEmphasis();
top_right_label.setGeometry (FPoint(int(getClientWidth()) - 5, 1), FSize(6, 1));
finalcut::FString bottom_label_text = "resize\n"
"corner\n";
finalcut::FString bottom_label_text ( "resize\n"
"corner\n" );
bottom_label_text += arrow_down;
bottom_label = bottom_label_text;
bottom_label.setAlignment (fc::alignRight);
@ -263,7 +263,7 @@ Window::Window (finalcut::FWidget* parent)
Statusbar.setMessage("Status bar message");
// Generate data vector for the windows
for (int n = 1; n <= 6; n++)
for (int n{1}; n <= 6; n++)
{
auto win_dat = new win_data;
win_dat->title.sprintf("Window %1d", n);

View File

@ -38,26 +38,26 @@ namespace finalcut
{
// Global application object
static FApplication* app_object = nullptr;
static FApplication* app_object{nullptr};
// Flag to exit the local event loop
static bool app_exit_loop = false;
static bool app_exit_loop{false};
// Static attributes
FWidget* FWidget::main_widget = nullptr; // main application widget
FWidget* FWidget::active_window = nullptr; // the active window
FWidget* FWidget::focus_widget = nullptr; // has keyboard input focus
FWidget* FWidget::clicked_widget = nullptr; // is focused by click
FWidget* FWidget::open_menu = nullptr; // currently open menu
FWidget* FWidget::move_size_widget = nullptr; // move/size by keyboard
FWidget* FApplication::keyboard_widget = nullptr; // has the keyboard focus
FKeyboard* FApplication::keyboard = nullptr; // keyboard access
FMouseControl* FApplication::mouse = nullptr; // mouse control
int FApplication::loop_level = 0; // event loop level
int FApplication::quit_code = 0;
bool FApplication::quit_now = false;
FWidget* FWidget::main_widget {nullptr}; // main application widget
FWidget* FWidget::active_window {nullptr}; // the active window
FWidget* FWidget::focus_widget {nullptr}; // has keyboard input focus
FWidget* FWidget::clicked_widget {nullptr}; // is focused by click
FWidget* FWidget::open_menu {nullptr}; // currently open menu
FWidget* FWidget::move_size_widget {nullptr}; // move/size by keyboard
FWidget* FApplication::keyboard_widget {nullptr}; // has the keyboard focus
FKeyboard* FApplication::keyboard {nullptr}; // keyboard access
FMouseControl* FApplication::mouse {nullptr}; // mouse control
int FApplication::loop_level {0}; // event loop level
int FApplication::quit_code {0};
bool FApplication::quit_now {false};
FApplication::eventQueue* FApplication::event_queue = nullptr;
FApplication::eventQueue* FApplication::event_queue{nullptr};
//----------------------------------------------------------------------
@ -81,7 +81,7 @@ FApplication::FApplication ( const int& _argc
if ( ! (_argc && _argv) )
{
static char* empty = C_STR("");
static char* empty{C_STR("")};
app_argc = 0;
app_argv = static_cast<char**>(&empty);
}
@ -128,11 +128,10 @@ int FApplication::exec() // run
//----------------------------------------------------------------------
int FApplication::enter_loop() // event loop
{
bool old_app_exit_loop;
loop_level++;
quit_now = false;
old_app_exit_loop = app_exit_loop;
bool old_app_exit_loop = app_exit_loop;
app_exit_loop = false;
while ( ! (quit_now || app_exit_loop) )
@ -265,15 +264,13 @@ bool FApplication::eventInQueue()
//----------------------------------------------------------------------
bool FApplication::removeQueuedEvent (const FObject* receiver)
{
bool retval;
if ( ! eventInQueue() )
return false;
if ( ! receiver )
return false;
retval = false;
bool retval{false};
auto iter = event_queue->begin();
while ( iter != event_queue->end() )
@ -410,8 +407,6 @@ void FApplication::cmd_options (const int& argc, char* argv[])
while ( true )
{
int c, idx = 0;
static struct option long_options[] =
{
{C_STR("encoding"), required_argument, 0, 0 },
@ -433,7 +428,8 @@ void FApplication::cmd_options (const int& argc, char* argv[])
};
opterr = 0;
c = getopt_long (argc, argv, "", long_options, &idx);
int idx{0};
int c = getopt_long (argc, argv, "", long_options, &idx);
if ( c == -1 )
break;
@ -497,7 +493,7 @@ inline void FApplication::findKeyboardWidget()
{
// Find the widget that has the keyboard focus
FWidget* widget = nullptr;
FWidget* widget{nullptr};
auto focus = getFocusWidget();
auto move_size = getMoveSizeWidget();
@ -710,7 +706,7 @@ bool FApplication::processDialogSwitchAccelerator()
//----------------------------------------------------------------------
bool FApplication::processAccelerator (const FWidget*& widget)
{
bool accpt = false;
bool accpt{false};
if ( widget
&& widget->accelerator_list
@ -752,7 +748,7 @@ bool FApplication::processAccelerator (const FWidget*& widget)
//----------------------------------------------------------------------
bool FApplication::getMouseEvent()
{
bool mouse_event_occurred = false;
bool mouse_event_occurred{false};
if ( mouse && mouse->hasData() )
{
@ -834,7 +830,7 @@ void FApplication::closeOpenMenu()
return;
}
bool is_window_menu;
bool is_window_menu{false};
auto super = menu->getSuperMenu();
if ( super && menu->isWindowsMenu(super) )
@ -912,7 +908,7 @@ void FApplication::sendMouseEvent()
return;
const auto& mouse_position = mouse->getPos();
int key_state = 0;
int key_state{0};
if ( mouse->isShiftKeyPressed() )
key_state |= fc::ShiftButton;
@ -1179,7 +1175,7 @@ void FApplication::processCloseWidget()
//----------------------------------------------------------------------
bool FApplication::processNextEvent()
{
uInt num_events = 0;
uInt num_events{0};
processKeyboardEvent();
processMouseEvent();

View File

@ -217,9 +217,9 @@ bool FButton::setDown (bool enable)
void FButton::setText (const FString& txt)
{
if ( txt.isNull() )
text = "";
text.setString("");
else
text = txt;
text.setString(txt);
detectHotkey();
}
@ -227,8 +227,7 @@ void FButton::setText (const FString& txt)
//----------------------------------------------------------------------
void FButton::hide()
{
std::size_t s, f, size;
FColor fg, bg;
FColor fg{}, bg{};
auto parent_widget = getParentWidget();
FWidget::hide();
@ -244,16 +243,16 @@ void FButton::hide()
}
setColor (fg, bg);
s = hasShadow() ? 1 : 0;
f = isFlat() ? 1 : 0;
size = getWidth() + s + (f << 1);
std::size_t s = hasShadow() ? 1 : 0;
std::size_t f = isFlat() ? 1 : 0;
std::size_t size = getWidth() + s + (f << 1);
if ( size == 0 )
return;
char* blank = createBlankArray(size + 1);
for (std::size_t y = 0; y < getHeight() + s + (f << 1); y++)
for (std::size_t y{0}; y < getHeight() + s + (f << 1); y++)
{
print() << FPoint(1 - int(f), 1 + int(y - f)) << blank;
}
@ -309,7 +308,7 @@ void FButton::onMouseDown (FMouseEvent* ev)
getStatusBar()->drawMessage();
}
FPoint tPos = ev->getTermPos();
FPoint tPos(ev->getTermPos());
if ( getTermGeometry().contains(tPos) )
setDown();
@ -336,7 +335,7 @@ void FButton::onMouseMove (FMouseEvent* ev)
if ( ev->getButton() != fc::LeftButton )
return;
FPoint tPos = ev->getTermPos();
FPoint tPos(ev->getTermPos());
if ( click_animation )
{
@ -465,7 +464,7 @@ inline std::size_t FButton::clickAnimationIndent (FWidget* parent_widget)
setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() );
for (std::size_t y = 1; y <= getHeight(); y++)
for (std::size_t y{1}; y <= getHeight(); y++)
{
print() << FPoint(1, int(y)) << ' '; // clear one left █
}
@ -484,7 +483,7 @@ inline void FButton::clearRightMargin (FWidget* parent_widget)
setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() );
for (int y = 1; y <= int(getHeight()); y++)
for (int y{1}; y <= int(getHeight()); y++)
{
if ( isMonochron() )
setReverse(true); // Light background
@ -503,7 +502,7 @@ inline void FButton::drawMarginLeft()
setColor (getForegroundColor(), button_bg);
for (std::size_t y = 0; y < getHeight(); y++)
for (std::size_t y{0}; y < getHeight(); y++)
{
print() << FPoint(1 + int(indent), 1 + int(y));
@ -519,7 +518,7 @@ inline void FButton::drawMarginRight()
{
// Print right margin
for (std::size_t y = 0; y < getHeight(); y++)
for (std::size_t y{0}; y < getHeight(); y++)
{
print() << FPoint(int(getWidth() + indent), 1 + int(y));
@ -538,19 +537,19 @@ inline void FButton::drawTopBottomBackground()
if ( getHeight() < 2 )
return;
for (std::size_t y = 0; y < vcenter_offset; y++)
for (std::size_t y{0}; y < vcenter_offset; y++)
{
print() << FPoint(2 + int(indent), 1 + int(y));
for (std::size_t x = 1; x < getWidth() - 1; x++)
for (std::size_t x{1}; x < getWidth() - 1; x++)
print (space_char); // █
}
for (std::size_t y = vcenter_offset + 1; y < getHeight(); y++)
for (std::size_t y{vcenter_offset + 1}; y < getHeight(); y++)
{
print() << FPoint(2 + int(indent), 1 + int(y));
for (std::size_t x = 1; x < getWidth() - 1; x++)
for (std::size_t x{1}; x < getWidth() - 1; x++)
print (space_char); // █
}
}
@ -558,7 +557,7 @@ inline void FButton::drawTopBottomBackground()
//----------------------------------------------------------------------
inline void FButton::drawButtonTextLine (wchar_t button_text[])
{
std::size_t pos;
std::size_t pos{};
print() << FPoint(2 + int(indent), 1 + int(vcenter_offset))
<< FColorPair (button_fg, button_bg);
@ -584,7 +583,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
if ( active_focus && (isMonochron() || getMaxColor() < 16) )
setBold();
for ( std::size_t z = 0
for ( std::size_t z{0}
; pos < center_offset + txtlength && z < getWidth() - 2
; z++, pos++)
{
@ -630,7 +629,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
//----------------------------------------------------------------------
void FButton::draw()
{
wchar_t* button_text;
wchar_t* button_text{};
auto parent_widget = getParentWidget();
txtlength = text.getLength();
space_char = int(' ');

View File

@ -116,7 +116,7 @@ bool FButtonGroup::setEnable (bool enable)
//----------------------------------------------------------------------
void FButtonGroup::setText (const FString& txt)
{
text = txt;
text.setString(txt);
if ( isEnabled() )
{
@ -183,8 +183,7 @@ bool FButtonGroup::hasCheckedButton() const
//----------------------------------------------------------------------
void FButtonGroup::hide()
{
std::size_t size;
FColor fg, bg;
FColor fg{}, bg{};
FWidget::hide();
auto parent_widget = getParentWidget();
@ -213,14 +212,14 @@ void FButtonGroup::hide()
}
setColor (fg, bg);
size = getWidth();
std::size_t size = getWidth();
if ( size == 0 )
return;
char* blank = createBlankArray(size + 1);
for (int y = 0; y < int(getHeight()); y++)
for (int y{0}; y < int(getHeight()); y++)
{
FWidget::setPrintPos (FPoint(1, 1 + y));
print (blank);
@ -298,7 +297,7 @@ void FButtonGroup::checkScrollSize (const FRect& r)
if ( ! scrollgeometry.contains(r) )
{
FRect r_combined = scrollgeometry.combined(r);
FRect r_combined (scrollgeometry.combined(r));
setScrollSize (r_combined.getSize());
}
}
@ -424,12 +423,11 @@ void FButtonGroup::draw()
//----------------------------------------------------------------------
void FButtonGroup::drawLabel()
{
wchar_t* LabelText;
if ( text.isNull() || text.isEmpty() )
return;
FString txt = " " + text + " ";
wchar_t* LabelText{};
FString txt{" " + text + " "};
std::size_t length = txt.getLength();
try
@ -494,7 +492,7 @@ void FButtonGroup::drawText ( wchar_t LabelText[]
else
setColor(wc.label_inactive_fg, wc.label_inactive_bg);
for (std::size_t z = 0; z < length; z++)
for (std::size_t z{0}; z < length; z++)
{
if ( (z == hotkeypos) && flags.active )
{
@ -523,7 +521,7 @@ void FButtonGroup::directFocus()
{
if ( ! hasFocusedButton() )
{
bool found_checked = false;
bool found_checked{false};
if ( hasCheckedButton() && ! buttonlist.empty() )
{

View File

@ -62,7 +62,7 @@ void FCheckMenuItem::init (FWidget* parent)
if ( isMenu(parent) ) // Parent is menu
{
auto menu_ptr = static_cast<FMenu*>(parent);
auto menu_ptr{static_cast<FMenu*>(parent)};
menu_ptr->has_checkable_items = true;
}
}

View File

@ -167,7 +167,7 @@ int FDialog::exec()
//----------------------------------------------------------------------
void FDialog::setPos (const FPoint& pos, bool)
{
FRect old_geometry, restore;
setPos_error = false;
// Avoid to move widget completely outside the terminal
@ -185,7 +185,7 @@ void FDialog::setPos (const FPoint& pos, bool)
const auto& shadow = getShadow();
std::size_t width = getWidth() + shadow.getWidth(); // width + right shadow
std::size_t height = getHeight() + shadow.getHeight(); // height + bottom shadow
old_geometry = getTermGeometryWithShadow();
FRect old_geometry (getTermGeometryWithShadow());
// move to the new position
FWindow::setPos(pos, false);
@ -194,6 +194,10 @@ void FDialog::setPos (const FPoint& pos, bool)
// restoring the non-covered terminal areas
if ( getTermGeometry().overlap(old_geometry) )
{
FRect restore{};
std::size_t d_width = std::size_t(std::abs(dx));
std::size_t d_height = std::size_t(std::abs(dy));
// dx > 0 : move left
// dx = 0 : move vertical
// dx < 0 : move right
@ -201,9 +205,6 @@ void FDialog::setPos (const FPoint& pos, bool)
// dy = 0 : move horizontal
// dy < 0 : move down
std::size_t d_width = std::size_t(std::abs(dx));
std::size_t d_height = std::size_t(std::abs(dy));
if ( dx > 0 )
{
if ( dy > 0 )
@ -518,7 +519,7 @@ void FDialog::onMouseUp (FMouseEvent* ev)
&& titlebar_x < getTermX() + int(getWidth())
&& titlebar_y == int(getTermY()) )
{
FPoint deltaPos = ms.termPos - titlebar_click_pos;
FPoint deltaPos(ms.termPos - titlebar_click_pos);
move (deltaPos);
titlebar_click_pos = ms.termPos;
}
@ -562,7 +563,7 @@ void FDialog::onMouseMove (FMouseEvent* ev)
if ( ! titlebar_click_pos.isOrigin() )
{
FPoint deltaPos = ms.termPos - titlebar_click_pos;
FPoint deltaPos(ms.termPos - titlebar_click_pos);
move (deltaPos);
titlebar_click_pos = ms.termPos;
}
@ -586,15 +587,14 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
getZoomButtonWidth(),
false // mouse_over_menu
};
int x, y;
if ( ev->getButton() != fc::LeftButton )
return;
x = getTermX();
y = getTermY();
int x = getTermX();
int y = getTermY();
FRect title_button(x, y, 3, 1);
FPoint tPos = ms.termPos;
FPoint tPos(ms.termPos);
if ( title_button.contains(tPos) )
{
@ -825,7 +825,7 @@ void FDialog::initDialogMenu()
return;
}
FPoint p = getPos();
FPoint p(getPos());
p.y_ref()++;
dialog_menu->setPos(p);
dgl_menuitem = dialog_menu->getItem();
@ -1093,8 +1093,8 @@ inline void FDialog::drawZoomedButton()
void FDialog::drawTextBar()
{
// Fill with spaces (left of the title)
std::size_t center_offset = 0;
std::size_t x = 1;
std::size_t center_offset{0};
std::size_t x{1};
if ( getMaxColor() < 16 )
setBold();
@ -1143,7 +1143,7 @@ void FDialog::restoreOverlaidWindows()
if ( ! window_list || window_list->empty() )
return;
bool overlaid = false;
bool overlaid{false};
for (auto&& win : *window_list)
{
@ -1166,7 +1166,7 @@ void FDialog::setCursorToFocusWidget()
&& focus->isShown()
&& focus->hasVisibleCursor() )
{
FPoint cursor_pos = focus->getCursorPos();
FPoint cursor_pos(focus->getCursorPos());
focus->setCursorPos(cursor_pos);
updateVTermCursor(vwin);
}
@ -1207,7 +1207,7 @@ void FDialog::openMenu()
else
{
setOpenMenu(dialog_menu);
FPoint pos = getPos();
FPoint pos(getPos());
pos.y_ref()++;
dialog_menu->setPos (pos);
dialog_menu->setVisible();
@ -1483,11 +1483,11 @@ void FDialog::resizeMouseDown (const mouseStates& ms)
if ( isResizeable() && isLowerRightResizeCorner(ms) )
{
resize_click_pos = ms.termPos;
FPoint lower_right_pos = getTermGeometry().getLowerRightPos();
FPoint lower_right_pos(getTermGeometry().getLowerRightPos());
if ( ms.termPos != lower_right_pos )
{
FPoint deltaPos = ms.termPos - lower_right_pos;
FPoint deltaPos(ms.termPos - lower_right_pos);
int w = lower_right_pos.getX() + deltaPos.getX() - getTermX() + 1;
int h = lower_right_pos.getY() + deltaPos.getY() - getTermY() + 1;
const FSize& size = FSize(std::size_t(w), std::size_t(h));
@ -1510,8 +1510,8 @@ void FDialog::resizeMouseUpMove (const mouseStates& ms, bool mouse_up)
resize_click_pos = ms.termPos;
int x2 = resize_click_pos.getX()
, y2 = resize_click_pos.getY()
, x2_offset = 0
, y2_offset = 0;
, x2_offset{0}
, y2_offset{0};
if ( r )
{
@ -1521,8 +1521,8 @@ void FDialog::resizeMouseUpMove (const mouseStates& ms, bool mouse_up)
if ( ms.termPos != getTermGeometry().getLowerRightPos() )
{
int w, h;
FPoint deltaPos = ms.termPos - resize_click_pos;
int w{}, h{};
FPoint deltaPos(ms.termPos - resize_click_pos);
if ( x2 - x2_offset <= int(getMaxWidth()) )
w = resize_click_pos.getX() + deltaPos.getX() - getTermX() + 1;

View File

@ -61,20 +61,20 @@ const FString fileChooser ( FWidget* parent
, const FString& filter
, FFileDialog::DialogType type )
{
FString ret;
FString path = dirname;
FString file_filter = filter;
FString ret{};
FString path(dirname);
FString file_filter(filter);
if ( path.isNull() || path.isEmpty() )
{
path = FFileDialog::getHomeDir();
path.setString(FFileDialog::getHomeDir());
if ( path.isNull() || path.isEmpty() )
path = FString("/");
path.setString("/");
}
if ( file_filter.isNull() || file_filter.isEmpty() )
file_filter = FString("*");
file_filter.setString("*");
FFileDialog fileopen ( path
, file_filter
@ -90,7 +90,7 @@ const FString fileChooser ( FWidget* parent
}
// static class attributes
FSystem* FFileDialog::fsystem = nullptr;
FSystem* FFileDialog::fsystem{nullptr};
//----------------------------------------------------------------------
// class FFileDialog
@ -179,9 +179,9 @@ const FString FFileDialog::getSelectedFile() const
void FFileDialog::setPath (const FString& dir)
{
const char* const dirname = dir.c_str();
char resolved_path[MAXPATHLEN];
FString r_dir;
struct stat sb;
char resolved_path[MAXPATHLEN]{};
FString r_dir{};
struct stat sb{};
if ( stat(dirname, &sb) != 0 )
{
@ -205,9 +205,9 @@ void FFileDialog::setPath (const FString& dir)
}
if ( fsystem->realpath(dir.c_str(), resolved_path) != 0 )
r_dir = resolved_path;
r_dir.setString(resolved_path);
else
r_dir = dir;
r_dir.setString(dir);
if ( r_dir[r_dir.getLength() - 1] != '/' )
directory = r_dir + "/";
@ -280,10 +280,7 @@ const FString FFileDialog::fileSaveChooser ( FWidget* parent
//----------------------------------------------------------------------
void FFileDialog::adjustSize()
{
int X, Y;
std::size_t max_width;
std::size_t max_height;
std::size_t h;
std::size_t max_width{}, max_height{};
auto root_widget = getRootWidget();
if ( root_widget )
@ -298,7 +295,7 @@ void FFileDialog::adjustSize()
max_height = 24;
}
h = max_height - 6;
std::size_t h = max_height - 6;
if ( h < 15 ) // minimum
h = 15;
@ -307,8 +304,8 @@ void FFileDialog::adjustSize()
h = 30;
setHeight (h, false);
X = 1 + int((max_width - getWidth()) / 2);
Y = 1 + int((max_height - getHeight()) / 3);
int X = 1 + int((max_width - getWidth()) / 2);
int Y = 1 + int((max_height - getHeight()) / 3);
setPos(FPoint(X, Y), false);
filebrowser.setHeight (h - 8, false);
hidden_check.setY (int(h) - 4, false);
@ -422,7 +419,7 @@ void FFileDialog::initCallbacks()
inline bool FFileDialog::pattern_match ( const char* const pattern
, char fname[] )
{
char search[128] = { };
char search[128]{};
if ( show_hidden && fname[0] == '.' && fname[1] != '\0' ) // hidden files
{
@ -475,14 +472,14 @@ long FFileDialog::numOfDirs()
//----------------------------------------------------------------------
void FFileDialog::sortDir()
{
long start, dir_num;
long start{};
if ( std::strcmp((*dir_entries.begin()).name, "..") == 0 )
start = 1;
else
start = 0;
dir_num = numOfDirs();
long dir_num = numOfDirs();
// directories first
std::sort ( dir_entries.begin() + start
, dir_entries.end()
@ -565,7 +562,7 @@ int FFileDialog::readDir()
void FFileDialog::getEntry (const char* const dir, struct dirent* d_entry)
{
const char* const filter = filter_pattern.c_str();
dir_entry entry;
dir_entry entry{};
entry.name = strdup(d_entry->d_name);
@ -578,7 +575,7 @@ void FFileDialog::getEntry (const char* const dir, struct dirent* d_entry)
entry.symbolic_link = (d_entry->d_type & DT_LNK ) == DT_LNK;
entry.socket = (d_entry->d_type & DT_SOCK) == DT_SOCK;
#else
struct stat s;
struct stat s{};
stat (entry.name, &s);
entry.fifo = S_ISFIFO (s.st_mode);
entry.character_device = S_ISCHR (s.st_mode);
@ -605,9 +602,9 @@ void FFileDialog::followSymLink (const char* const dir, dir_entry& entry)
if ( ! entry.symbolic_link )
return; // No symbolic link
char resolved_path[MAXPATHLEN] = { };
char symLink[MAXPATHLEN] = { };
struct stat sb;
char resolved_path[MAXPATHLEN]{};
char symLink[MAXPATHLEN]{};
struct stat sb{};
if ( ! fsystem )
fsystem = FTerm::getFSystem();
@ -654,7 +651,7 @@ void FFileDialog::selectDirectoryEntry (const char* const name)
if ( dir_entries.empty() )
return;
std::size_t i = 1;
std::size_t i{1};
for (auto&& entry : dir_entries)
{
@ -672,8 +669,8 @@ void FFileDialog::selectDirectoryEntry (const char* const name)
//----------------------------------------------------------------------
int FFileDialog::changeDir (const FString& dirname)
{
FString lastdir = directory;
FString newdir = dirname;
FString lastdir(directory);
FString newdir(dirname);
if ( ! fsystem )
fsystem = FTerm::getFSystem();
@ -710,7 +707,7 @@ int FFileDialog::changeDir (const FString& dirname)
}
else
{
FString firstname = dir_entries[0].name;
FString firstname(dir_entries[0].name);
if ( dir_entries[0].directory )
filename.setText(firstname + '/');
@ -742,9 +739,9 @@ void FFileDialog::printPath (const FString& txt)
//----------------------------------------------------------------------
const FString FFileDialog::getHomeDir()
{
struct passwd pwd;
struct passwd* pwd_ptr;
char buf[1024];
struct passwd pwd{};
struct passwd* pwd_ptr{};
char buf[1024]{};
if ( ! fsystem )
fsystem = FTerm::getFSystem();
@ -781,7 +778,7 @@ void FFileDialog::cb_processActivate (FWidget*, FDataPtr)
}
else
{
bool found = false;
bool found{false};
const auto& input = filename.getText().trim();
if ( ! dir_entries.empty() )

View File

@ -42,11 +42,11 @@ namespace finalcut
{
// static class attributes
uInt64 FKeyboard::key_timeout = 100000; // 100 ms (default timeout for keypress)
uInt64 FKeyboard::key_timeout{100000}; // 100 ms (default timeout for keypress)
struct timeval FKeyboard::time_keypressed{};
#if defined(__linux__)
FTermLinux* FKeyboard::linux = nullptr;
FTermLinux* FKeyboard::linux{nullptr};
#endif
//----------------------------------------------------------------------
@ -102,7 +102,7 @@ void FKeyboard::fetchKeyCode()
//----------------------------------------------------------------------
const FString FKeyboard::getKeyName (FKey keynum)
{
for (std::size_t i = 0; fc::FkeyName[i].string[0] != 0; i++)
for (std::size_t i{0}; fc::FkeyName[i].string[0] != 0; i++)
if ( fc::FkeyName[i].num && fc::FkeyName[i].num == keynum )
return FString(fc::FkeyName[i].string);
@ -135,16 +135,15 @@ bool& FKeyboard::unprocessedInput()
//----------------------------------------------------------------------
bool FKeyboard::isKeyPressed()
{
int result;
fd_set ifds;
struct timeval tv;
fd_set ifds{};
struct timeval tv{};
int stdin_no = FTermios::getStdIn();
FD_ZERO(&ifds);
FD_SET(stdin_no, &ifds);
tv.tv_sec = 0;
tv.tv_usec = 100000; // 100 ms
result = select (stdin_no + 1, &ifds, 0, 0, &tv);
int result = select (stdin_no + 1, &ifds, 0, 0, &tv);
if ( result > 0 && FD_ISSET(stdin_no, &ifds) )
FD_CLR (stdin_no, &ifds);
@ -235,14 +234,14 @@ inline FKey FKeyboard::getTermcapKey()
if ( ! key_map )
return NOT_SET;
for (std::size_t i = 0; key_map[i].tname[0] != 0; i++)
for (std::size_t i{0}; key_map[i].tname[0] != 0; i++)
{
char* k = key_map[i].string;
std::size_t len = ( k ) ? std::strlen(k) : 0;
if ( k && std::strncmp(k, fifo_buf, len) == 0 ) // found
{
std::size_t n;
std::size_t n{};
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove founded entry
fifo_buf[n - len] = fifo_buf[n];
@ -265,14 +264,14 @@ inline FKey FKeyboard::getMetaKey()
assert ( FIFO_BUF_SIZE > 0 );
for (std::size_t i = 0; fc::Fmetakey[i].string[0] != 0; i++)
for (std::size_t i{0}; fc::Fmetakey[i].string[0] != 0; i++)
{
char* kmeta = fc::Fmetakey[i].string; // The string is never null
std::size_t len = std::strlen(kmeta);
if ( std::strncmp(kmeta, fifo_buf, len) == 0 ) // found
{
std::size_t n;
std::size_t n{};
if ( len == 2 && ( fifo_buf[1] == 'O'
|| fifo_buf[1] == '['
@ -301,15 +300,15 @@ inline FKey FKeyboard::getSingleKey()
{
// Looking for single key code in the buffer
std::size_t n{};
std::size_t len{1};
uChar firstchar = uChar(fifo_buf[0]);
std::size_t n;
std::size_t len = 1;
FKey keycode;
FKey keycode{};
// Look for a utf-8 character
if ( utf8_input && (firstchar & 0xc0) == 0xc0 )
{
char utf8char[5] = { }; // Init array with '\0'
char utf8char[5]{}; // Init array with '\0'
if ( (firstchar & 0xe0) == 0xc0 )
len = 2;
@ -318,7 +317,7 @@ inline FKey FKeyboard::getSingleKey()
else if ( (firstchar & 0xf8) == 0xf0 )
len = 4;
for (std::size_t i = 0; i < len ; i++)
for (std::size_t i{0}; i < len ; i++)
utf8char[i] = char(fifo_buf[i] & 0xff);
keycode = UTF8decode(utf8char);
@ -373,14 +372,14 @@ bool FKeyboard::isKeypressTimeout()
//----------------------------------------------------------------------
FKey FKeyboard::UTF8decode (const char utf8[])
{
FKey ucs = 0; // Universal coded character
FKey ucs{0}; // Universal coded character
constexpr std::size_t max = 4;
std::size_t len = std::strlen(utf8);
if ( len > max )
len = max;
for (std::size_t i = 0; i < len; ++i)
for (std::size_t i{0}; i < len; ++i)
{
uChar ch = uChar(utf8[i]);
@ -422,9 +421,8 @@ FKey FKeyboard::UTF8decode (const char utf8[])
//----------------------------------------------------------------------
inline ssize_t FKeyboard::readKey()
{
ssize_t bytes;
setNonBlockingInput();
bytes = read(FTermios::getStdIn(), &read_buf, READ_BUF_SIZE - 1);
ssize_t bytes = read(FTermios::getStdIn(), &read_buf, READ_BUF_SIZE - 1);
unsetNonBlockingInput();
return bytes;
}
@ -432,14 +430,14 @@ inline ssize_t FKeyboard::readKey()
//----------------------------------------------------------------------
void FKeyboard::parseKeyBuffer()
{
ssize_t bytesread;
ssize_t bytesread{};
FObject::getCurrentTime (&time_keypressed);
while ( (bytesread = readKey()) > 0 )
{
if ( bytesread + fifo_offset <= int(FIFO_BUF_SIZE) )
{
for (std::size_t i = 0; i < std::size_t(bytesread); i++)
for (std::size_t i{0}; i < std::size_t(bytesread); i++)
{
fifo_buf[fifo_offset] = read_buf[i];
fifo_offset++;

View File

@ -217,7 +217,7 @@ bool FLabel::setEnable (bool enable)
//----------------------------------------------------------------------
void FLabel::setText (const FString& txt)
{
text = txt;
text.setString(txt);
multiline_text = text.split("\r\n");
if ( int(multiline_text.size()) > 1 )
@ -428,15 +428,15 @@ void FLabel::draw()
//----------------------------------------------------------------------
void FLabel::drawMultiLine()
{
std::size_t y = 0;
std::size_t y{0};
std::size_t text_lines = multiline_text.size();
bool hotkey_printed = false;
bool hotkey_printed{false};
while ( y < text_lines && y < std::size_t(getHeight()) )
{
wchar_t* label_text;
std::size_t hotkeypos = NOT_SET;
std::size_t align_offset;
std::size_t hotkeypos{NOT_SET};
std::size_t align_offset{};
std::size_t length = multiline_text[y].getLength();
try
@ -480,8 +480,7 @@ void FLabel::drawMultiLine()
void FLabel::drawSingleLine()
{
wchar_t* label_text;
std::size_t hotkeypos = NOT_SET;
std::size_t align_offset;
std::size_t hotkeypos{NOT_SET};
std::size_t length = text.getLength();
try
@ -500,7 +499,7 @@ void FLabel::drawSingleLine()
length--;
print() << FPoint(1, 1);
align_offset = getAlignOffset(length);
std::size_t align_offset = getAlignOffset(length);
printLine (label_text, length, hotkeypos, align_offset);
delete[] label_text;
}
@ -511,7 +510,7 @@ void FLabel::printLine ( wchar_t line[]
, std::size_t hotkeypos
, std::size_t align_offset )
{
std::size_t to_char;
std::size_t to_char{};
std::size_t width = std::size_t(getWidth());
if ( align_offset > 0 )
@ -525,7 +524,7 @@ void FLabel::printLine ( wchar_t line[]
if ( hasReverseMode() )
setReverse(true);
for (std::size_t z = 0; z < to_char; z++)
for (std::size_t z{0}; z < to_char; z++)
{
if ( ! std::iswprint(wint_t(line[z])) )
{

View File

@ -254,12 +254,12 @@ void FLineEdit::setText (const FString& txt)
if ( txt )
{
if ( txt.getLength() > max_length )
text = txt.left(max_length);
text.setString(txt.left(max_length));
else
text = txt;
text.setString(txt);
}
else
text = "";
text.setString("");
keyEnd();
}
@ -270,7 +270,7 @@ void FLineEdit::setMaxLength (std::size_t max)
max_length = max;
if ( text.getLength() > max_length )
text = text.left(max_length);
text.setString(text.left(max_length));
keyEnd();
}
@ -291,7 +291,7 @@ void FLineEdit::setCursorPosition (std::size_t pos)
//----------------------------------------------------------------------
void FLineEdit::setLabelText (const FString& ltxt)
{
label_text = ltxt;
label_text.setString(ltxt);
label->setText(label_text);
adjustLabel();
}
@ -400,8 +400,6 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
//----------------------------------------------------------------------
void FLineEdit::onMouseDown (FMouseEvent* ev)
{
int mouse_x, mouse_y;
if ( ev->getButton() != fc::LeftButton )
return;
@ -419,8 +417,8 @@ void FLineEdit::onMouseDown (FMouseEvent* ev)
getStatusBar()->drawMessage();
}
mouse_x = ev->getX();
mouse_y = ev->getY();
int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( mouse_x >= 2 && mouse_x <= int(getWidth()) && mouse_y == 1 )
{
@ -449,15 +447,12 @@ void FLineEdit::onMouseUp (FMouseEvent*)
//----------------------------------------------------------------------
void FLineEdit::onMouseMove (FMouseEvent* ev)
{
std::size_t len;
int mouse_x, mouse_y;
if ( ev->getButton() != fc::LeftButton )
return;
len = text.getLength();
mouse_x = ev->getX();
mouse_y = ev->getY();
std::size_t len = text.getLength();
int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( mouse_x >= 2 && mouse_x <= int(getWidth()) && mouse_y == 1 )
{
@ -717,8 +712,6 @@ void FLineEdit::draw()
//----------------------------------------------------------------------
void FLineEdit::drawInputField()
{
std::size_t x;
FString show_text;
bool isActiveFocus = flags.active && flags.focus;
print() << FPoint(1, 1);
@ -741,12 +734,12 @@ void FLineEdit::drawInputField()
if ( isActiveFocus && getMaxColor() < 16 )
setBold();
show_text = text.mid(1 + text_offset, getWidth() - 2);
FString show_text(text.mid(1 + text_offset, getWidth() - 2));
if ( show_text )
print (show_text);
x = show_text.getLength();
std::size_t x = show_text.getLength();
while ( x < getWidth() - 1 )
{
@ -888,7 +881,7 @@ inline bool FLineEdit::keyInput (FKey key)
text.overwrite(c, cursor_pos);
}
else
text = c;
text.setString(c);
cursor_pos++;

View File

@ -104,12 +104,10 @@ FListBox::~FListBox() // destructor
//----------------------------------------------------------------------
void FListBox::setCurrentItem (std::size_t index)
{
std::size_t element_count;
if ( index == current )
return;
element_count = getCount();
std::size_t element_count = getCount();
if ( index > element_count )
current = element_count;
@ -211,7 +209,7 @@ bool FListBox::setFocus (bool enable)
//----------------------------------------------------------------------
void FListBox::setText (const FString& txt)
{
text = txt;
text.setString(txt);
}
//----------------------------------------------------------------------
@ -237,13 +235,11 @@ void FListBox::insert (FListBoxItem listItem)
//----------------------------------------------------------------------
void FListBox::remove (std::size_t item)
{
std::size_t element_count;
if ( item > getCount() )
return;
itemlist.erase (itemlist.begin() + int(item) - 1);
element_count = getCount();
std::size_t element_count = getCount();
max_line_width = 0;
for (auto&& listbox_item : itemlist)
@ -318,7 +314,7 @@ void FListBox::clear()
std::memset (blank, ' ', size);
blank[size] = '\0';
for (int y = 0; y < int(getHeight()) - 2; y++)
for (int y{0}; y < int(getHeight()) - 2; y++)
{
print() << FPoint(2, 2 + y) << blank;
}
@ -428,10 +424,6 @@ void FListBox::onKeyPress (FKeyEvent* ev)
//----------------------------------------------------------------------
void FListBox::onMouseDown (FMouseEvent* ev)
{
int yoffset_before
, mouse_x
, mouse_y;
if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::RightButton )
{
@ -443,9 +435,9 @@ void FListBox::onMouseDown (FMouseEvent* ev)
getWidgetFocus();
yoffset_before = yoffset;
mouse_x = ev->getX();
mouse_y = ev->getY();
int yoffset_before = yoffset;
int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
@ -553,13 +545,11 @@ void FListBox::onMouseMove (FMouseEvent* ev)
//----------------------------------------------------------------------
void FListBox::onMouseDoubleClick (FMouseEvent* ev)
{
int mouse_x, mouse_y;
if ( ev->getButton() != fc::LeftButton )
return;
mouse_x = ev->getX();
mouse_y = ev->getY();
int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
@ -624,11 +614,9 @@ void FListBox::onTimer (FTimerEvent*)
void FListBox::onWheel (FWheelEvent* ev)
{
std::size_t current_before = current;
int wheel
, yoffset_before = yoffset
, pagesize = 4;
wheel = ev->getWheel();
int yoffset_before = yoffset;
int pagesize{4};
int wheel = ev->getWheel();
if ( drag_scroll != fc::noScroll )
stopDragScroll();
@ -821,7 +809,7 @@ void FListBox::draw()
{
setColor();
for (int y = 2; y < int(getHeight()); y++)
for (int y{2}; y < int(getHeight()); y++)
{
print() << FPoint(int(getWidth()), y)
<< ' '; // clear right side of the scrollbar
@ -883,7 +871,7 @@ void FListBox::drawHeadline()
if ( text.isNull() || text.isEmpty() )
return;
FString txt = " " + text + " ";
FString txt(" " + text + " ");
std::size_t length = txt.getLength();
print() << FPoint(2, 1);
@ -908,7 +896,7 @@ void FListBox::drawList()
if ( itemlist.empty() || getHeight() <= 2 || getWidth() <= 4 )
return;
std::size_t start = 0;
std::size_t start{};
std::size_t num = uInt(getHeight() - 2);
if ( num > getCount() )
@ -929,7 +917,7 @@ void FListBox::drawList()
for (std::size_t y = start; y < num && iter != itemlist.end() ; y++)
{
bool serach_mark = false;
bool serach_mark{false};
bool lineHasBrackets = hasBrackets(iter);
// Import data via lazy conversion
@ -962,14 +950,12 @@ inline void FListBox::drawListLine ( int y
, listBoxItems::iterator iter
, bool serach_mark )
{
std::size_t i, len;
std::size_t inc_len = inc_search.getLength();
bool isCurrentLine = bool(y + yoffset + 1 == int(current));
FString element;
element = getString(iter).mid ( std::size_t(1 + xoffset)
, getWidth() - nf_offset - 4 );
FString element (getString(iter).mid ( std::size_t(1 + xoffset)
, getWidth() - nf_offset - 4 ));
const wchar_t* const& element_str = element.wc_str();
len = element.getLength();
std::size_t len = element.getLength();
if ( isMonochron() && isCurrentLine && flags.focus )
print (fc::BlackRightPointingPointer); // ►
@ -980,6 +966,8 @@ inline void FListBox::drawListLine ( int y
setColor ( wc.current_inc_search_element_fg
, wc.current_element_focus_bg );
std::size_t i{};
for (i = 0; i < len; i++)
{
if ( serach_mark && i == inc_len && flags.focus )
@ -1018,12 +1006,9 @@ inline void FListBox::drawListBracketsLine ( int y
, listBoxItems::iterator iter
, bool serach_mark )
{
FString element;
std::size_t len
, full_length
, inc_len = inc_search.getLength()
, i = 0
, b = 0;
FString element{};
std::size_t inc_len = inc_search.getLength()
, b{0};
bool isCurrentLine = bool(y + yoffset + 1 == int(current));
if ( isMonochron() && isCurrentLine && flags.focus )
@ -1044,7 +1029,9 @@ inline void FListBox::drawListBracketsLine ( int y
, getWidth() - nf_offset - 4 );
const wchar_t* const& element_str = element.wc_str();
len = element.getLength();
std::size_t full_length = getString(iter).getLength()
, len = element.getLength()
, i{0};
for (; i < len; i++)
{
@ -1059,8 +1046,6 @@ inline void FListBox::drawListBracketsLine ( int y
print (element_str[i]);
}
full_length = getString(iter).getLength();
if ( b + i < getWidth() - nf_offset - 4
&& std::size_t(xoffset) <= full_length + 1 )
{
@ -1280,7 +1265,7 @@ void FListBox::multiSelection (std::size_t pos)
//----------------------------------------------------------------------
void FListBox::multiSelectionUpTo (std::size_t pos)
{
std::size_t from, to;
std::size_t from{}, to{};
if ( ! isMultiSelection() )
return;
@ -1654,7 +1639,7 @@ inline bool FListBox::keySpace()
if ( inc_len > 0 )
{
inc_search += L' ';
bool inc_found = false;
bool inc_found{false};
auto iter = itemlist.begin();
while ( iter != itemlist.end() )
@ -1764,7 +1749,7 @@ inline bool FListBox::keyIncSearchInput (FKey key)
inc_search += wchar_t(key);
std::size_t inc_len = inc_search.getLength();
bool inc_found = false;
bool inc_found{false};
auto iter = itemlist.begin();
while ( iter != itemlist.end() )
@ -1831,8 +1816,8 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
{
FScrollbar::sType scrollType;
std::size_t current_before = current;
int distance = 1
, pagesize = 4
int distance{1}
, pagesize{4}
, yoffset_before = yoffset;
scrollType = vbar->getScrollType();
@ -1898,8 +1883,8 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
{
static constexpr int padding_space = 2; // 1 leading space + 1 trailing space
FScrollbar::sType scrollType;
int distance = 1
, pagesize = 4
int distance{1}
, pagesize{4}
, xoffset_before = xoffset;
scrollType = hbar->getScrollType();

View File

@ -57,9 +57,6 @@ uInt64 firstNumberFromString (const FString& str)
{
auto last = str.end();
auto iter = str.begin();
std::size_t pos;
std::size_t length;
uInt64 number;
while ( iter != last )
{
@ -92,8 +89,9 @@ uInt64 firstNumberFromString (const FString& str)
if ( last_pos == last )
return 0;
pos = std::size_t(std::distance(str.begin(), first_pos)) + 1;
length = std::size_t(std::distance(first_pos, last_pos));
uInt64 number;
std::size_t pos = std::size_t(std::distance(str.begin(), first_pos)) + 1;
std::size_t length = std::size_t(std::distance(first_pos, last_pos));
const auto& num_str = str.mid(pos, length);
try
@ -597,7 +595,7 @@ FListView::~FListView() // destructor
//----------------------------------------------------------------------
std::size_t FListView::getCount()
{
int n = 0;
int n{0};
auto iter = itemlist.begin();
while ( iter != itemlist.end() )
@ -640,7 +638,7 @@ FString FListView::getColumnText (int column) const
fc::sorting_type FListView::getColumnSortType (int column) const
{
fc::sorting_type type;
std::size_t col = uInt(column);
std::size_t col = std::size_t(column);
try
{
@ -683,7 +681,7 @@ void FListView::setColumnAlignment (int column, fc::text_alignment align)
return;
// Convert column position to address offset (index)
std::size_t index = uInt(column - 1);
std::size_t index = std::size_t(column - 1);
header[index].alignment = align;
}
@ -696,7 +694,7 @@ void FListView::setColumnText (int column, const FString& label)
return;
// Convert column position to address offset (index)
std::size_t index = uInt(column - 1);
std::size_t index = std::size_t(column - 1);
if ( ! header[index].fixed_width )
{
@ -717,7 +715,7 @@ void FListView::setColumnSortType (int column, fc::sorting_type type)
if ( column < 1 || header.empty() || column > int(header.size()) )
return;
std::size_t size = uInt(column + 1);
std::size_t size = std::size_t(column + 1);
if ( sort_type.empty() || sort_type.size() < size )
sort_type.resize(size);
@ -1068,7 +1066,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
if ( itemlist.empty() )
return;
int indent = 0;
int indent{0};
auto item = getCurrentItem();
if ( tree_view )
@ -1161,13 +1159,11 @@ void FListView::onMouseMove (FMouseEvent* ev)
//----------------------------------------------------------------------
void FListView::onMouseDoubleClick (FMouseEvent* ev)
{
int mouse_x, mouse_y;
if ( ev->getButton() != fc::LeftButton )
return;
mouse_x = ev->getX();
mouse_y = ev->getY();
int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
@ -1243,7 +1239,7 @@ void FListView::onWheel (FWheelEvent* ev)
{
int position_before = current_iter.getPosition()
, first_line_position_before = first_visible_line.getPosition()
, pagesize = 4;
, pagesize{4};
if ( drag_scroll != fc::noScroll )
stopDragScroll();
@ -1481,7 +1477,7 @@ void FListView::draw()
{
setColor();
for (int y = 2; y < int(getHeight()); y++)
for (int y{2}; y < int(getHeight()); y++)
{
print() << FPoint(int(getWidth()), y)
<< ' '; // clear right side of the scrollbar
@ -1592,7 +1588,7 @@ void FListView::drawList()
if ( itemlist.empty() || getHeight() <= 2 || getWidth() <= 4 )
return;
uInt y = 0;
uInt y{0};
uInt page_height = uInt(getHeight() - 2);
auto iter = first_visible_line;
@ -1644,12 +1640,12 @@ void FListView::drawListLine ( const FListViewItem* item
// Print the entry
std::size_t indent = item->getDepth() << 1; // indent = 2 * depth
FString line = getLinePrefix (item, indent);
FString line(getLinePrefix (item, indent));
// Print columns
if ( ! item->column_list.empty() )
{
for (std::size_t col = 0; col < item->column_list.size(); )
for (std::size_t col{0}; col < item->column_list.size(); )
{
static constexpr std::size_t ellipsis_length = 2;
const auto& text = item->column_list[col];
@ -1751,7 +1747,7 @@ inline void FListView::setLineAttributes ( bool is_current
//----------------------------------------------------------------------
inline FString FListView::getCheckBox (const FListViewItem* item)
{
FString checkbox;
FString checkbox{};
if ( isNewFont() )
{
@ -1760,7 +1756,7 @@ inline FString FListView::getCheckBox (const FListViewItem* item)
}
else
{
checkbox = L"[ ] ";
checkbox.setString("[ ] ");
if ( item->isChecked() )
checkbox[1] = fc::Times; // Times ×
@ -1773,7 +1769,7 @@ inline FString FListView::getCheckBox (const FListViewItem* item)
inline FString FListView::getLinePrefix ( const FListViewItem* item
, std::size_t indent )
{
FString line;
FString line{};
if ( tree_view )
{
@ -1797,7 +1793,7 @@ inline FString FListView::getLinePrefix ( const FListViewItem* item
line += L" ";
}
else
line = L" ";
line.setString(" ");
if ( item->isCheckable() )
line += getCheckBox(item);
@ -1841,7 +1837,7 @@ void FListView::drawHeadlineLabel (const headerItems::const_iterator& iter)
// Print lable text
static constexpr std::size_t leading_space = 1;
const auto& text = iter->name;
FString txt = " " + text;
FString txt(" " + text);
std::size_t width = std::size_t(iter->width);
std::size_t txt_length = txt.getLength();
std::size_t column_width = leading_space + width;
@ -1924,7 +1920,7 @@ std::size_t FListView::determineLineWidth (FListViewItem* item)
{
static constexpr std::size_t padding_space = 1;
std::size_t line_width = padding_space; // leading space
uInt column_idx = 0;
uInt column_idx{0};
uInt entries = uInt(item->column_list.size());
headerItems::iterator header_iter = header.begin();
@ -2029,7 +2025,7 @@ void FListView::recalculateVerticalBar (std::size_t element_count)
//----------------------------------------------------------------------
void FListView::mouseHeaderClicked()
{
int column = 1;
int column{1};
int checkbox_offset = ( hasCheckableItems() ) ? 4 : 0;
int header_start = 2 + checkbox_offset;
int header_pos = clicked_header_pos.getX() + xoffset;
@ -2573,8 +2569,8 @@ void FListView::scrollBy (int dx, int dy)
void FListView::cb_VBarChange (FWidget*, FDataPtr)
{
FScrollbar::sType scrollType = vbar->getScrollType();
int distance = 1
, pagesize = 4
int distance{1}
, pagesize{4}
, first_line_position_before = first_visible_line.getPosition();
switch ( scrollType )
@ -2632,8 +2628,8 @@ void FListView::cb_VBarChange (FWidget*, FDataPtr)
void FListView::cb_HBarChange (FWidget*, FDataPtr)
{
FScrollbar::sType scrollType = hbar->getScrollType();
int distance = 1
, pagesize = 4
int distance{1}
, pagesize{4}
, xoffset_before = xoffset;
switch ( scrollType )

View File

@ -469,7 +469,6 @@ void FMenu::init(FWidget* parent)
//----------------------------------------------------------------------
void FMenu::calculateDimensions()
{
int item_X, item_Y, adjust_X;
auto iter = item_list.begin();
auto last = item_list.end();
max_item_width = 10; // minimum width
@ -500,7 +499,7 @@ void FMenu::calculateDimensions()
++iter;
}
adjust_X = adjustX(getX());
int adjust_X = adjustX(getX());
// set widget geometry
setGeometry ( FPoint(adjust_X, getY())
@ -508,8 +507,8 @@ void FMenu::calculateDimensions()
// set geometry of all items
iter = item_list.begin();
item_X = 1;
item_Y = 1;
int item_X = 1;
int item_Y = 1;
while ( iter != last )
{
@ -538,12 +537,10 @@ void FMenu::adjustItems()
{
if ( (*iter)->hasMenu() )
{
int menu_X, menu_Y;
auto menu = (*iter)->getMenu();
menu_X = getTermX() + int(max_item_width) + 1;
int menu_X = getTermX() + int(max_item_width) + 1;
menu_X = menu->adjustX(menu_X);
menu_Y = (*iter)->getTermY() - 2;
int menu_Y = (*iter)->getTermY() - 2;
// set sub-menu position
menu->setPos (FPoint(menu_X, menu_Y));
@ -661,7 +658,7 @@ void FMenu::hideSuperMenus()
//----------------------------------------------------------------------
bool FMenu::mouseDownOverList (FPoint mouse_pos)
{
bool focus_changed = false;
bool focus_changed{false};
auto iter = item_list.begin();
auto last = item_list.end();
mouse_pos -= FPoint(getRightPadding(), getTopPadding());
@ -1038,7 +1035,7 @@ bool FMenu::selectNextItem()
{
if ( (*iter)->isSelected() )
{
FMenuItem* next;
FMenuItem* next{};
auto next_element = iter;
do
@ -1144,7 +1141,7 @@ bool FMenu::hotkeyMenu (FKeyEvent* ev)
{
if ( (*iter)->hasHotkey() )
{
bool found = false;
bool found{false};
uChar hotkey = (*iter)->getHotkey();
FKey key = ev->key();
@ -1261,8 +1258,8 @@ inline void FMenu::drawSeparator (int y)
//----------------------------------------------------------------------
inline void FMenu::drawMenuLine (FMenuItem* menuitem, int y)
{
FString txt = menuitem->getText();
menuText txtdata;
FString txt(menuitem->getText());
menuText txtdata{};
std::size_t txt_length = txt.getLength();
std::size_t to_char = txt_length;
FKey accel_key = menuitem->accel_key;
@ -1369,7 +1366,7 @@ inline void FMenu::drawMenuText (menuText& data)
{
// Print menu text
for (std::size_t z = 0; z < data.length; z++)
for (std::size_t z{0}; z < data.length; z++)
{
if ( ! std::iswprint(wint_t(data.text[z])) )
{

View File

@ -487,7 +487,7 @@ void FMenuBar::drawItems()
screenWidth = getDesktopWidth();
auto iter = item_list.begin();
auto last = item_list.end();
std::size_t x = 1;
std::size_t x{1};
while ( iter != last )
{
@ -506,16 +506,14 @@ void FMenuBar::drawItems()
//----------------------------------------------------------------------
inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
{
FString txt = menuitem->getText();
menuText txtdata;
std::size_t txt_length = txt.getLength();
std::size_t to_char;
std::size_t hotkeypos;
bool is_enabled = menuitem->isEnabled();
bool is_selected = menuitem->isSelected();
menuText txtdata{};
txtdata.startpos = x + 1;
txtdata.no_underline = menuitem->getFlags().no_underline;
FString txt(menuitem->getText());
std::size_t to_char{};
std::size_t txt_length = txt.getLength();
bool is_enabled = menuitem->isEnabled();
bool is_selected = menuitem->isSelected();
// Set screen attributes
setLineAttributes (menuitem);
@ -536,7 +534,9 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
else
to_char = txt_length - screenWidth - x - 1;
hotkeypos = finalcut::getHotkeyPos (txt.wc_str(), txtdata.text, txt_length);
std::size_t hotkeypos = finalcut::getHotkeyPos ( txt.wc_str()
, txtdata.text
, txt_length );
if ( hotkeypos != NOT_SET )
{
@ -600,7 +600,7 @@ inline void FMenuBar::drawMenuText (menuText& data)
{
// Print menu text
for (std::size_t z = 0; z < data.length; z++)
for (std::size_t z{0}; z < data.length; z++)
{
if ( data.startpos > screenWidth - z )
break;
@ -893,7 +893,7 @@ void FMenuBar::mouseMoveOverList (const FMouseEvent* ev)
return;
focus_changed = false;
bool mouse_over_menubar = false;
bool mouse_over_menubar{false};
auto iter = item_list.begin();
auto last = item_list.end();
int mouse_x = ev->getX();

View File

@ -188,7 +188,7 @@ void FMenuItem::unsetSelected()
//----------------------------------------------------------------------
void FMenuItem::setText (const FString& txt)
{
text = txt;
text.setString(txt);
text_length = text.getLength();
hotkey = hotKey();
@ -502,7 +502,7 @@ bool FMenuItem::isMenu (FWidget* w) const
//----------------------------------------------------------------------
FMenuList* FMenuItem::getFMenuList (FWidget& widget)
{
FMenuList* menu_list;
FMenuList* menu_list{};
if ( isMenu(&widget) )
{
@ -569,14 +569,12 @@ void FMenuItem::init (FWidget* parent)
//----------------------------------------------------------------------
uChar FMenuItem::hotKey()
{
std::size_t length;
if ( text.isEmpty() )
return 0;
length = text.getLength();
std::size_t length = text.getLength();
for (std::size_t i = 0; i < length; i++)
for (std::size_t i{0}; i < length; i++)
{
try
{
@ -632,7 +630,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
if ( win )
{
FMenuItem* win_item;
FMenuItem* win_item{};
uInt32 n = uInt32(std::distance(first, iter));
// get the dialog title
const auto& name = win->getText();

View File

@ -105,7 +105,7 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
}
else
{
for (uInt n = 0; n < num_buttons; n++)
for (uInt n{0}; n < num_buttons; n++)
delete button[n];
if ( mbox.getParentWidget() )
@ -133,10 +133,10 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
//----------------------------------------------------------------------
void FMessageBox::setHeadline (const FString& headline)
{
headline_text = headline;
headline_text.setString(headline);
setHeight(getHeight() + 2, true);
for (uInt n = 0; n < num_buttons; n++)
for (uInt n{0}; n < num_buttons; n++)
button[n]->setY (int(getHeight()) - 4, false);
std::size_t len = headline_text.getLength();
@ -148,7 +148,7 @@ void FMessageBox::setHeadline (const FString& headline)
//----------------------------------------------------------------------
void FMessageBox::setText (const FString& txt)
{
text = txt;
text.setString(txt);
calculateDimensions();
button[0]->setY (int(getHeight()) - 4, false);
@ -166,8 +166,8 @@ void FMessageBox::setText (const FString& txt)
//----------------------------------------------------------------------
void FMessageBox::adjustSize()
{
std::size_t max_width;
std::size_t max_height;
std::size_t max_width{};
std::size_t max_height{};
auto root_widget = getRootWidget();
if ( root_widget )
@ -268,7 +268,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
//----------------------------------------------------------------------
inline void FMessageBox::deallocation()
{
for (uInt n = 0; n < num_buttons; n++)
for (uInt n{0}; n < num_buttons; n++)
delete button[n];
}
@ -309,7 +309,7 @@ inline void FMessageBox::initCallbacks()
//----------------------------------------------------------------------
void FMessageBox::calculateDimensions()
{
FSize size;
FSize size{};
std::size_t headline_height{0};
text_split = text.split("\n");
max_line_width = 0;
@ -321,7 +321,7 @@ void FMessageBox::calculateDimensions()
if ( ! headline_text.isNull() )
headline_height = 2;
for (uInt i = 0; i < text_num_lines; i++)
for (uInt i{0}; i < text_num_lines; i++)
{
text_components = &text_split[0];
std::size_t len = text_components[i].getLength();
@ -366,7 +366,7 @@ void FMessageBox::draw()
setColor();
for (int i = 0; i < int(text_num_lines); i++)
for (int i{0}; i < int(text_num_lines); i++)
{
std::size_t line_length = text_components[i].getLength();
@ -384,9 +384,9 @@ void FMessageBox::draw()
//----------------------------------------------------------------------
void FMessageBox::resizeButtons()
{
std::size_t len[3], max_size;
std::size_t len[3]{}, max_size{};
for (std::size_t n = 0; n < num_buttons; n++)
for (std::size_t n{0}; n < num_buttons; n++)
{
len[n] = button[n]->getText().getLength();
@ -408,7 +408,7 @@ void FMessageBox::resizeButtons()
if ( max_size < 7 )
max_size = 7;
for (std::size_t n = 0; n < num_buttons; n++)
for (std::size_t n{0}; n < num_buttons; n++)
button[n]->setWidth(max_size + 3, false);
}
@ -416,9 +416,9 @@ void FMessageBox::resizeButtons()
void FMessageBox::adjustButtons()
{
static constexpr std::size_t gap = 4;
std::size_t btn_width = 0;
std::size_t btn_width{0};
for (std::size_t n = 0; n < num_buttons; n++)
for (std::size_t n{0}; n < num_buttons; n++)
{
if ( n == num_buttons - 1 )
btn_width += button[n]->getWidth();
@ -437,7 +437,7 @@ void FMessageBox::adjustButtons()
int btn_x = int((getWidth() - btn_width) / 2);
for (std::size_t n = 0; n < num_buttons; n++)
for (std::size_t n{0}; n < num_buttons; n++)
{
if ( n == 0 )
button[n]->setX(btn_x);

View File

@ -449,17 +449,16 @@ void FMouseGPM::drawGpmPointer()
//----------------------------------------------------------------------
int FMouseGPM::gpmEvent (bool clear)
{
int result;
int max = ( gpm_fd > stdin_no ) ? gpm_fd : stdin_no;
fd_set ifds;
struct timeval tv;
fd_set ifds{};
struct timeval tv{};
FD_ZERO(&ifds);
FD_SET(stdin_no, &ifds);
FD_SET(gpm_fd, &ifds);
tv.tv_sec = 0;
tv.tv_usec = 100000; // 100 ms
result = select (max + 1, &ifds, 0, 0, &tv);
int result = select (max + 1, &ifds, 0, 0, &tv);
if ( result > 0 && FD_ISSET(stdin_no, &ifds) )
{
@ -503,8 +502,8 @@ void FMouseX11::setRawData (FKeyboard::keybuffer& fifo_buf)
// Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data
static constexpr std::size_t len = 6;
std::size_t fifo_buf_size = sizeof(fifo_buf);
std::size_t n;
std::size_t fifo_buf_size{sizeof(fifo_buf)};
std::size_t n{};
x11_mouse[0] = fifo_buf[3];
x11_mouse[1] = fifo_buf[4];
x11_mouse[2] = fifo_buf[5];
@ -529,12 +528,9 @@ void FMouseX11::processEvent (struct timeval* time)
// Parse and interpret the X11 xterm mouse string
const auto& mouse_position = getPos();
uChar x, y;
int btn;
x = uChar(x11_mouse[1] - 0x20);
y = uChar(x11_mouse[2] - 0x20);
btn = x11_mouse[0];
uChar x = uChar(x11_mouse[1] - 0x20);
uChar y = uChar(x11_mouse[2] - 0x20);
int btn = x11_mouse[0];
new_mouse_position.setPoint (x, y);
// Fill bit field with 0
std::memset(&b_state, 0x00, sizeof(b_state));
@ -691,7 +687,7 @@ void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
std::size_t fifo_buf_size = sizeof(fifo_buf);
std::size_t len = std::strlen(fifo_buf);
std::size_t n = 3;
std::size_t n{3};
while ( n < len && n <= MOUSE_BUF_SIZE + 1 )
{
@ -719,16 +715,12 @@ void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
void FMouseSGR::processEvent (struct timeval* time)
{
const auto& mouse_position = getPos();
char* p;
int btn;
uInt16 x, y;
x = 0;
y = 0;
btn = 0;
uInt16 x{0};
uInt16 y{0};
int btn{0};
// parse the SGR mouse string
p = sgr_mouse;
char* p = sgr_mouse;
while ( *p && *p != ';' )
{
@ -930,7 +922,7 @@ void FMouseUrxvt::setRawData (FKeyboard::keybuffer& fifo_buf)
std::size_t fifo_buf_size = sizeof(fifo_buf);
std::size_t len = std::strlen(fifo_buf);
std::size_t n = 2;
std::size_t n{2};
while ( n < len && n <= MOUSE_BUF_SIZE )
{
@ -960,20 +952,14 @@ void FMouseUrxvt::processEvent (struct timeval* time)
// Parse and interpret the X11 xterm mouse string (Urxvt-Mode)
const auto& mouse_position = getPos();
char* p;
bool x_neg;
bool y_neg;
int btn;
uInt16 x, y;
x = 0;
y = 0;
btn = 0;
uInt16 x{0};
uInt16 y{0};
int btn{0};
// Parse the Urxvt mouse string
p = urxvt_mouse;
x_neg = false;
y_neg = false;
char* p = urxvt_mouse;
bool x_neg{false};
bool y_neg{false};
while ( *p && *p != ';' )
{

View File

@ -32,8 +32,8 @@ namespace finalcut
// static class attributes
bool FObject::timer_modify_lock;
FObject::TimerList* FObject::timer_list = nullptr;
const FString* fc::emptyFString::empty_string = nullptr;
FObject::TimerList* FObject::timer_list{nullptr};
const FString* fc::emptyFString::empty_string{nullptr};
//----------------------------------------------------------------------
@ -120,7 +120,7 @@ bool FObject::isChild (const FObject* obj) const
{
// Find out if obj is a child object of mine
FObject* p_obj = nullptr;
FObject* p_obj{nullptr};
while ( obj && (p_obj = obj->getParent()) )
{
@ -228,9 +228,8 @@ bool FObject::isTimeout (timeval* time, uInt64 timeout)
{
// Checks whether the specified time span (timeout in µs) has elapse
uInt64 diff_usec;
struct timeval now;
struct timeval diff;
struct timeval now{};
struct timeval diff{};
FObject::getCurrentTime(&now);
diff.tv_sec = now.tv_sec - time->tv_sec;
@ -242,7 +241,7 @@ bool FObject::isTimeout (timeval* time, uInt64 timeout)
diff.tv_usec += 1000000;
}
diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec);
uInt64 diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec);
return ( diff_usec > timeout );
}
@ -252,9 +251,9 @@ int FObject::addTimer (int interval)
// Create a timer and returns the timer identifier number
// (interval in ms)
timeval time_interval;
timeval currentTime;
int id = 1;
timeval time_interval{};
timeval currentTime{};
int id{1};
timer_modify_lock = true;
// find an unused timer id
@ -282,7 +281,7 @@ int FObject::addTimer (int interval)
time_interval.tv_usec = (interval % 1000) * 1000;
getCurrentTime (&currentTime);
timeval timeout = currentTime + time_interval;
timer_data t = { id, time_interval, timeout, this };
timer_data t{ id, time_interval, timeout, this };
// insert in list sorted by timeout
auto iter = timer_list->begin();
@ -380,8 +379,8 @@ void FObject::onUserEvent (FUserEvent*)
//----------------------------------------------------------------------
uInt FObject::processTimerEvent()
{
timeval currentTime;
uInt activated = 0;
timeval currentTime{};
uInt activated{0};
getCurrentTime (&currentTime);

View File

@ -1253,7 +1253,7 @@ inline void FOptiAttr::prevent_no_color_video_attributes ( charData*& attr
|| attr_without_color <= 0 )
return;
for (int bit = 1; bit < no_mode; bit <<= 1)
for (int bit{1}; bit < no_mode; bit <<= 1)
{
switch ( bit & attr_without_color )
{
@ -1331,7 +1331,7 @@ inline void FOptiAttr::deactivateAttributes ( charData*& term
inline void FOptiAttr::changeAttributeSGR ( charData*& term
, charData*& next )
{
bool pc_charset_usable = true;
bool pc_charset_usable{true};
if ( ! (term && next) )
return;
@ -1393,8 +1393,6 @@ inline void FOptiAttr::changeAttributeSeparately ( charData*& term
//----------------------------------------------------------------------
void FOptiAttr::change_color (charData*& term, charData*& next)
{
FColor fg, bg;
if ( ! (term && next) )
return;
@ -1411,8 +1409,8 @@ void FOptiAttr::change_color (charData*& term, charData*& next)
if ( next->bg_color != fc::Default )
next->bg_color %= max_color;
fg = next->fg_color;
bg = next->bg_color;
FColor fg = next->fg_color;
FColor bg = next->bg_color;
if ( fg == fc::Default || bg == fc::Default )
change_to_default_color (term, next, fg, bg);
@ -1449,7 +1447,7 @@ inline void FOptiAttr::change_to_default_color ( charData*& term
}
else if ( fg == fc::Default && term->fg_color != fc::Default )
{
char sgr_39[] = CSI "39m";
char sgr_39[]{ CSI "39m" };
append_sequence (sgr_39);
term->fg_color = fc::Default;
}
@ -1479,7 +1477,7 @@ inline void FOptiAttr::change_to_default_color ( charData*& term
inline void FOptiAttr::change_current_color ( charData*& term
, FColor fg, FColor bg )
{
char* color_str;
char* color_str{};
auto& AF = F_set_a_foreground.cap;
auto& AB = F_set_a_background.cap;
auto& Sf = F_set_foreground.cap;

View File

@ -485,8 +485,8 @@ void FOptiMove::check_boundaries ( int& xold, int& yold
//----------------------------------------------------------------------
char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
{
int method = 0;
int move_time = LONG_DURATION;
int method{0};
int move_time{LONG_DURATION};
check_boundaries (xold, yold, xnew, ynew);
@ -558,10 +558,9 @@ int FOptiMove::capDuration (char cap[], int affcnt)
if ( ! cap )
return LONG_DURATION;
const char* p;
float ms = 0;
float ms{0};
for (p = cap; *p; p++)
for (const char* p = cap; *p; p++)
{
// check for delay with padding character
if ( p[0] == '$' && p[1] == '<' && std::strchr(p, '>') )
@ -601,13 +600,9 @@ int FOptiMove::repeatedAppend ( const capability& o
, volatile int count
, char* dst )
{
std::size_t src_len;
std::size_t dst_len;
int total;
src_len = std::strlen(o.cap);
dst_len = ( dst != 0 ) ? std::strlen(dst) : 0;
total = 0;
std::size_t src_len = std::strlen(o.cap);
std::size_t dst_len = ( dst != 0 ) ? std::strlen(dst) : 0;
int total{0};
if ( (dst_len + uInt(count) * src_len) < BUF_SIZE - 1 )
{
@ -637,8 +632,8 @@ int FOptiMove::relativeMove ( char move[]
, int from_x, int from_y
, int to_x, int to_y )
{
int vtime = 0;
int htime = 0;
int vtime{0};
int htime{0};
if ( move )
move[0] = '\0';
@ -653,7 +648,7 @@ int FOptiMove::relativeMove ( char move[]
if ( to_x != from_x ) // horizontal move
{
char hmove[BUF_SIZE] = { };
char hmove[BUF_SIZE]{};
htime = horizontalMove (hmove, from_x, to_x);
if ( htime >= LONG_DURATION )
@ -676,7 +671,7 @@ int FOptiMove::relativeMove ( char move[]
//----------------------------------------------------------------------
inline int FOptiMove::verticalMove (char move[], int from_y, int to_y)
{
int vtime = LONG_DURATION;
int vtime{LONG_DURATION};
if ( F_row_address.cap )
{
@ -758,7 +753,7 @@ inline void FOptiMove::upMove ( char move[], int& vtime
//----------------------------------------------------------------------
inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
{
int htime = LONG_DURATION;
int htime{LONG_DURATION};
if ( F_column_address.cap )
{
@ -795,8 +790,8 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
if ( F_cursor_right.cap )
{
char str[BUF_SIZE] = { };
int htime_r = 0;
char str[BUF_SIZE]{};
int htime_r{0};
str[0] = '\0';
// try to use tab
@ -850,8 +845,8 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
if ( F_cursor_left.cap )
{
char str[BUF_SIZE] = { };
int htime_l = 0;
char str[BUF_SIZE]{};
int htime_l{0};
str[0] = '\0';
// try to use backward tab

View File

@ -164,7 +164,7 @@ void FProgressbar::drawProgressLabel()
//----------------------------------------------------------------------
void FProgressbar::drawProgressBar()
{
std::size_t len = 0;
std::size_t len{0};
print() << FPoint(1, 1);
if ( percentage > 0 && percentage <= 100 )

View File

@ -290,7 +290,7 @@ bool FRect::overlap (const FRect &r) const
FRect FRect::intersect (const FRect& r) const
{
// intersection: this ∩ r
FRect new_rect;
FRect new_rect{};
new_rect.X1 = std::max(X1, r.X1);
new_rect.Y1 = std::max(Y1, r.Y1);
new_rect.X2 = std::min(X2, r.X2);
@ -302,7 +302,7 @@ FRect FRect::intersect (const FRect& r) const
FRect FRect::combined (const FRect& r) const
{
// Union: this r
FRect new_rect;
FRect new_rect{};
new_rect.X1 = std::min(X1, r.X1);
new_rect.Y1 = std::min(Y1, r.Y1);
new_rect.X2 = std::max(X2, r.X2);

View File

@ -129,7 +129,7 @@ void FScrollbar::setPageSize (int document_size, int page_size)
//----------------------------------------------------------------------
void FScrollbar::setOrientation (fc::orientation o)
{
std::size_t nf = 0;
std::size_t nf{0};
length = ( getHeight() > getWidth() ) ? getHeight() : getWidth();
if ( o == fc::vertical && bar_orientation == fc::horizontal )
@ -158,7 +158,7 @@ void FScrollbar::setGeometry ( const FPoint& pos, const FSize& size
FWidget::setGeometry (pos, size, adjust);
std::size_t nf = 0;
std::size_t nf{0};
std::size_t w = size.getWidth();
std::size_t h = size.getHeight();
length = ( h > w ) ? h : w;
@ -257,8 +257,6 @@ void FScrollbar::drawBar()
//----------------------------------------------------------------------
void FScrollbar::onMouseDown (FMouseEvent* ev)
{
int mouse_x, mouse_y;
if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::MiddleButton )
return;
@ -266,8 +264,8 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
if ( min == max )
return;
mouse_x = ev->getX();
mouse_y = ev->getY();
int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( ev->getButton() == fc::MiddleButton )
{
@ -330,14 +328,12 @@ void FScrollbar::onMouseUp (FMouseEvent* ev)
//----------------------------------------------------------------------
void FScrollbar::onMouseMove (FMouseEvent* ev)
{
int mouse_x, mouse_y, new_scroll_type;
if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::MiddleButton )
return;
mouse_x = ev->getX();
mouse_y = ev->getY();
int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( ev->getButton() == fc::MiddleButton )
{
@ -346,7 +342,7 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
}
// Process left button
new_scroll_type = getClickedScrollType(mouse_x, mouse_y);
int new_scroll_type = getClickedScrollType(mouse_x, mouse_y);
if ( scroll_type == FScrollbar::scrollJump )
{
@ -476,10 +472,9 @@ void FScrollbar::draw()
//----------------------------------------------------------------------
void FScrollbar::drawVerticalBar()
{
int z;
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
for (z = 1; z <= slider_pos; z++)
for (int z{1}; z <= slider_pos; z++)
{
print() << FPoint(1, 1 + z);
drawVerticalBackgroundLine();
@ -490,7 +485,7 @@ void FScrollbar::drawVerticalBar()
if ( isMonochron() )
setReverse(false);
for (z = 1; z <= int(slider_length); z++) // Draw slider
for (int z{1}; z <= int(slider_length); z++) // Draw slider
{
print() << FPoint(1, 1 + slider_pos + z);
@ -505,7 +500,7 @@ void FScrollbar::drawVerticalBar()
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
for (z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++)
for (int z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++)
{
print() << FPoint(1, 1 + z);
drawVerticalBackgroundLine();
@ -535,7 +530,6 @@ inline void FScrollbar::drawVerticalBackgroundLine()
//----------------------------------------------------------------------
void FScrollbar::drawHorizontalBar()
{
int z;
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
if ( isNewFont() )
@ -543,7 +537,7 @@ void FScrollbar::drawHorizontalBar()
else
print() << FPoint(2, 1);
for (z = 0; z < slider_pos; z++)
for (int z{0}; z < slider_pos; z++)
drawHorizontalBackgroundColumn();
setColor (wc.scrollbar_bg, wc.scrollbar_fg);
@ -551,14 +545,14 @@ void FScrollbar::drawHorizontalBar()
if ( isMonochron() )
setReverse(false);
for (z = 0; z < int(slider_length); z++) // Draw slider
for (int z{0}; z < int(slider_length); z++) // Draw slider
print (' ');
if ( isMonochron() )
setReverse(true);
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
z = slider_pos + int(slider_length) + 1;
int z = slider_pos + int(slider_length) + 1;
for (; z <= int(bar_length); z++)
drawHorizontalBackgroundColumn();
@ -745,7 +739,7 @@ int FScrollbar::getSliderClickPos (int mouse_x, int mouse_y)
//----------------------------------------------------------------------
void FScrollbar::jumpToClickPos (int x, int y)
{
int new_val;
int new_val{};
if ( bar_orientation == fc::vertical )
{

View File

@ -114,7 +114,6 @@ void FScrollView::setScrollHeight (std::size_t height)
//----------------------------------------------------------------------
void FScrollView::setScrollSize (const FSize& size)
{
int xoffset_end, yoffset_end;
std::size_t width = size.getWidth();
std::size_t height = size.getHeight();
@ -139,8 +138,8 @@ void FScrollView::setScrollSize (const FSize& size)
child_print_area = viewport;
}
xoffset_end = int(getScrollWidth() - getViewportWidth());
yoffset_end = int(getScrollHeight() - getViewportHeight());
int xoffset_end = int(getScrollWidth() - getViewportWidth());
int yoffset_end = int(getScrollHeight() - getViewportHeight());
setTopPadding (1 - getScrollY());
setLeftPadding (1 - getScrollX());
setBottomPadding (1 - (yoffset_end - getScrollY()));
@ -350,8 +349,8 @@ void FScrollView::scrollTo (int x, int y)
int yoffset_end = int(getScrollHeight() - getViewportHeight());
std::size_t save_width = viewport_geometry.getWidth();
std::size_t save_height = viewport_geometry.getHeight();
bool changeX = false;
bool changeY = false;
bool changeX{false};
bool changeY{false};
x--;
y--;
@ -516,7 +515,7 @@ void FScrollView::onKeyPress (FKeyEvent* ev)
//----------------------------------------------------------------------
void FScrollView::onWheel (FWheelEvent* ev)
{
int distance = 4;
int distance{4};
switch ( ev->getWheel() )
{
@ -576,8 +575,8 @@ void FScrollView::onChildFocusIn (FFocusEvent*)
if ( ! vp_geometry.contains(widget_geometry) )
{
int x
, y
int x{}
, y{}
, vx = vp_geometry.getX()
, vy = vp_geometry.getY()
, wx = widget_geometry.getX()
@ -712,10 +711,10 @@ void FScrollView::copy2area()
if ( print_area->height <= ay + y_end )
y_end = print_area->height - ay;
for (int y = 0; y < y_end; y++) // line loop
for (int y{0}; y < y_end; y++) // line loop
{
charData* vc; // viewport character
charData* ac; // area character
charData* vc{}; // viewport character
charData* ac{}; // area character
int v_line_len = viewport->width;
int a_line_len = print_area->width + print_area->right_shadow;
vc = &viewport->text[(dy + y) * v_line_len + dx];
@ -896,7 +895,7 @@ void FScrollView::setViewportCursor()
FPoint cursor_pos ( viewport->input_cursor_x - 1
, viewport->input_cursor_y - 1 );
FPoint window_cursor_pos = getViewportCursorPos();
FPoint window_cursor_pos(getViewportCursorPos());
print_area->input_cursor_x = window_cursor_pos.getX();
print_area->input_cursor_y = window_cursor_pos.getY();
@ -911,8 +910,8 @@ void FScrollView::setViewportCursor()
void FScrollView::cb_VBarChange (FWidget*, FDataPtr)
{
FScrollbar::sType scrollType = vbar->getScrollType();
int distance = 1;
int wheel_distance = 4;
int distance{1};
int wheel_distance{4};
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
@ -963,8 +962,8 @@ void FScrollView::cb_VBarChange (FWidget*, FDataPtr)
void FScrollView::cb_HBarChange (FWidget*, FDataPtr)
{
FScrollbar::sType scrollType = hbar->getScrollType();
int distance = 1;
int wheel_distance = 4;
int distance{1};
int wheel_distance{4};
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )

View File

@ -155,7 +155,7 @@ FStatusBar::~FStatusBar() // destructor
//----------------------------------------------------------------------
void FStatusBar::setMessage (const FString& mgs)
{
text = mgs;
text.setString(mgs);
}
//----------------------------------------------------------------------
@ -187,10 +187,6 @@ void FStatusBar::hide()
//----------------------------------------------------------------------
void FStatusBar::drawMessage()
{
std::size_t termWidth;
int space_offset;
bool isLastActiveFocus, hasKeys;
if ( ! (isVisible() ) )
return;
@ -198,9 +194,10 @@ void FStatusBar::drawMessage()
return;
x = x_msg;
termWidth = getDesktopWidth();
space_offset = 1;
hasKeys = bool(! key_list.empty());
int space_offset{1};
bool hasKeys = bool(! key_list.empty());
bool isLastActiveFocus{false};
std::size_t termWidth = getDesktopWidth();
if ( hasKeys )
{
@ -352,7 +349,7 @@ void FStatusBar::onMouseDown (FMouseEvent* ev)
if ( ! key_list.empty() )
{
int X = 1;
int X{1};
auto iter = key_list.begin();
auto last = key_list.end();
@ -395,7 +392,7 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
if ( ! key_list.empty() )
{
int X = 1;
int X{1};
auto iter = key_list.begin();
auto last = key_list.end();
@ -439,8 +436,8 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
if ( mouse_down && ! key_list.empty() )
{
bool focus_changed = false;
int X = 1;
bool focus_changed{false};
int X{1};
auto iter = key_list.begin();
auto last = key_list.end();
@ -584,9 +581,7 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
{
// Draw not active key
std::size_t txt_length;
auto item = *iter;
setColor (wc.statusbar_hotkey_fg, wc.statusbar_hotkey_bg);
x++;
print (' ');
@ -595,7 +590,7 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
setColor (wc.statusbar_fg, wc.statusbar_bg);
x++;
print ('-');
txt_length = item->getText().getLength();
std::size_t txt_length = item->getText().getLength();
x += int(txt_length);
if ( x - 1 <= int(screenWidth) )
@ -603,8 +598,8 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
else
{
// Print ellipsis
print ( item->getText()
.left(txt_length + screenWidth - std::size_t(x) - 1) );
std::size_t len = txt_length + screenWidth - std::size_t(x) - 1;
print (item->getText().left(len));
print ("..");
}
@ -644,7 +639,6 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
{
// Draw active key
std::size_t txt_length;
auto item = *iter;
if ( isMonochron() )
@ -659,7 +653,7 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg);
x++;
print ('-');
txt_length = item->getText().getLength();
std::size_t txt_length = item->getText().getLength();
x += int(txt_length);
if ( x <= int(screenWidth) )

View File

@ -52,12 +52,9 @@ FString::FString (std::size_t len)
//----------------------------------------------------------------------
FString::FString (std::size_t len, wchar_t c)
{
wchar_t* ps;
wchar_t* pe;
initLength(len);
ps = string;
pe = string + len;
const wchar_t* ps = string;
wchar_t* pe = string + len;
while ( pe != ps )
*--pe = c;
@ -194,9 +191,8 @@ const FString FString::operator + (const FString& s)
//----------------------------------------------------------------------
const FString FString::operator + (const wchar_t c)
{
wchar_t s[2];
wchar_t s[2]{};
s[0] = c;
s[1] = L'\0';
FString tmp(string);
tmp._insert (length, 1, s);
return tmp;
@ -205,9 +201,8 @@ const FString FString::operator + (const wchar_t c)
//----------------------------------------------------------------------
const FString FString::operator + (const char c)
{
wchar_t s[2];
wchar_t s[2]{};
s[0] = wchar_t(c & 0xff);
s[1] = L'\0';
FString tmp(string);
tmp._insert (length, 1, s);
return tmp;
@ -247,7 +242,7 @@ FString& FString::operator << (const char c)
//----------------------------------------------------------------------
FString& FString::operator << (const sInt16 num)
{
FString numstr = FString().setNumber(num);
FString numstr(FString().setNumber(num));
_insert (length, numstr.length, numstr.string);
return *this;
}
@ -255,7 +250,7 @@ FString& FString::operator << (const sInt16 num)
//----------------------------------------------------------------------
FString& FString::operator << (const uInt16 num)
{
FString numstr = FString().setNumber(num);
FString numstr(FString().setNumber(num));
_insert (length, numstr.length, numstr.string);
return *this;
}
@ -263,7 +258,7 @@ FString& FString::operator << (const uInt16 num)
//----------------------------------------------------------------------
FString& FString::operator << (const int num)
{
FString numstr = FString().setNumber(num);
FString numstr(FString().setNumber(num));
_insert (length, numstr.length, numstr.string);
return *this;
}
@ -271,7 +266,7 @@ FString& FString::operator << (const int num)
//----------------------------------------------------------------------
FString& FString::operator << (const uInt num)
{
FString numstr = FString().setNumber(num);
FString numstr(FString().setNumber(num));
_insert (length, numstr.length, numstr.string);
return *this;
}
@ -279,7 +274,7 @@ FString& FString::operator << (const uInt num)
//----------------------------------------------------------------------
FString& FString::operator << (const long num)
{
FString numstr = FString().setNumber(num);
FString numstr(FString().setNumber(num));
_insert (length, numstr.length, numstr.string);
return *this;
}
@ -287,7 +282,7 @@ FString& FString::operator << (const long num)
//----------------------------------------------------------------------
FString& FString::operator << (const uLong num)
{
FString numstr = FString().setNumber(num);
FString numstr(FString().setNumber(num));
_insert (length, numstr.length, numstr.string);
return *this;
}
@ -295,7 +290,7 @@ FString& FString::operator << (const uLong num)
//----------------------------------------------------------------------
FString& FString::operator << (const float num)
{
FString numstr = FString().setNumber(num);
FString numstr(FString().setNumber(num));
_insert (length, numstr.length, numstr.string);
return *this;
}
@ -303,7 +298,7 @@ FString& FString::operator << (const float num)
//----------------------------------------------------------------------
FString& FString::operator << (const double num)
{
FString numstr = FString().setNumber(num);
FString numstr(FString().setNumber(num));
_insert (length, numstr.length, numstr.string);
return *this;
}
@ -311,7 +306,7 @@ FString& FString::operator << (const double num)
//----------------------------------------------------------------------
FString& FString::operator << (const lDouble num)
{
FString numstr = FString().setNumber(num);
FString numstr(FString().setNumber(num));
_insert (length, numstr.length, numstr.string);
return *this;
}
@ -419,14 +414,11 @@ const FString& FString::operator () ()
//----------------------------------------------------------------------
std::size_t FString::getUTF8length() const
{
std::size_t len;
const char* s;
if ( ! string )
return 0;
len = 0;
s = c_str();
std::size_t len = 0;
const char* s = c_str();
while ( *s )
len += std::size_t((*s++ & 0xc0) != 0x80);
@ -438,8 +430,8 @@ std::size_t FString::getUTF8length() const
FString& FString::sprintf (const FString format, ...)
{
static constexpr int BUFSIZE = 4096;
wchar_t buffer[BUFSIZE];
va_list args;
wchar_t buffer[BUFSIZE]{};
va_list args{};
if ( ! format )
{
@ -518,9 +510,8 @@ const std::string FString::toString() const
//----------------------------------------------------------------------
FString FString::toLower() const
{
wchar_t* p;
FString s(string);
p = s.string;
wchar_t* p = s.string;
if ( p )
{
@ -537,9 +528,8 @@ FString FString::toLower() const
//----------------------------------------------------------------------
FString FString::toUpper() const
{
wchar_t* p;
FString s(string);
p = s.string;
wchar_t* p = s.string;
if ( p )
{
@ -556,8 +546,7 @@ FString FString::toUpper() const
//----------------------------------------------------------------------
sInt16 FString::toShort() const
{
long num;
num = toLong();
long num = toLong();
if ( num > SHRT_MAX )
throw std::overflow_error ("overflow");
@ -571,8 +560,7 @@ sInt16 FString::toShort() const
//----------------------------------------------------------------------
uInt16 FString::toUShort() const
{
uLong num;
num = uLong(toULong());
uLong num = uLong(toULong());
if ( num > USHRT_MAX )
throw std::overflow_error ("overflow");
@ -583,8 +571,7 @@ uInt16 FString::toUShort() const
//----------------------------------------------------------------------
int FString::toInt() const
{
long num;
num = toLong();
long num = toLong();
if ( num > INT_MAX )
throw std::overflow_error ("overflow");
@ -598,8 +585,7 @@ int FString::toInt() const
//----------------------------------------------------------------------
uInt FString::toUInt() const
{
uLong num;
num = uLong(toULong());
uLong num = uLong(toULong());
if ( num > UINT_MAX )
throw std::overflow_error ("overflow");
@ -610,19 +596,12 @@ uInt FString::toUInt() const
//----------------------------------------------------------------------
long FString::toLong() const
{
bool neg;
long num;
long tenth_limit;
long tenth_limit_digit;
wchar_t* p;
FString s;
neg = false;
num = 0;
tenth_limit = LONG_MAX / 10;
tenth_limit_digit = LONG_MAX % 10;
s = trim();
p = s.string;
bool neg{false};
long num{0};
long tenth_limit{LONG_MAX / 10};
long tenth_limit_digit{LONG_MAX % 10};
FString s(trim());
const wchar_t* p = s.string;
if ( ! p )
throw std::invalid_argument ("null value");
@ -671,17 +650,11 @@ long FString::toLong() const
//----------------------------------------------------------------------
uLong FString::toULong() const
{
uLong num;
uLong tenth_limit;
uLong tenth_limit_digit;
wchar_t* p;
FString s;
num = 0;
tenth_limit = ULONG_MAX / 10;
tenth_limit_digit = ULONG_MAX % 10;
s = trim();
p = s.string;
uLong num{0};
uLong tenth_limit{ULONG_MAX / 10};
uLong tenth_limit_digit{ULONG_MAX % 10};
FString s(trim());
const wchar_t* p = s.string;
if ( ! p )
throw std::invalid_argument ("null value");
@ -721,8 +694,7 @@ uLong FString::toULong() const
//----------------------------------------------------------------------
float FString::toFloat() const
{
double num;
num = toDouble();
double num = toDouble();
if ( num > double(FLT_MAX) || num < double(-FLT_MAX) )
throw std::overflow_error ("overflow");
@ -736,16 +708,14 @@ float FString::toFloat() const
//----------------------------------------------------------------------
double FString::toDouble() const
{
wchar_t* p;
double ret;
if ( ! string )
throw std::invalid_argument ("null value");
if ( ! *string )
throw std::invalid_argument ("empty value");
ret = std::wcstod(string, &p);
wchar_t* p{};
double ret = std::wcstod(string, &p);
if ( p != 0 && *p != '\0' )
throw std::invalid_argument ("no valid floating point value");
@ -765,14 +735,13 @@ double FString::toDouble() const
//----------------------------------------------------------------------
FString FString::ltrim() const
{
wchar_t* p;
FString s(string);
// handle NULL and empty string
if ( ! (string && *string) )
return s;
p = s.string;
const wchar_t* p = s.string;
while ( std::iswspace(wint_t(*p)) )
p++;
@ -783,16 +752,14 @@ FString FString::ltrim() const
//----------------------------------------------------------------------
FString FString::rtrim() const
{
wchar_t* p;
wchar_t* last;
FString s(string);
// handle NULL and empty string
if ( ! (string && *string) )
return s;
p = s.string;
last = p + length;
wchar_t* p = s.string;
wchar_t* last = p + length;
while ( std::iswspace(wint_t(*--last)) && last > p )
s.length--;
@ -819,7 +786,6 @@ FString FString::trim() const
//----------------------------------------------------------------------
FString FString::left (std::size_t len) const
{
wchar_t* p;
FString s(string);
// handle NULL and empty string
@ -829,7 +795,7 @@ FString FString::left (std::size_t len) const
if ( len > length )
return s;
p = s.string;
wchar_t* p = s.string;
s.length = len;
*(p + len) = '\0';
return s;
@ -838,7 +804,6 @@ FString FString::left (std::size_t len) const
//----------------------------------------------------------------------
FString FString::right (std::size_t len) const
{
wchar_t* p;
FString s(string);
// handle NULL and empty string
@ -848,7 +813,7 @@ FString FString::right (std::size_t len) const
if ( len > length )
return s;
p = s.string;
const wchar_t* p = s.string;
p += (length - len);
return FString(p);
}
@ -856,8 +821,6 @@ FString FString::right (std::size_t len) const
//----------------------------------------------------------------------
FString FString::mid (std::size_t pos, std::size_t len) const
{
wchar_t* p;
wchar_t* first;
FString s(string);
// handle NULL and empty string
@ -873,8 +836,8 @@ FString FString::mid (std::size_t pos, std::size_t len) const
if ( pos > length || pos + len - 1 > length || len == 0 )
return FString(L"");
p = s.string;
first = p + pos - 1;
wchar_t* p = s.string;
wchar_t* first = p + pos - 1;
*(first + len) = '\0';
return FString(first);
}
@ -882,17 +845,15 @@ FString FString::mid (std::size_t pos, std::size_t len) const
//----------------------------------------------------------------------
FStringList FString::split (const FString& delimiter)
{
wchar_t* rest;
wchar_t* token;
FString s(string);
FStringList string_list;
FStringList string_list{};
// handle NULL and empty string
if ( ! (string && *string) )
return string_list;
rest = nullptr;
token = extractToken(&rest, s.string, delimiter.wc_str());
wchar_t* rest{nullptr};
const wchar_t* token = extractToken(&rest, s.string, delimiter.wc_str());
while ( token )
{
@ -913,11 +874,9 @@ FString& FString::setString (const FString& s)
//----------------------------------------------------------------------
FString& FString::setNumber (sInt64 num)
{
wchar_t* s;
bool neg;
bool neg{false};
wchar_t buf[30];
s = &buf[29];
wchar_t* s = &buf[29];
if ( num < 0 )
{
@ -948,10 +907,8 @@ FString& FString::setNumber (sInt64 num)
//----------------------------------------------------------------------
FString& FString::setNumber (uInt64 num)
{
wchar_t* s;
wchar_t buf[30];
s = &buf[29];
wchar_t* s = &buf[29];
*s = '\0';
do
@ -968,10 +925,8 @@ FString& FString::setNumber (uInt64 num)
//----------------------------------------------------------------------
FString& FString::setNumber (lDouble f_num, int precision)
{
wchar_t* s;
wchar_t format[20]; // = "%.<precision>Lg"
s = &format[0];
wchar_t* s = &format[0];
*s++ = L'%';
*s++ = L'.';
@ -1001,13 +956,10 @@ FString& FString::setNumber (lDouble f_num, int precision)
//----------------------------------------------------------------------
FString& FString::setFormatedNumber (sInt64 num, char separator)
{
int n;
wchar_t* s;
bool neg;
bool neg{false};
int n{0};
wchar_t buf[30];
n = 0;
s = &buf[29];
wchar_t* s = &buf[29];
if ( separator == 0 )
separator = ' ';
@ -1044,12 +996,9 @@ FString& FString::setFormatedNumber (sInt64 num, char separator)
//----------------------------------------------------------------------
FString& FString::setFormatedNumber (uInt64 num, char separator)
{
int n;
wchar_t* s;
int n{0};
wchar_t buf[30];
n = 0;
s = &buf[29];
wchar_t* s = &buf[29];
*s = L'\0';
if ( separator == 0 )
@ -1177,8 +1126,6 @@ const FString& FString::insert (const FString& s, std::size_t pos)
//----------------------------------------------------------------------
FString FString::replace (const FString& from, const FString& to)
{
wchar_t* p;
std::size_t from_length, to_length, pos;
FString s(string);
// handle NULL and empty string
@ -1191,10 +1138,10 @@ FString FString::replace (const FString& from, const FString& to)
if ( from.isEmpty() )
return s;
p = s.string;
from_length = from.getLength();
to_length = to.getLength();
pos = 0;
const wchar_t* p = s.string;
std::size_t from_length = from.getLength();
std::size_t to_length = to.getLength();
std::size_t pos{0};
while ( *p )
{
@ -1218,10 +1165,8 @@ FString FString::replace (const FString& from, const FString& to)
//----------------------------------------------------------------------
FString FString::replaceControlCodes() const
{
wchar_t* p;
FString s(string);
p = s.string;
wchar_t* p = s.string;
if ( p )
{
@ -1252,18 +1197,16 @@ FString FString::replaceControlCodes() const
//----------------------------------------------------------------------
FString FString::expandTabs (int tabstop) const
{
uLong last;
FStringList tab_split;
FString instr(string);
FString outstr;
FString outstr{};
if ( tabstop <= 0 )
return instr;
tab_split = instr.split("\t");
last = tab_split.size();
FStringList tab_split = instr.split("\t");
uLong last = tab_split.size();
for (std::size_t i = 0; i < last; i++)
for (std::size_t i{0}; i < last; i++)
{
std::size_t len = tab_split[i].getLength();
std::size_t tab_len = std::size_t(tabstop);
@ -1280,14 +1223,13 @@ FString FString::expandTabs (int tabstop) const
//----------------------------------------------------------------------
FString FString::removeDel() const
{
wchar_t* p;
FString s(string);
p = s.string;
const wchar_t* p = s.string;
if ( p )
{
uInt i = 0;
uInt d = 0;
uInt i{0};
uInt d{0};
while ( *p )
{
@ -1319,9 +1261,8 @@ FString FString::removeDel() const
//----------------------------------------------------------------------
FString FString::removeBackspaces() const
{
wchar_t* p;
FString s(string);
p = s.string;
const wchar_t* p = s.string;
if ( p )
{
@ -1502,7 +1443,7 @@ inline void FString::_insert ( std::size_t pos
}
else
{
std::size_t x;
std::size_t x{};
if ( length + len <= capacity() )
{
@ -1517,9 +1458,9 @@ inline void FString::_insert ( std::size_t pos
}
else
{
wchar_t* sptr;
// output string > bufsize
bufsize = FWDBUFFER + length + len + 1;
wchar_t* sptr{};
try
{
@ -1531,7 +1472,7 @@ inline void FString::_insert ( std::size_t pos
return;
}
std::size_t y = 0;
std::size_t y{0};
for (x = 0; x < pos; x++) // left side
sptr[y++] = string[x];
@ -1562,8 +1503,8 @@ inline void FString::_remove (std::size_t pos, std::size_t len)
}
else
{
wchar_t* sptr;
bufsize = length + 1 - len + FWDBUFFER;
wchar_t* sptr{};
try
{
@ -1575,7 +1516,7 @@ inline void FString::_remove (std::size_t pos, std::size_t len)
return;
}
std::size_t x, y = 0;
std::size_t x{}, y{};
for (x = 0; x < pos; x++) // left side
sptr[y++] = string[x];
@ -1592,11 +1533,6 @@ inline void FString::_remove (std::size_t pos, std::size_t len)
//----------------------------------------------------------------------
inline char* FString::wc_to_c_str (const wchar_t s[]) const
{
int mblength
, size
, dest_size;
const wchar_t* src;
if ( ! s ) // handle NULL string
return 0;
@ -1619,9 +1555,9 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
if ( c_string )
delete[](c_string);
size = int(std::wcslen(s)) + 1;
dest_size = size * int(CHAR_SIZE);
src = s;
int size = int(std::wcslen(s)) + 1;
int dest_size = size * int(CHAR_SIZE);
const wchar_t* src = s;
std::mbstate_t state;
std::memset (&state, '\0', sizeof(mbstate_t));
@ -1638,7 +1574,8 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
return 0;
}
mblength = int(std::wcsrtombs (c_string, &src, std::size_t(dest_size), &state));
int mblength = \
int(std::wcsrtombs (c_string, &src, std::size_t(dest_size), &state));
if ( mblength == -1 && errno != EILSEQ )
{
@ -1653,12 +1590,6 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
//----------------------------------------------------------------------
inline wchar_t* FString::c_to_wc_str (const char s[]) const
{
int wclength
, size
, dest_size;
const char* src;
wchar_t* dest;
if ( ! s ) // handle NULL string
return 0;
@ -1676,9 +1607,10 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const
}
}
size = int(std::strlen(s)) + 1;
dest_size = size * int(CHAR_SIZE);
src = s;
int size = int(std::strlen(s)) + 1;
int dest_size = size * int(CHAR_SIZE);
const char* src = s;
wchar_t* dest{};
std::mbstate_t state;
std::memset (&state, '\0', sizeof(mbstate_t));
@ -1694,7 +1626,8 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const
return 0;
}
wclength = int(std::mbsrtowcs (dest, &src, std::size_t(dest_size), &state));
int wclength = \
int(std::mbsrtowcs (dest, &src, std::size_t(dest_size), &state));
if ( wclength == -1 )
{
@ -1724,8 +1657,7 @@ inline wchar_t* FString::extractToken ( wchar_t* rest[]
, const wchar_t s[]
, const wchar_t delim[] )
{
wchar_t* token;
token = ( s ) ? const_cast<wchar_t*>(s) : *rest;
wchar_t* token = ( s ) ? const_cast<wchar_t*>(s) : *rest;
if ( ! token )
return 0;
@ -1841,11 +1773,9 @@ std::ostream& operator << (std::ostream& outstr, const FString& s)
//----------------------------------------------------------------------
std::istream& operator >> (std::istream& instr, FString& s)
{
const wchar_t* wc_str;
char buf[FString::INPBUFFER + 1];
char buf[FString::INPBUFFER + 1]{};
instr.getline (buf, FString::INPBUFFER);
wc_str = s.c_to_wc_str(buf);
const wchar_t* wc_str = s.c_to_wc_str(buf);
if ( wc_str )
{
@ -1868,7 +1798,7 @@ std::wostream& operator << (std::wostream& outstr, const FString& s)
//----------------------------------------------------------------------
std::wistream& operator >> (std::wistream& instr, FString& s)
{
wchar_t buf[FString::INPBUFFER + 1];
wchar_t buf[FString::INPBUFFER + 1]{};
instr.getline (buf, FString::INPBUFFER);
s._assign (buf);
return instr;

View File

@ -141,8 +141,8 @@ void FSwitch::drawCheckButton()
//----------------------------------------------------------------------
inline void FSwitch::drawChecked()
{
wchar_t on[6] = L" On ";
wchar_t off[6] = L" Off ";
wchar_t on[6]{L" On "};
wchar_t off[6]{L" Off "};
if ( hasFocus() && ! button_pressed )
{
@ -190,8 +190,8 @@ inline void FSwitch::drawChecked()
//----------------------------------------------------------------------
inline void FSwitch::drawUnchecked()
{
wchar_t on[6] = L" On ";
wchar_t off[6] = L" Off ";
wchar_t on[6]{L" On "};
wchar_t off[6]{L" Off "};
setColor (wc.button_inactive_fg, wc.button_inactive_bg);

View File

@ -61,39 +61,39 @@ namespace finalcut
{
// global FTerm object
static FTerm* init_term_object = nullptr;
static FTerm* init_term_object{nullptr};
// global init state
static bool term_initialized = false;
static bool term_initialized{false};
// function pointer
int (*FTerm::Fputchar)(int);
// static class attributes
FTerm::initializationValues FTerm::init_values;
FTermData* FTerm::data = nullptr;
FSystem* FTerm::fsys = nullptr;
FOptiMove* FTerm::opti_move = nullptr;
FOptiAttr* FTerm::opti_attr = nullptr;
FTermDetection* FTerm::term_detection = nullptr;
FTermXTerminal* FTerm::xterm = nullptr;
FKeyboard* FTerm::keyboard = nullptr;
FMouseControl* FTerm::mouse = nullptr;
FTerm::initializationValues FTerm::init_values{};
FTermData* FTerm::data {nullptr};
FSystem* FTerm::fsys {nullptr};
FOptiMove* FTerm::opti_move {nullptr};
FOptiAttr* FTerm::opti_attr {nullptr};
FTermDetection* FTerm::term_detection{nullptr};
FTermXTerminal* FTerm::xterm {nullptr};
FKeyboard* FTerm::keyboard {nullptr};
FMouseControl* FTerm::mouse {nullptr};
#if defined(UNIT_TEST)
FTermLinux* FTerm::linux = nullptr;
FTermFreeBSD* FTerm::freebsd = nullptr;
FTermOpenBSD* FTerm::openbsd = nullptr;
FTermLinux* FTerm::linux {nullptr};
FTermFreeBSD* FTerm::freebsd {nullptr};
FTermOpenBSD* FTerm::openbsd {nullptr};
#elif defined(__linux__)
FTermLinux* FTerm::linux = nullptr;
FTermLinux* FTerm::linux {nullptr};
#elif defined(__FreeBSD__) || defined(__DragonFly__)
FTermFreeBSD* FTerm::freebsd = nullptr;
FTermFreeBSD* FTerm::freebsd {nullptr};
#elif defined(__NetBSD__) || defined(__OpenBSD__)
FTermOpenBSD* FTerm::openbsd = nullptr;
FTermOpenBSD* FTerm::openbsd {nullptr};
#endif
#if DEBUG
FTermDebugData* FTerm::debug_data = nullptr;
FTermDebugData* FTerm::debug_data {nullptr};
#endif
// function prototypes
@ -743,12 +743,11 @@ bool FTerm::setNewFont()
//----------------------------------------------------------------------
bool FTerm::setOldFont()
{
bool retval = false;
bool retval{false};
if ( ! (data->isNewFont() || data->isVGAFont()) )
return false;
retval = false;
data->setNewFont(false);
data->setVGAFont(false);
@ -812,7 +811,7 @@ int FTerm::openConsole()
if ( ! *termfilename || ! fsys )
return 0;
for (std::size_t i = 0; terminal_devices[i] != 0; i++)
for (std::size_t i{0}; terminal_devices[i] != 0; i++)
{
fd = fsys->open(terminal_devices[i], O_RDWR, 0);
data->setTTYFileDescriptor(fd);
@ -831,7 +830,7 @@ int FTerm::closeConsole()
data = FTerm::getFTermData();
int fd = data->getTTYFileDescriptor();
int ret = -1;
int ret{-1};
if ( fd < 0 ) // console is already closed
return 0;
@ -863,7 +862,7 @@ char* FTerm::cursorsVisibilityString (bool enable)
{
// Hides or shows the input cursor on the terminal
char* visibility_str = nullptr;
char* visibility_str{nullptr};
if ( data->isCursorHidden() == enable )
return 0;
@ -894,9 +893,9 @@ void FTerm::detectTermSize()
if ( ! data )
data = FTerm::getFTermData();
struct winsize win_size;
struct winsize win_size{};
auto& term_geometry = data->getTermGeometry();
int ret;
int ret{};
errno = 0;
do
@ -1110,7 +1109,7 @@ void FTerm::setEncoding (fc::encoding enc)
{
if ( enc == fc::VT100 || enc == fc::PC )
{
char* empty = nullptr;
char* empty{nullptr};
opti_move->set_tabular (empty);
}
else
@ -1156,7 +1155,7 @@ wchar_t FTerm::charEncode (wchar_t c, fc::encoding enc)
{
wchar_t ch_enc = c;
for (std::size_t i = 0; i <= fc::lastCharItem; i++)
for (std::size_t i{0}; i <= fc::lastCharItem; i++)
{
if ( fc::character[i][fc::UTF8] == uInt(c) )
{
@ -1178,7 +1177,7 @@ wchar_t FTerm::cp437_to_unicode (uChar c)
constexpr std::size_t UNICODE = 1;
wchar_t ucs = wchar_t(c);
for (std::size_t i = 0; i <= fc::lastCP437Item; i++)
for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
{
if ( fc::cp437_to_ucs[i][CP437] == c ) // found
{
@ -1197,7 +1196,7 @@ uChar FTerm::unicode_to_cp437 (wchar_t ucs)
constexpr std::size_t UNICODE = 1;
uChar c = '?';
for (std::size_t i = 0; i <= fc::lastCP437Item; i++)
for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
{
if ( fc::cp437_to_ucs[i][UNICODE] == ucs ) // found
{
@ -1239,11 +1238,10 @@ bool FTerm::scrollTermReverse()
void FTerm::putstringf (const char format[], ...)
{
assert ( format != 0 );
char buf[512];
char* str;
va_list args;
char buf[512]{};
va_list args{};
str = buf;
char* str = buf;
va_start (args, format);
vsnprintf (str, sizeof(buf), format, args);
va_end (args);
@ -1379,7 +1377,7 @@ void FTerm::init_global_values (bool disable_alt_screen)
//----------------------------------------------------------------------
void FTerm::init_terminal_device_path()
{
char termfilename[256] = { };
char termfilename[256]{};
int stdout_no = FTermios::getStdOut();
if ( ttyname_r(stdout_no, termfilename, sizeof(termfilename)) )
@ -1422,7 +1420,7 @@ void FTerm::init_alt_charset()
if ( TCAP(fc::t_acs_chars) )
{
for (std::size_t n = 0; TCAP(fc::t_acs_chars)[n]; n += 2)
for (std::size_t n{0}; TCAP(fc::t_acs_chars)[n]; n += 2)
{
// insert the VT100 key/value pairs into a map
uChar p1 = uChar(TCAP(fc::t_acs_chars)[n]);
@ -1438,7 +1436,7 @@ void FTerm::init_alt_charset()
};
// Update array 'character' with discovered VT100 pairs
for (std::size_t n = 0; n <= fc::lastKeyItem; n++ )
for (std::size_t n{0}; n <= fc::lastKeyItem; n++ )
{
uChar keyChar = uChar(fc::vt100_key_to_utf8[n][vt100_key]);
uChar altChar = uChar(vt100_alt_char[keyChar]);
@ -1463,7 +1461,7 @@ void FTerm::init_alt_charset()
//----------------------------------------------------------------------
void FTerm::init_pc_charset()
{
bool reinit = false;
bool reinit{false};
// rxvt does not support pc charset
if ( isRxvtTerminal() || isUrxvtTerminal() )
@ -1527,7 +1525,7 @@ void FTerm::init_cygwin_charmap()
return;
// PC encoding changes
for (std::size_t i = 0; i <= fc::lastCharItem; i++ )
for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
{
if ( fc::character[i][fc::UTF8] == fc::BlackUpPointingTriangle ) // ▲
fc::character[i][fc::PC] = 0x18;
@ -1581,7 +1579,7 @@ void FTerm::init_teraterm_charmap()
if ( ! isTeraTerm() )
return;
for (std::size_t i = 0; i <= fc::lastCharItem; i++ )
for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
if ( fc::character[i][fc::PC] < 0x20 )
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
}
@ -1709,14 +1707,12 @@ void FTerm::init_locale()
{
// Init current locale
char* locale_name;
char* locale_xterm;
const char* termtype = data->getTermType();
locale_name = std::setlocale (LC_ALL, "");
const char* locale_name = std::setlocale (LC_ALL, "");
std::setlocale (LC_NUMERIC, "");
// Get XTERM_LOCALE
locale_xterm = std::getenv("XTERM_LOCALE");
const char* locale_xterm = std::getenv("XTERM_LOCALE");
// set LC_ALL to XTERM_LOCALE
if ( locale_xterm )
@ -1761,7 +1757,7 @@ void FTerm::init_encoding()
{
// detect encoding and set the Fputchar function pointer
bool force_vt100 = false; // VT100 line drawing (G1 character set)
bool force_vt100{false}; // VT100 line drawing (G1 character set)
init_encoding_set();
if ( isRxvtTerminal() && ! isUrxvtTerminal() )
@ -1885,7 +1881,7 @@ void FTerm::init_tab_quirks()
if ( enc == fc::VT100 || enc == fc::PC )
{
char* empty = nullptr;
char* empty{nullptr};
opti_move->set_tabular (empty);
}
}
@ -1991,7 +1987,7 @@ char* FTerm::enableCursorString()
// Returns the cursor enable string
static constexpr std::size_t SIZE = 32;
static char enable_str[SIZE] = { };
static char enable_str[SIZE]{};
const auto& vs = TCAP(fc::t_cursor_visible);
const auto& ve = TCAP(fc::t_cursor_normal);
@ -2043,8 +2039,8 @@ void FTerm::enableMouse()
if ( ! init_values.mouse_support )
return;
bool gpm_mouse = false;
bool xterm_mouse = false;
bool gpm_mouse{false};
bool xterm_mouse{false};
#if defined(__linux__)
if ( isLinuxTerm() && openConsole() == 0 )

View File

@ -44,8 +44,8 @@ FTermBuffer::~FTermBuffer() // destructor
int FTermBuffer::writef (const FString format, ...)
{
static constexpr int BUFSIZE = 4096;
wchar_t buffer[BUFSIZE];
va_list args;
wchar_t buffer[BUFSIZE]{};
va_list args{};
if ( format.isEmpty() )
return 0;
@ -62,7 +62,7 @@ int FTermBuffer::writef (const FString format, ...)
int FTermBuffer::write (const FString& s)
{
assert ( ! s.isNull() );
int len = 0;
int len{0};
const wchar_t* p = s.wc_str();
if ( p )
@ -88,8 +88,7 @@ int FTermBuffer::write (const FString& s)
//----------------------------------------------------------------------
int FTermBuffer::write (wchar_t c)
{
charData nc; // next character
nc = FVTerm::getAttribute();
charData nc = FVTerm::getAttribute(); // next character
nc.code = c;
nc.attr.bit.no_changes = false;
nc.attr.bit.printed = false;

View File

@ -36,19 +36,19 @@ namespace finalcut
{
// static class attributes
bool FTermcap::background_color_erase = false;
bool FTermcap::can_change_color_palette = false;
bool FTermcap::automatic_left_margin = false;
bool FTermcap::automatic_right_margin = false;
bool FTermcap::eat_nl_glitch = false;
bool FTermcap::ansi_default_color = false;
bool FTermcap::osc_support = false;
bool FTermcap::no_utf8_acs_chars = false;
int FTermcap::max_color = 1;
int FTermcap::tabstop = 8;
int FTermcap::attr_without_color = 0;
FTermData* FTermcap::fterm_data = nullptr;
FTermDetection* FTermcap::term_detection = nullptr;
bool FTermcap::background_color_erase {false};
bool FTermcap::can_change_color_palette{false};
bool FTermcap::automatic_left_margin {false};
bool FTermcap::automatic_right_margin {false};
bool FTermcap::eat_nl_glitch {false};
bool FTermcap::ansi_default_color {false};
bool FTermcap::osc_support {false};
bool FTermcap::no_utf8_acs_chars {false};
int FTermcap::max_color {1};
int FTermcap::tabstop {8};
int FTermcap::attr_without_color {0};
FTermData* FTermcap::fterm_data {nullptr};
FTermDetection* FTermcap::term_detection {nullptr};
//----------------------------------------------------------------------
@ -77,11 +77,11 @@ void FTermcap::init()
//----------------------------------------------------------------------
void FTermcap::termcap()
{
std::vector<std::string> terminals;
std::vector<std::string> terminals{};
static constexpr int success = 1;
static constexpr int uninitialized = -2;
static char term_buffer[2048];
static char string_buf[2048];
static char term_buffer[2048]{};
static char string_buf[2048]{};
char* buffer = string_buf;
int status = uninitialized;
bool color256 = term_detection->canDisplay256Colors();
@ -221,7 +221,7 @@ void FTermcap::termcapStrings (char*& buffer)
// Get termcap strings
// Read termcap output strings
for (std::size_t i = 0; strings[i].tname[0] != 0; i++)
for (std::size_t i{0}; strings[i].tname[0] != 0; i++)
strings[i].string = tgetstr(strings[i].tname, &buffer);
}
@ -230,7 +230,7 @@ void FTermcap::termcapKeys (char*& buffer)
{
// Read termcap key strings
for (std::size_t i = 0; fc::Fkey[i].tname[0] != 0; i++)
for (std::size_t i{0}; fc::Fkey[i].tname[0] != 0; i++)
{
fc::Fkey[i].string = tgetstr(fc::Fkey[i].tname, &buffer);
@ -290,7 +290,7 @@ void FTermcap::termcapKeysVt100 (char*& buffer)
|| ( TCAP(fc::t_cursor_up)
&& (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
{
for (std::size_t i = 0; fc::Fkey[i].tname[0] != 0; i++)
for (std::size_t 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

View File

@ -34,8 +34,8 @@ namespace finalcut
{
// static class attributes
FTermData* FTermcapQuirks::fterm_data = nullptr;
FTermDetection* FTermcapQuirks::term_detection = nullptr;
FTermData* FTermcapQuirks::fterm_data {nullptr};
FTermDetection* FTermcapQuirks::term_detection {nullptr};
//----------------------------------------------------------------------
@ -402,7 +402,7 @@ void FTermcapQuirks::sunConsole()
C_STR(CSI "%p1%dD");
// Sun Microsystems workstation console keys
for (std::size_t i = 0; fc::Fkey[i].tname[0] != 0; i++)
for (std::size_t i{0}; fc::Fkey[i].tname[0] != 0; i++)
{
if ( std::strncmp(fc::Fkey[i].tname, "K2", 2) == 0 )
fc::Fkey[i].string = C_STR(CSI "218z"); // center of keypad

View File

@ -31,8 +31,8 @@ namespace finalcut
#if DEBUG
// static class attributes
FTermData* FTermDebugData::data = nullptr;
FTermDetection* FTermDebugData::term_detection = nullptr;
FTermData* FTermDebugData::data {nullptr};
FTermDetection* FTermDebugData::term_detection {nullptr};
//----------------------------------------------------------------------
// class FClassName

View File

@ -46,25 +46,24 @@ namespace finalcut
{
// static class attributes
FTermDetection::terminalType FTermDetection::terminal_type = \
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
FTermDetection::colorEnv FTermDetection::color_env;
FTermDetection::secondaryDA FTermDetection::secondary_da;
FTermData* FTermDetection::fterm_data = nullptr;
FSystem* FTermDetection::fsystem = nullptr;
char FTermDetection::termtype[256] = { };
char FTermDetection::ttytypename[256] = { };
bool FTermDetection::decscusr_support;
bool FTermDetection::terminal_detection;
bool FTermDetection::color256;
const FString* FTermDetection::answer_back = nullptr;
const FString* FTermDetection::sec_da = nullptr;
int FTermDetection::gnome_terminal_id;
FTermDetection::terminalType FTermDetection::terminal_type{};
FTermDetection::colorEnv FTermDetection::color_env{};
FTermDetection::secondaryDA FTermDetection::secondary_da{};
FTermData* FTermDetection::fterm_data{nullptr};
FSystem* FTermDetection::fsystem{nullptr};
char FTermDetection::termtype[256]{};
char FTermDetection::ttytypename[256]{};
bool FTermDetection::decscusr_support{};
bool FTermDetection::terminal_detection{};
bool FTermDetection::color256{};
const FString* FTermDetection::answer_back{nullptr};
const FString* FTermDetection::sec_da{nullptr};
int FTermDetection::gnome_terminal_id{};
#if DEBUG
char FTermDetection::termtype_256color[256] = { };
char FTermDetection::termtype_Answerback[256] = { };
char FTermDetection::termtype_SecDA[256] = { };
char FTermDetection::termtype_256color[256]{};
char FTermDetection::termtype_Answerback[256]{};
char FTermDetection::termtype_SecDA[256]{};
#endif // DEBUG
@ -87,10 +86,6 @@ FTermDetection::FTermDetection()
// a.b.c = a * 100 + b * 100 + c
gnome_terminal_id = 0;
// Initialize the structs
color_env.setDefault();
secondary_da.setDefault();
// Set default ttytype file
std::strncpy (ttytypename, C_STR("/etc/ttytype"), sizeof(ttytypename));
ttytypename[sizeof(ttytypename) - 1] = '\0';
@ -208,20 +203,17 @@ bool FTermDetection::getTTYtype()
else
term_basename++;
std::FILE *fp;
std::FILE* fp{};
char str[BUFSIZ]{};
if ( fsystem && (fp = fsystem->fopen(ttytypename, "r")) != 0 )
{
char* p;
char str[BUFSIZ];
// Read and parse the file
while ( fgets(str, sizeof(str) - 1, fp) != 0 )
{
char* name;
char* type;
type = name = nullptr; // nullptr == not found
p = str;
const char* type{nullptr}; // nullptr == not found
const char* name{nullptr};
char* p = str;
while ( *p )
{
@ -271,7 +263,7 @@ bool FTermDetection::getTTYSFileEntry()
if ( ttys_entryt )
{
char* type = ttys_entryt->ty_type;
const char* type = ttys_entryt->ty_type;
if ( type != 0 )
{
@ -328,7 +320,7 @@ void FTermDetection::termtypeAnalysis()
if ( std::strncmp(termtype, "screen", 6) == 0 )
{
terminal_type.screen = true;
char* tmux = std::getenv("TMUX");
const char* tmux = std::getenv("TMUX");
if ( tmux && std::strlen(tmux) != 0 )
terminal_type.tmux = true;
@ -349,7 +341,7 @@ void FTermDetection::detectTerminal()
{
// Terminal detection
char* new_termtype = nullptr;
char* new_termtype{nullptr};
if ( terminal_detection )
{
@ -397,7 +389,7 @@ void FTermDetection::detectTerminal()
//----------------------------------------------------------------------
char* FTermDetection::init_256colorTerminal()
{
char* new_termtype = nullptr;
char* new_termtype{nullptr};
if ( get256colorEnvString() )
color256 = true;
@ -460,7 +452,7 @@ bool FTermDetection::get256colorEnvString()
//----------------------------------------------------------------------
char* FTermDetection::termtype_256color_quirks()
{
char* new_termtype = nullptr;
char* new_termtype{nullptr};
if ( ! color256 )
return new_termtype;
@ -549,13 +541,12 @@ char* FTermDetection::determineMaxColor (char current_termtype[])
//----------------------------------------------------------------------
const FString FTermDetection::getXTermColorName (int color)
{
FString color_str("");
fd_set ifds;
struct timeval tv;
FString color_str{""};
fd_set ifds{};
struct timeval tv{};
int stdin_no = FTermios::getStdIn();
char temp[512] = { };
char temp[512]{};
std::fprintf (stdout, OSC "4;%d;?" BEL, color); // get color
std::fflush(stdout);
@ -632,11 +623,10 @@ char* FTermDetection::parseAnswerbackMsg (char current_termtype[])
//----------------------------------------------------------------------
const FString FTermDetection::getAnswerbackMsg()
{
FString answerback = "";
fd_set ifds;
struct timeval tv;
char temp[10] = { };
FString answerback{""};
fd_set ifds{};
struct timeval tv{};
char temp[10]{};
int stdin_no = FTermios::getStdIn();
std::putchar (ENQ[0]); // Send enquiry character
@ -677,7 +667,7 @@ char* FTermDetection::parseSecDA (char current_termtype[])
return current_termtype;
// remove the first 3 bytes ("\033[>")
FString temp = sec_da->right(sec_da->getLength() - 3);
FString temp(sec_da->right(sec_da->getLength() - 3));
// remove the last byte ("c")
temp.remove(temp.getLength() - 1, 1);
// split into components
@ -736,15 +726,15 @@ int FTermDetection::str2int (const FString& s)
//----------------------------------------------------------------------
const FString FTermDetection::getSecDA()
{
FString sec_da_str = "";
FString sec_da_str{""};
int a = 0
, b = 0
, c = 0
, stdin_no = FTermios::getStdIn()
, stdout_no = FTermios::getStdOut();
fd_set ifds;
struct timeval tv;
int a{0}
, b{0}
, c{0}
, stdin_no{FTermios::getStdIn()}
, stdout_no{FTermios::getStdOut()};
fd_set ifds{};
struct timeval tv{};
// Get the secondary device attributes
ssize_t ret = write(stdout_no, SECDA, std::strlen(SECDA));
@ -904,9 +894,8 @@ inline char* FTermDetection::secDA_Analysis_32 (char[])
{
// Terminal ID 32 - Tera Term
char* new_termtype;
terminal_type.tera_term = true;
new_termtype = C_STR("teraterm");
char* new_termtype = C_STR("teraterm");
return new_termtype;
}
@ -925,9 +914,8 @@ inline char* FTermDetection::secDA_Analysis_67 (char[])
{
// Terminal ID 67 - cygwin
char* new_termtype;
terminal_type.cygwin = true;
new_termtype = C_STR("cygwin");
char* new_termtype = C_STR("cygwin");
std::fflush(stdout);
return new_termtype;
}
@ -937,10 +925,9 @@ inline char* FTermDetection::secDA_Analysis_77 (char[])
{
// Terminal ID 77 - mintty
char* new_termtype;
terminal_type.mintty = true;
decscusr_support = true;
new_termtype = C_STR("xterm-256color");
char* new_termtype = C_STR("xterm-256color");
std::fflush(stdout);
return new_termtype;
}

View File

@ -32,12 +32,12 @@ namespace finalcut
// static class attributes
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
uInt FTermFreeBSD::bsd_alt_keymap = 0;
FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style = fc::normal_cursor;
bool FTermFreeBSD::change_cursorstyle = true;
bool FTermFreeBSD::meta_sends_escape = true;
FSystem* FTermFreeBSD::fsystem = nullptr;
FTermData* FTermFreeBSD::fterm_data = nullptr;
uInt FTermFreeBSD::bsd_alt_keymap{0};
FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style{fc::normal_cursor};
bool FTermFreeBSD::change_cursorstyle{true};
bool FTermFreeBSD::meta_sends_escape{true};
FSystem* FTermFreeBSD::fsystem{nullptr};
FTermData* FTermFreeBSD::fterm_data{nullptr};
#endif
@ -156,7 +156,7 @@ void FTermFreeBSD::initCharMap()
if ( ! isFreeBSDConsole() )
return;
for (std::size_t i = 0; i <= fc::lastCharItem; i++)
for (std::size_t i{0}; i <= fc::lastCharItem; i++)
if ( fc::character[i][fc::PC] < 0x1c )
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
}
@ -183,7 +183,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey()
// Saving the current mapping for the alt key
static constexpr int left_alt = 0x38;
int ret = -1;
int ret{-1};
keymap_t keymap{};
if ( fsystem )
@ -203,7 +203,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
// Remapping the alt key
static constexpr int left_alt = 0x38;
int ret = -1;
int ret{-1};
keymap_t keymap{};
if ( fsystem )

View File

@ -71,7 +71,7 @@ void FTermios::init()
//----------------------------------------------------------------------
termios FTermios::getTTY()
{
struct termios t;
struct termios t{};
tcgetattr (stdin_no, &t);
return t;
}
@ -100,7 +100,7 @@ void FTermios::restoreTTYsettings()
void FTermios::setHardwareEcho()
{
// Info under: man 3 termios
struct termios t;
struct termios t{};
tcgetattr (stdin_no, &t);
// local mode
@ -120,7 +120,7 @@ void FTermios::setHardwareEcho()
void FTermios::unsetHardwareEcho()
{
// Info under: man 3 termios
struct termios t;
struct termios t{};
tcgetattr (stdin_no, &t);
// local mode
@ -139,7 +139,7 @@ void FTermios::unsetHardwareEcho()
//----------------------------------------------------------------------
void FTermios::setCaptureSendCharacters()
{
struct termios t;
struct termios t{};
tcgetattr (stdin_no, &t);
t.c_lflag &= uInt(~(ICANON | ECHO));
t.c_cc[VTIME] = 1; // Timeout in deciseconds
@ -150,7 +150,7 @@ void FTermios::setCaptureSendCharacters()
//----------------------------------------------------------------------
void FTermios::unsetCaptureSendCharacters()
{
struct termios t;
struct termios t{};
tcgetattr (stdin_no, &t);
t.c_lflag |= uInt(ICANON | ECHO);
t.c_cc[VTIME] = 0; // Timeout in deciseconds
@ -166,7 +166,7 @@ bool FTermios::setRawMode (bool enable)
return raw_mode;
// Info under: man 3 termios
struct termios t;
struct termios t{};
tcgetattr (stdin_no, &t);
if ( enable )

View File

@ -43,21 +43,21 @@ namespace finalcut
// static class attributes
#if defined(__linux__)
FTermLinux::modifier_key FTermLinux::mod_key;
console_font_op FTermLinux::screen_font;
unimapdesc FTermLinux::screen_unicode_map;
FTermLinux::modifier_key FTermLinux::mod_key{};
console_font_op FTermLinux::screen_font{};
unimapdesc FTermLinux::screen_unicode_map{};
bool FTermLinux::new_font;
bool FTermLinux::vga_font;
bool FTermLinux::has_saved_palette = false;
bool FTermLinux::new_font{false};
bool FTermLinux::vga_font{false};
bool FTermLinux::has_saved_palette{false};
FTermData* FTermLinux::fterm_data = nullptr;
FSystem* FTermLinux::fsystem = nullptr;
FTermDetection* FTermLinux::term_detection = nullptr;
fc::linuxConsoleCursorStyle FTermLinux::linux_console_cursor_style;
FTermData* FTermLinux::fterm_data{nullptr};
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{};
int FTermLinux::framebuffer_bpp = -1;
int FTermLinux::framebuffer_bpp{-1};
#endif // defined(__linux__)
@ -93,7 +93,7 @@ char* FTermLinux::getCursorStyleString()
{
// Gets the current cursor style string of the Linux console
static char buf[16] = { };
static char buf[16]{};
std::fill (std::begin(buf), std::end(buf), '\0');
std::sprintf (buf, CSI "?%dc", getCursorStyle());
return buf;
@ -157,7 +157,7 @@ bool FTermLinux::isLinuxConsole()
if ( ! fsystem )
fsystem = FTerm::getFSystem();
char arg = 0;
char arg{0};
int fd_tty = FTerm::getTTYFileDescriptor();
// Get keyboard type an compare
@ -232,7 +232,7 @@ void FTermLinux::initCharMap()
if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries )
{
for (std::size_t i = 0; i <= fc::lastCharItem; i++ )
for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
{
auto ucs = wchar_t(fc::character[i][fc::UTF8]);
sInt16 fontpos = getFontPos(ucs);
@ -507,10 +507,10 @@ FKey FTermLinux::modifierKeyCorrection (const FKey& key_id)
//----------------------------------------------------------------------
int FTermLinux::getFramebuffer_bpp()
{
int fd = -1;
int fd{-1};
const char* fb = C_STR("/dev/fb/0");
struct fb_var_screeninfo fb_var;
struct fb_fix_screeninfo fb_fix;
struct fb_var_screeninfo fb_var{};
struct fb_fix_screeninfo fb_fix{};
if ( ! fsystem )
fsystem = FTerm::getFSystem();
@ -543,9 +543,9 @@ int FTermLinux::getFramebuffer_bpp()
//----------------------------------------------------------------------
bool FTermLinux::getScreenFont()
{
struct console_font_op font;
struct console_font_op font{};
int fd_tty = FTerm::getTTYFileDescriptor();
int ret = -1;
int ret{-1};
if ( fd_tty < 0 )
return false;
@ -593,8 +593,8 @@ bool FTermLinux::getScreenFont()
//----------------------------------------------------------------------
bool FTermLinux::getUnicodeMap()
{
int ret = -1;
int fd_tty = FTerm::getTTYFileDescriptor();
int ret{-1};
if ( fd_tty < 0 )
return false;
@ -639,7 +639,7 @@ FTermLinux::modifier_key& FTermLinux::getModifierKey()
{
// Get Linux console shift state
char subcode = 6; // Shift state command + return value
char subcode{6}; // Shift state command + return value
// Fill bit field with 0
std::memset (&mod_key, 0x00, sizeof(mod_key));
@ -668,9 +668,9 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
, uInt fontwidth, uInt fontheight
, bool direct)
{
struct console_font_op font;
struct console_font_op font{};
int fd_tty = FTerm::getTTYFileDescriptor();
int ret = -1;
int ret{-1};
if ( fd_tty < 0 )
return -1;
@ -701,7 +701,7 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
return -1;
}
for (std::size_t i = 0; i < count; i++)
for (std::size_t i{0}; i < count; i++)
std::memcpy ( const_cast<uChar*>(font.data + bytes_per_line * 32 * i)
, &fontdata[i * font.height]
, font.height);
@ -733,7 +733,7 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap)
{
struct unimapinit advice;
int fd_tty = FTerm::getTTYFileDescriptor();
int ret = -1;
int ret{-1};
if ( fd_tty < 0 )
return -1;
@ -798,7 +798,6 @@ uChar FTermLinux::readAttributeController (uChar index)
if ( ! fsystem )
fsystem = FTerm::getFSystem();
uChar res;
// Attribute controller (write port)
static constexpr uInt16 attrib_cntlr_write = 0x3c0;
// Attribute controller (read port)
@ -807,7 +806,7 @@ uChar FTermLinux::readAttributeController (uChar index)
fsystem->inPortByte (input_status_1); // switch to index mode
fsystem->outPortByte (index & 0x1f, attrib_cntlr_write); // selects address register
res = fsystem->inPortByte (attrib_cntlr_read); // read from data register
uChar res = fsystem->inPortByte (attrib_cntlr_read); // read from data register
// Disable access to the palette and unblank the display
fsystem->inPortByte (input_status_1); // switch to index mode
@ -916,7 +915,7 @@ void FTermLinux::setVGADefaultPalette()
{0x55, 0xff, 0xff}, {0xff, 0xff, 0xff}
};
for (std::size_t index = 0; index < 16; index++)
for (std::size_t index{0}; index < 16; index++)
{
cmap.color[index].red = defaultColor[index].red;
cmap.color[index].green = defaultColor[index].green;
@ -1288,7 +1287,7 @@ sInt16 FTermLinux::getFontPos (wchar_t ucs)
{
constexpr sInt16 NOT_FOUND = -1;
for (std::size_t n = 0; n < screen_unicode_map.entry_ct; n++)
for (std::size_t n{0}; n < screen_unicode_map.entry_ct; n++)
{
if ( screen_unicode_map.entries[n].unicode == ucs )
return sInt16(screen_unicode_map.entries[n].fontpos);

View File

@ -29,9 +29,9 @@ namespace finalcut
// static class attributes
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
kbd_t FTermOpenBSD::bsd_keyboard_encoding = 0;
bool FTermOpenBSD::meta_sends_escape = true;
FSystem* FTermOpenBSD::fsystem = nullptr;
kbd_t FTermOpenBSD::bsd_keyboard_encoding{0};
bool FTermOpenBSD::meta_sends_escape{true};
FSystem* FTermOpenBSD::fsystem{nullptr};
#endif
@ -140,7 +140,7 @@ bool FTermOpenBSD::resetBeep()
bool FTermOpenBSD::saveBSDConsoleEncoding()
{
static kbd_t k_encoding{};
int ret = -1;
int ret{-1};
if ( fsystem )
ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding);

View File

@ -38,22 +38,22 @@ namespace finalcut
{
// static class attributes
bool FTermXTerminal::mouse_support;
bool FTermXTerminal::meta_sends_esc;
bool FTermXTerminal::xterm_default_colors;
std::size_t FTermXTerminal::term_width = 80;
std::size_t FTermXTerminal::term_height = 24;
const FString* FTermXTerminal::xterm_font = nullptr;
const FString* FTermXTerminal::xterm_title = nullptr;
const FString* FTermXTerminal::foreground_color = nullptr;
const FString* FTermXTerminal::background_color = nullptr;
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;
bool FTermXTerminal::mouse_support{false};
bool FTermXTerminal::meta_sends_esc{false};
bool FTermXTerminal::xterm_default_colors{false};
std::size_t FTermXTerminal::term_width{80};
std::size_t FTermXTerminal::term_height{24};
const FString* FTermXTerminal::xterm_font{nullptr};
const FString* FTermXTerminal::xterm_title{nullptr};
const FString* FTermXTerminal::foreground_color{nullptr};
const FString* FTermXTerminal::background_color{nullptr};
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};
//----------------------------------------------------------------------
@ -64,10 +64,6 @@ fc::xtermCursorStyle FTermXTerminal::cursor_style = fc::unknown_cursor_style;
//----------------------------------------------------------------------
FTermXTerminal::FTermXTerminal()
{
// Preset to false
mouse_support = \
meta_sends_esc = \
xterm_default_colors = false;
// Get FSystem object
fsystem = FTerm::getFSystem();
}
@ -777,8 +773,8 @@ const FString* FTermXTerminal::captureXTermFont()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{
fd_set ifds;
struct timeval tv;
fd_set ifds{};
struct timeval tv{};
int stdin_no = FTermios::getStdIn();
oscPrefix();
@ -794,7 +790,7 @@ const FString* FTermXTerminal::captureXTermFont()
// Read the terminal answer
if ( select(stdin_no + 1, &ifds, 0, 0, &tv) > 0 )
{
char temp[150] = { };
char temp[150]{};
if ( std::scanf("\033]50;%148[^\n]s", temp) == 1 )
{
@ -829,8 +825,8 @@ const FString* FTermXTerminal::captureXTermTitle()
if ( term_detection->isKdeTerminal() )
return 0;
fd_set ifds;
struct timeval tv;
fd_set ifds{};
struct timeval tv{};
int stdin_no = FTermios::getStdIn();
FTerm::putstring (CSI "21t"); // get title
@ -844,7 +840,7 @@ const FString* FTermXTerminal::captureXTermTitle()
// read the terminal answer
if ( select (stdin_no + 1, &ifds, 0, 0, &tv) > 0 )
{
char temp[512] = { };
char temp[512]{};
if ( std::scanf("\033]l%509[^\n]s", temp) == 1 )
{

View File

@ -61,21 +61,19 @@ FTextView::~FTextView() // destructor
//----------------------------------------------------------------------
const FString FTextView::getText() const
{
std::size_t len, rows, idx;
if ( data.empty() )
return FString("");
len = 0;
rows = getRows();
std::size_t len{0};
std::size_t rows = getRows();
for (std::size_t i = 0 ; i < rows; i++)
for (std::size_t i{0} ; i < rows; i++)
len += data[i].getLength() + 1;
FString s(len + 1);
idx = 0;
std::size_t idx{0};
for (std::size_t i = 0 ; i < rows; i++)
for (std::size_t i{0}; i < rows; i++)
{
const wchar_t* p = data[i].wc_str();
@ -223,7 +221,7 @@ void FTextView::insert (const FString& str, int pos)
auto text_split = s.split("\r\n");
auto num = text_split.size();
for (std::size_t i = 0; i < num; i++)
for (std::size_t i{0}; i < num; i++)
{
text_split[i] = text_split[i].removeBackspaces()
.removeDel()
@ -283,7 +281,6 @@ void FTextView::replaceRange (const FString& str, int from, int to)
//----------------------------------------------------------------------
void FTextView::clear()
{
std::size_t size;
data.clear();
data.shrink_to_fit();
xoffset = 0;
@ -300,14 +297,14 @@ void FTextView::clear()
// clear list from screen
setColor();
size = getWidth() - 2;
std::size_t size = getWidth() - 2;
if ( size == 0 )
return;
char* blank = createBlankArray(size + 1);
for (int y = 0; y < int(getTextHeight()); y++)
for (int y{0}; y < int(getTextHeight()); y++)
{
print() << FPoint(2, 2 - nf_offset + y) << blank;
}
@ -479,7 +476,7 @@ void FTextView::onMouseMove (FMouseEvent* ev)
//----------------------------------------------------------------------
void FTextView::onWheel (FWheelEvent* ev)
{
int distance = 4;
int distance{4};
switch ( ev->getWheel() )
{
@ -705,15 +702,15 @@ void FTextView::drawText()
if ( isMonochron() )
setReverse(true);
for (std::size_t y = 0; y < num; y++)
for (std::size_t y{0}; y < num; y++)
{
std::size_t i;
FString line;
print() << FPoint(2, 2 - nf_offset + int(y));
line = data[y + std::size_t(yoffset)].mid ( std::size_t(1 + xoffset)
, getTextWidth() );
std::size_t i{};
std::size_t n = y + std::size_t(yoffset);
std::size_t x = std::size_t(1 + xoffset);
FString line(data[n].mid (x, getTextWidth()));
const auto line_str = line.wc_str();
const auto len = line.getLength();
print() << FPoint(2, 2 - nf_offset + int(y));
for (i = 0; i < len; i++)
{
@ -749,8 +746,8 @@ void FTextView::processChanged()
void FTextView::cb_VBarChange (FWidget*, FDataPtr)
{
FScrollbar::sType scrollType = vbar->getScrollType();
int distance = 1;
int wheel_distance = 4;
int distance{1};
int wheel_distance{4};
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
@ -805,8 +802,8 @@ void FTextView::cb_VBarChange (FWidget*, FDataPtr)
void FTextView::cb_HBarChange (FWidget*, FDataPtr)
{
FScrollbar::sType scrollType = hbar->getScrollType();
int distance = 1;
int wheel_distance = 4;
int distance{1};
int wheel_distance{4};
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )

View File

@ -84,7 +84,7 @@ void FToggleButton::setGeometry ( const FPoint& pos, const FSize& s
{
// Set the toggle button geometry
FSize size = s;
FSize size(s);
std::size_t hotkey_mark = ( getHotkey(text) ) ? 1 : 0;
std::size_t min_width = button_width + text.getLength() - hotkey_mark;
@ -190,7 +190,7 @@ bool FToggleButton::setChecked (bool enable)
//----------------------------------------------------------------------
void FToggleButton::setText (const FString& txt)
{
text = txt;
text.setString(txt);
std::size_t hotkey_mark = ( getHotkey(text) ) ? 1 : 0;
setWidth(button_width + text.getLength() - hotkey_mark);
@ -440,7 +440,7 @@ void FToggleButton::drawLabel()
return;
}
FString txt = text;
FString txt(text);
wchar_t* src = const_cast<wchar_t*>(txt.wc_str());
wchar_t* dest = const_cast<wchar_t*>(LabelText);
auto hotkeypos = finalcut::getHotkeyPos(src, dest, length);
@ -566,7 +566,7 @@ void FToggleButton::drawText ( wchar_t LabelText[]
else
setColor (wc.label_inactive_fg, wc.label_inactive_bg);
for (std::size_t z = 0; z < length; z++)
for (std::size_t z{0}; z < length; z++)
{
if ( (z == hotkeypos) && flags.active )
{

View File

@ -55,7 +55,7 @@ FToolTip::~FToolTip() // destructor
if ( fapp->isQuit() )
return;
FWindow* parent_win = nullptr;
FWindow* parent_win{nullptr};
if ( auto parent = getParentWidget() )
parent_win = getWindowWidget(parent);
@ -71,7 +71,7 @@ FToolTip::~FToolTip() // destructor
//----------------------------------------------------------------------
void FToolTip::setText (const FString& txt)
{
text = txt;
text.setString(txt);
calculateDimensions();
}
@ -86,7 +86,7 @@ void FToolTip::draw()
clearArea();
drawBorder();
for (std::size_t i = 0; i < text_num_lines; i++)
for (std::size_t i{0}; i < text_num_lines; i++)
{
print() << FPoint(3, 2 + int(i)) << text_components[i];
}
@ -134,8 +134,7 @@ void FToolTip::init()
//----------------------------------------------------------------------
void FToolTip::calculateDimensions()
{
int x, y;
std::size_t w, h;
int x{}, y{};
auto r = getRootWidget();
max_line_width = 0;
text_split = text.split("\n");
@ -144,7 +143,7 @@ void FToolTip::calculateDimensions()
if ( text_num_lines == 0 )
return;
for (std::size_t i = 0; i < text_num_lines; i++)
for (std::size_t i{0}; i < text_num_lines; i++)
{
text_components = &text_split[0];
std::size_t len = text_components[i].getLength();
@ -153,8 +152,8 @@ void FToolTip::calculateDimensions()
max_line_width = len;
}
h = text_num_lines + 2;
w = max_line_width + 4;
std::size_t h = text_num_lines + 2;
std::size_t w = max_line_width + 4;
if ( r )
{

View File

@ -45,27 +45,27 @@ namespace finalcut
{
// global FVTerm object
static FVTerm* init_object = nullptr;
static FVTerm* init_object{nullptr};
// static class attributes
bool FVTerm::terminal_update_complete;
bool FVTerm::terminal_update_pending;
bool FVTerm::force_terminal_update;
bool FVTerm::stop_terminal_updates;
int FVTerm::skipped_terminal_update = 0;
uInt FVTerm::erase_char_length;
uInt FVTerm::repeat_char_length;
uInt FVTerm::clr_bol_length;
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;
FVTerm::term_area* FVTerm::active_area = nullptr;
FKeyboard* FVTerm::keyboard = nullptr;
bool FVTerm::terminal_update_complete{false};
bool FVTerm::terminal_update_pending{false};
bool FVTerm::force_terminal_update{false};
bool FVTerm::stop_terminal_updates{false};
int FVTerm::skipped_terminal_update{};
uInt FVTerm::erase_char_length{};
uInt FVTerm::repeat_char_length{};
uInt FVTerm::clr_bol_length{};
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};
FVTerm::term_area* FVTerm::active_area{nullptr};
FKeyboard* FVTerm::keyboard{nullptr};
charData FVTerm::term_attribute{};
charData FVTerm::next_attribute{};
charData FVTerm::s_ch{};
@ -80,8 +80,6 @@ charData FVTerm::i_ch{};
//----------------------------------------------------------------------
FVTerm::FVTerm (bool initialize, bool disable_alt_screen)
{
terminal_update_complete = false;
if ( initialize )
init (disable_alt_screen);
}
@ -119,13 +117,12 @@ FPoint FVTerm::getPrintCursor()
void FVTerm::setTermXY (int x, int y)
{
// Sets the hardware cursor to the given (x,y) position
int term_x, term_y, term_width, term_height;
if ( term_pos->getX() == x && term_pos->getY() == y )
return;
term_width = int(getColumnNumber());
term_height = int(getLineNumber());
int term_width = int(getColumnNumber());
int term_height = int(getLineNumber());
if ( x >= term_width && term_width > 0 )
{
@ -139,8 +136,8 @@ void FVTerm::setTermXY (int x, int y)
if ( y >= term_height )
y = term_height - 1;
term_x = term_pos->getX();
term_y = term_pos->getY();
int term_x = term_pos->getX();
int term_y = term_pos->getY();
const char* move_str = FTerm::moveCursorString (term_x, term_y, x, y);
@ -214,7 +211,7 @@ void FVTerm::resizeVTerm (const FSize& size)
//----------------------------------------------------------------------
void FVTerm::putVTerm()
{
for (int i = 0; i < vterm->height; i++)
for (int i{0}; i < vterm->height; i++)
{
vterm->changes[i].xmin = 0;
vterm->changes[i].xmax = uInt(vterm->width - 1);
@ -282,7 +279,7 @@ void FVTerm::updateTerminal()
if ( ! vterm->has_changes )
return;
for (uInt y = 0; y < uInt(vterm->height); y++)
for (uInt y{0}; y < uInt(vterm->height); y++)
updateTerminalLine (y);
vterm->has_changes = false;
@ -300,7 +297,7 @@ void FVTerm::addPreprocessingHandler ( FVTerm* instance
if ( print_area )
{
vterm_preprocessing obj = { instance, handler };
vterm_preprocessing obj{ instance, handler };
delPreprocessingHandler (instance);
print_area->preprocessing_call.push_back(obj);
}
@ -330,8 +327,8 @@ void FVTerm::delPreprocessingHandler (FVTerm* instance)
int FVTerm::printf (const FString format, ...)
{
static constexpr int BUFSIZE = 4096;
wchar_t buffer[BUFSIZE];
va_list args;
wchar_t buffer[BUFSIZE]{};
va_list args{};
if ( format.isEmpty() )
return 0;
@ -364,7 +361,7 @@ int FVTerm::print (term_area* area, const FString& s)
if ( s.isNull() || ! area )
return -1;
std::vector<charData> term_string;
std::vector<charData> term_string{};
const wchar_t* p = s.wc_str();
if ( p )
@ -426,7 +423,7 @@ int FVTerm::print (const std::vector<charData>& term_string)
//----------------------------------------------------------------------
int FVTerm::print (term_area* area, const std::vector<charData>& term_string)
{
int len = 0;
int len{0};
uInt tabstop = uInt(getTabstop());
if ( ! area )
@ -437,7 +434,7 @@ int FVTerm::print (term_area* area, const std::vector<charData>& term_string)
for (auto&& ch : term_string)
{
bool printable_character = false;
bool printable_character{false};
switch ( ch.code )
{
@ -495,7 +492,7 @@ int FVTerm::print (wchar_t c)
//----------------------------------------------------------------------
int FVTerm::print (term_area* area, wchar_t c)
{
charData nc; // next character
charData nc{}; // next character
if ( ! area )
return -1;
@ -525,17 +522,16 @@ int FVTerm::print (charData& term_char)
int FVTerm::print (term_area* area, charData& term_char)
{
charData& nc = term_char; // next character
int width, height, rsh, bsh, ax, ay;
if ( ! area )
return -1;
width = area->width;
height = area->height;
rsh = area->right_shadow;
bsh = area->bottom_shadow;
ax = area->cursor_x - 1;
ay = area->cursor_y - 1;
int width = area->width;
int height = area->height;
int rsh = area->right_shadow;
int bsh = area->bottom_shadow;
int ax = area->cursor_x - 1;
int ay = area->cursor_y - 1;
if ( area->cursor_x > 0
&& area->cursor_y > 0
@ -672,8 +668,6 @@ void FVTerm::resizeArea ( const FRect& box
assert ( height > 0 && height + bsh > 0 );
assert ( rsw >= 0 );
assert ( bsh >= 0 );
std::size_t area_size;
bool realloc_success = false;
if ( ! area )
return;
@ -692,7 +686,8 @@ void FVTerm::resizeArea ( const FRect& box
return;
}
area_size = std::size_t((width + rsw) * (height + bsh));
bool realloc_success{false};
std::size_t area_size = std::size_t((width + rsw) * (height + bsh));
if ( area->height + area->bottom_shadow != height + bsh )
{
@ -847,11 +842,11 @@ void FVTerm::restoreVTerm (const FRect& box)
if ( h < 0 )
return;
for (int ty = 0; ty < h; ty++)
for (int ty{0}; ty < h; ty++)
{
int ypos = y + ty;
for (int tx = 0; tx < w; tx++)
for (int tx{0}; tx < w; tx++)
{
int xpos = x + tx;
auto tc = &vterm->text[ypos * vterm->width + xpos]; // terminal character
@ -943,7 +938,7 @@ void FVTerm::updateOverlappedColor ( term_area* area
// Terminal character
auto tc = &vterm->text[ty * vterm->width + tx];
// New character
charData nc;
charData nc{};
std::memcpy (&nc, ac, sizeof(nc));
// Overlapped character
auto oc = getOverlappedCharacter (terminal_pos + FPoint(1, 1), area->widget);
@ -1032,7 +1027,7 @@ void FVTerm::updateInheritBackground ( term_area* area
// Terminal character
auto tc = &vterm->text[ty * vterm->width + tx];
// New character
charData nc;
charData nc{};
std::memcpy (&nc, ac, sizeof(nc));
// Covered character
auto cc = getCoveredCharacter (terminal_pos + FPoint(1, 1), area->widget);
@ -1213,7 +1208,7 @@ void FVTerm::updateVTerm (term_area* area)
else
y_end = height;
for (int y = 0; y < y_end; y++) // Line loop
for (int y{0}; y < y_end; y++) // Line loop
{
int _xmin, _xmax;
bool modified = false;
@ -1284,16 +1279,15 @@ bool FVTerm::updateVTermCursor (term_area* area)
if ( area->input_cursor_visible )
{
int cx, cy, ax, ay, x, y;
// area offset
ax = area->offset_left;
ay = area->offset_top;
int ax = area->offset_left;
int ay = area->offset_top;
// area cursor position
cx = area->input_cursor_x;
cy = area->input_cursor_y;
int cx = area->input_cursor_x;
int cy = area->input_cursor_y;
// terminal position
x = ax + cx;
y = ay + cy;
int x = ax + cx;
int y = ay + cy;
if ( isInsideArea (FPoint(cx, cy), area)
&& isInsideTerminal (FPoint(x, y))
@ -1362,7 +1356,7 @@ void FVTerm::getArea (const FPoint& pos, term_area* area)
else
length = area->width;
for (int y = 0; y < y_end; y++) // line loop
for (int y{0}; y < y_end; y++) // line loop
{
auto tc = &vterm->text[(ay + y) * vterm->width + ax]; // terminal character
auto ac = &area->text[y * area->width]; // area character
@ -1390,8 +1384,7 @@ void FVTerm::getArea (const FRect& box, term_area* area)
int h = int(box.getHeight());
int dx = x - area->offset_left + 1;
int dy = y - area->offset_top + 1;
int y_end;
int length;
int y_end{}, length{};
if ( x < 0 || y < 0 )
return;
@ -1429,8 +1422,8 @@ void FVTerm::putArea (const FPoint& pos, term_area* area)
{
// Copies the given area block to the virtual terminal position
charData* tc; // terminal character
charData* ac; // area character
charData* tc{}; // terminal character
charData* ac{}; // area character
if ( ! area || ! area->visible )
return;
@ -1440,7 +1433,7 @@ void FVTerm::putArea (const FPoint& pos, term_area* area)
int width = area->width + area->right_shadow;
int height = area->height + area->bottom_shadow;
int ol = 0; // outside left
int y_end, length;
int y_end{}, length{};
if ( ax < 0 )
{
@ -1461,7 +1454,7 @@ void FVTerm::putArea (const FPoint& pos, term_area* area)
if ( length < 1 )
return;
for (int y = 0; y < y_end; y++) // line loop
for (int y{0}; y < y_end; y++) // line loop
{
if ( area->changes[y].trans_count == 0 )
{
@ -1473,7 +1466,7 @@ void FVTerm::putArea (const FPoint& pos, term_area* area)
else
{
// Line has one or more transparent characters
for (int x = 0; x < length; x++) // column loop
for (int x{0}; x < length; x++) // column loop
{
int cx = ax + x;
int cy = ay + y;
@ -1497,12 +1490,9 @@ void FVTerm::putArea (const FPoint& pos, term_area* area)
void FVTerm::scrollAreaForward (term_area* area)
{
// Scrolls the entire area up line down
int total_width
, length
, y_max;
charData nc; // next character
charData* lc; // last character
charData* dc; // destination character
charData nc{}; // next character
charData* lc{}; // last character
charData* dc{}; // destination character
if ( ! area )
return;
@ -1510,11 +1500,11 @@ void FVTerm::scrollAreaForward (term_area* area)
if ( area->height <= 1 )
return;
length = area->width;
total_width = area->width + area->right_shadow;
y_max = area->height - 1;
int length = area->width;
int total_width = area->width + area->right_shadow;
int y_max = area->height - 1;
for (int y = 0; y < y_max; y++)
for (int y{0}; y < y_max; y++)
{
int pos1 = y * total_width;
int pos2 = (y + 1) * total_width;
@ -1544,7 +1534,7 @@ void FVTerm::scrollAreaForward (term_area* area)
putArea (FPoint(1, 1), vdesktop);
// avoid update lines from 0 to (y_max - 1)
for (int y = 0; y < y_max; y++)
for (int y{0}; y < y_max; y++)
{
area->changes[y].xmin = uInt(area->width - 1);
area->changes[y].xmax = 0;
@ -1557,12 +1547,10 @@ void FVTerm::scrollAreaForward (term_area* area)
void FVTerm::scrollAreaReverse (term_area* area)
{
// Scrolls the entire area one line down
int total_width
, length
, y_max;
charData nc; // next character
charData* lc; // last character
charData* dc; // destination character
charData nc{}; // next character
charData* lc{}; // last character
charData* dc{}; // destination character
if ( ! area )
return;
@ -1570,9 +1558,9 @@ void FVTerm::scrollAreaReverse (term_area* area)
if ( area->height <= 1 )
return;
length = area->width;
total_width = area->width + area->right_shadow;
y_max = area->height - 1;
int length = area->width;
int total_width = area->width + area->right_shadow;
int y_max = area->height - 1;
for (int y = y_max; y > 0; y--)
{
@ -1604,7 +1592,7 @@ void FVTerm::scrollAreaReverse (term_area* area)
putArea (FPoint(1, 1), vdesktop);
// avoid update lines from 1 to y_max
for (int y = 1; y <= y_max; y++)
for (int y{1}; y <= y_max; y++)
{
area->changes[y].xmin = uInt(area->width - 1);
area->changes[y].xmax = 0;
@ -1618,7 +1606,7 @@ void FVTerm::clearArea (term_area* area, int fillchar)
{
// Clear the area with the current attributes
charData nc; // next character
charData nc{}; // next character
// Current attributes with a space character
std::memcpy (&nc, &next_attribute, sizeof(nc));
@ -1640,7 +1628,7 @@ void FVTerm::clearArea (term_area* area, int fillchar)
else
clearAreaWithShadow(area, nc);
for (int i = 0; i < area->height; i++)
for (int i{0}; i < area->height; i++)
{
area->changes[i].xmin = 0;
area->changes[i].xmax = w - 1;
@ -1655,7 +1643,7 @@ void FVTerm::clearArea (term_area* area, int fillchar)
area->changes[i].trans_count = 0;
}
for (int i = 0; i < area->bottom_shadow; i++)
for (int i{0}; i < area->bottom_shadow; i++)
{
int y = area->height + i;
area->changes[y].xmin = 0;
@ -1893,11 +1881,6 @@ void FVTerm::init (bool disable_alt_screen)
std::abort();
}
// Preset to false
terminal_update_pending = \
force_terminal_update = \
stop_terminal_updates = false;
// term_attribute stores the current state of the terminal
term_attribute.code = '\0';
term_attribute.fg_color = fc::Default;
@ -1994,8 +1977,7 @@ void FVTerm::putAreaCharacter ( const FPoint& pos, FVTerm* obj
if ( ac->attr.bit.transparent ) // Transparent
{
// Restore one character on vterm
charData ch;
ch = getCoveredCharacter (pos, obj);
charData ch = getCoveredCharacter (pos, obj);
std::memcpy (tc, &ch, sizeof(*tc));
}
else // Mot transparent
@ -2003,8 +1985,7 @@ void FVTerm::putAreaCharacter ( const FPoint& pos, FVTerm* obj
if ( ac->attr.bit.trans_shadow ) // Transparent shadow
{
// Get covered character + add the current color
charData ch;
ch = getCoveredCharacter (pos, obj);
charData ch = getCoveredCharacter (pos, obj);
ch.fg_color = ac->fg_color;
ch.bg_color = ac->bg_color;
ch.attr.bit.reverse = false;
@ -2023,9 +2004,9 @@ void FVTerm::putAreaCharacter ( const FPoint& pos, FVTerm* obj
else if ( ac->attr.bit.inherit_bg )
{
// Add the covered background to this character
charData ch, cc;
charData ch{};
std::memcpy (&ch, ac, sizeof(ch));
cc = getCoveredCharacter (pos, obj);
charData cc = getCoveredCharacter (pos, obj);
ch.bg_color = cc.bg_color;
std::memcpy (tc, &ch, sizeof(*tc));
}
@ -2104,7 +2085,7 @@ bool FVTerm::clearTerm (int fillchar)
{
term_pos->setPoint(-1, -1);
for (int i = 0; i < int(getLineNumber()); i++)
for (int i{0}; i < int(getLineNumber()); i++)
{
setTermXY (0, i);
appendOutputBuffer (cb);
@ -2135,7 +2116,7 @@ bool FVTerm::clearFullArea (term_area* area, charData& nc)
}
else
{
for (int i = 0; i < vdesktop->height; i++)
for (int i{0}; i < vdesktop->height; i++)
{
vdesktop->changes[i].xmin = 0;
vdesktop->changes[i].xmax = uInt(vdesktop->width) - 1;
@ -2155,7 +2136,7 @@ void FVTerm::clearAreaWithShadow (term_area* area, charData& nc)
int total_width = area->width + area->right_shadow;
t_char.attr.bit.transparent = true;
for (int y = 0; y < area->height; y++)
for (int y{0}; y < area->height; y++)
{
int pos = y * total_width;
// Clear area
@ -2165,7 +2146,7 @@ void FVTerm::clearAreaWithShadow (term_area* area, charData& nc)
}
// Make bottom shadow transparent
for (int y = 0; y < area->bottom_shadow; y++)
for (int y{0}; y < area->bottom_shadow; y++)
{
int pos = total_width * (y + area->height);
std::fill_n (&area->text[pos], total_width, t_char);
@ -2223,7 +2204,7 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y)
bool normal = FTerm::isNormal(first_char);
bool& ut = FTermcap::background_color_erase;
for (uInt x = 1; x < uInt(vt->width); x++)
for (uInt x{1}; x < uInt(vt->width); x++)
{
auto ch = &vt->text[y * uInt(vt->width) + x];
@ -2294,7 +2275,7 @@ bool FVTerm::skipUnchangedCharacters(uInt& x, uInt xmax, uInt y)
if ( print_char->attr.bit.no_changes )
{
uInt count = 1;
uInt count{1};
for (uInt i = x + 1; i <= xmax; i++)
{
@ -2407,7 +2388,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
{
x--;
for (uInt i = 0; i < whitespace; i++, x++)
for (uInt i{0}; i < whitespace; i++, x++)
appendCharacter (print_char);
}
@ -2429,7 +2410,7 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y)
if ( ! rp )
return not_used;
uInt repetitions = 1;
uInt repetitions{1};
for (uInt i = x + 1; i <= xmax; i++)
{
@ -2464,7 +2445,7 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y)
{
x--;
for (uInt i = 0; i < repetitions; i++, x++)
for (uInt i{0}; i < repetitions; i++, x++)
appendCharacter (print_char);
}
@ -2504,11 +2485,11 @@ void FVTerm::cursorWrap()
//----------------------------------------------------------------------
bool FVTerm::printWrap (term_area* area)
{
bool end_of_area = false;
int width = area->width,
height = area->height,
rsh = area->right_shadow,
bsh = area->bottom_shadow;
bool end_of_area{false};
int width = area->width
, height = area->height
, rsh = area->right_shadow
, bsh = area->bottom_shadow;
// Line break at right margin
if ( area->cursor_x > width + rsh )
@ -2804,15 +2785,14 @@ int FVTerm::appendLowerRight (charData*& screen_char)
}
else
{
int x, y;
auto& IC = TCAP(fc::t_parm_ich);
auto& im = TCAP(fc::t_enter_insert_mode);
auto& ei = TCAP(fc::t_exit_insert_mode);
auto& ip = TCAP(fc::t_insert_padding);
auto& ic = TCAP(fc::t_insert_character);
x = int(getColumnNumber()) - 2;
y = int(getLineNumber()) - 1;
int x = int(getColumnNumber()) - 2;
int y = int(getLineNumber()) - 1;
setTermXY (x, y);
appendChar (screen_char);
term_pos->x_ref()++;

View File

@ -35,21 +35,21 @@ namespace finalcut
{
// global FWidget object
static FWidget* rootObject = nullptr;
static FWidget* rootObject{nullptr};
// static class attributes
FStatusBar* FWidget::statusbar = nullptr;
FMenuBar* FWidget::menubar = nullptr;
FWidget* FWidget::show_root_widget = nullptr;
FWidget* FWidget::redraw_root_widget = nullptr;
FWidget::widgetList* FWidget::window_list = nullptr;
FWidget::widgetList* FWidget::dialog_list = nullptr;
FWidget::widgetList* FWidget::always_on_top_list = nullptr;
FWidget::widgetList* FWidget::close_widget = nullptr;
FWidgetColors FWidget::wc;
bool FWidget::init_desktop;
bool FWidget::hideable;
uInt FWidget::modal_dialogs;
FStatusBar* FWidget::statusbar{nullptr};
FMenuBar* FWidget::menubar{nullptr};
FWidget* FWidget::show_root_widget{nullptr};
FWidget* FWidget::redraw_root_widget{nullptr};
FWidget::widgetList* FWidget::window_list{nullptr};
FWidget::widgetList* FWidget::dialog_list{nullptr};
FWidget::widgetList* FWidget::always_on_top_list{nullptr};
FWidget::widgetList* FWidget::close_widget{nullptr};
FWidgetColors FWidget::wc{};
bool FWidget::init_desktop{false};
bool FWidget::hideable{false};
uInt FWidget::modal_dialogs{};
//----------------------------------------------------------------------
// class FWidget
@ -344,7 +344,7 @@ void FWidget::setY (int y, bool adjust)
//----------------------------------------------------------------------
void FWidget::setPos (const FPoint& p, bool adjust)
{
FPoint pos = p;
FPoint pos(p);
if ( getX() == pos.getX() && wsize.getX() == pos.getX()
&& getY() == pos.getY() && wsize.getY() == pos.getY() )
@ -668,7 +668,7 @@ void FWidget::setPrintPos (const FPoint& pos)
//----------------------------------------------------------------------
void FWidget::setDoubleFlatLine (fc::sides side, bool bit)
{
uLong length;
uLong length{};
assert ( side == fc::top
|| side == fc::right
@ -702,8 +702,6 @@ void FWidget::setDoubleFlatLine (fc::sides side, bool bit)
//----------------------------------------------------------------------
void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
{
uLong length, index;
assert ( side == fc::top
|| side == fc::right
|| side == fc::bottom
@ -711,7 +709,8 @@ void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
assert ( pos >= 1 );
index = uLong(pos - 1);
uLong length{};
uLong index = uLong(pos - 1);
switch ( side )
{
@ -789,7 +788,7 @@ int FWidget::numOfFocusableChildren()
if ( ! hasChildren() )
return 0;
int num = 0;
int num{0};
auto iter = FObject::begin();
auto last = FObject::end();
@ -840,7 +839,7 @@ void FWidget::addCallback ( const FString& cb_signal
, FDataPtr data )
{
// add a (normal) function pointer as callback
callback_data obj = { cb_signal, cb_handler, data };
callback_data obj{ cb_signal, cb_handler, data };
callback_objects.push_back(obj);
}
@ -851,7 +850,7 @@ void FWidget::addCallback ( const FString& cb_signal
, FDataPtr data )
{
// add a member function pointer as callback
member_callback_data obj = { cb_signal, cb_instance, cb_handler, data };
member_callback_data obj{ cb_signal, cb_instance, cb_handler, data };
member_callback_objects.push_back(obj);
}
@ -1021,9 +1020,9 @@ void FWidget::resize()
{
if ( isRootWidget() )
{
FRect old_term_geometry = getTermGeometry();
FRect old_term_geometry (getTermGeometry());
detectTermSize();
FRect term_geometry = getTermGeometry();
FRect term_geometry (getTermGeometry());
term_geometry.move (-1, -1);
if ( old_term_geometry.getSize() == term_geometry.getSize() )
@ -1278,7 +1277,7 @@ void FWidget::clearShadow()
if ( w <= offset.getX2() )
{
for (std::size_t y = 1; y <= getHeight(); y++)
for (std::size_t y{1}; y <= getHeight(); y++)
{
print() << FPoint(w + 1, int(y)) << ' '; // clear █
}
@ -1288,7 +1287,7 @@ void FWidget::clearShadow()
{
print() << FPoint(2, h + 1);
for (std::size_t i = 1; i <= getWidth(); i++)
for (std::size_t i{1}; i <= getWidth(); i++)
print (' '); // clear ▀
}
@ -1312,7 +1311,7 @@ void FWidget::drawFlatBorder()
else
setColor (wc.dialog_fg, wc.dialog_bg);
for (std::size_t y = 0; y < getHeight(); y++)
for (std::size_t y{0}; y < getHeight(); y++)
{
print() << FPoint(x1 - 1, y1 + int(y) + 1);
@ -1326,7 +1325,7 @@ void FWidget::drawFlatBorder()
print() << FPoint(x2, y1 + 1);
for (std::size_t y = 0; y < getHeight(); y++)
for (std::size_t y{0}; y < getHeight(); y++)
{
if ( double_flatline_mask.right[y] )
// left+right line (on right side)
@ -1340,7 +1339,7 @@ void FWidget::drawFlatBorder()
print() << FPoint(x1, y1);
for (std::size_t x = 0; x < getWidth(); x++)
for (std::size_t x{0}; x < getWidth(); x++)
{
if ( double_flatline_mask.top[x] )
// top+bottom line (at top)
@ -1352,7 +1351,7 @@ void FWidget::drawFlatBorder()
print() << FPoint(x1, y2);
for (std::size_t x = 0; x < getWidth(); x++)
for (std::size_t x{0}; x < getWidth(); x++)
{
if ( double_flatline_mask.bottom[x] )
// top+bottom line (at bottom)
@ -1380,7 +1379,7 @@ void FWidget::clearFlatBorder()
setColor (wc.dialog_fg, wc.dialog_bg);
// clear on left side
for (std::size_t y = 0; y < getHeight(); y++)
for (std::size_t y{0}; y < getHeight(); y++)
{
print() << FPoint(x1 - 1, y1 + int(y) + 1);
@ -1391,7 +1390,7 @@ void FWidget::clearFlatBorder()
}
// clear on right side
for (std::size_t y = 0; y < getHeight(); y++)
for (std::size_t y{0}; y < getHeight(); y++)
{
print() << FPoint(x2, y1 + int(y) + 1);
@ -1404,7 +1403,7 @@ void FWidget::clearFlatBorder()
// clear at top
print() << FPoint(x1, y1);
for (std::size_t x = 0; x < getWidth(); x++)
for (std::size_t x{0}; x < getWidth(); x++)
{
if ( double_flatline_mask.top[x] )
print (fc::NF_border_line_upper);
@ -1415,7 +1414,7 @@ void FWidget::clearFlatBorder()
// clear at bottom
print() << FPoint(x1, y2);
for (std::size_t x = 0; x < getWidth(); x++)
for (std::size_t x{0}; x < getWidth(); x++)
{
if ( double_flatline_mask.bottom[x] )
print (fc::NF_border_line_bottom);
@ -1442,7 +1441,7 @@ FVTerm::term_area* FWidget::getPrintArea()
return print_area;
else
{
FWidget* obj;
FWidget* obj{};
FWidget* p_obj = this;
do
@ -1603,7 +1602,7 @@ void FWidget::hideSize (const FSize& size)
if ( size.isEmpty() )
return;
FColor fg, bg;
FColor fg{}, bg{};
auto parent_widget = getParentWidget();
if ( parent_widget )
@ -1623,7 +1622,7 @@ void FWidget::hideSize (const FSize& size)
if ( blank == 0 )
return;
for (int y = 0; y < int(size.getWidth()); y++)
for (int y{0}; y < int(size.getWidth()); y++)
{
print() << FPoint(1, 1 + y) << blank;
}
@ -1664,7 +1663,7 @@ bool FWidget::focusNextChild()
continue;
}
FWidget* next = nullptr;
FWidget* next{nullptr};
auto next_element = iter;
do
@ -1723,7 +1722,7 @@ bool FWidget::focusPrevChild()
if ( w != this )
continue;
FWidget* prev = nullptr;
FWidget* prev{nullptr};
auto prev_element = iter;
do
@ -2050,7 +2049,7 @@ inline void FWidget::insufficientSpaceAdjust()
//----------------------------------------------------------------------
void FWidget::KeyPressEvent (FKeyEvent* kev)
{
bool accpt_focus = false;
bool accpt_focus{false};
if ( kev->key() == fc::Fkey_tab )
accpt_focus = focusNextChild();
@ -2060,7 +2059,7 @@ void FWidget::KeyPressEvent (FKeyEvent* kev)
if ( accpt_focus )
return;
FWidget* widget = this;
FWidget* widget(this);
while ( widget )
{
@ -2089,7 +2088,7 @@ void FWidget::KeyPressEvent (FKeyEvent* kev)
//----------------------------------------------------------------------
void FWidget::KeyDownEvent (FKeyEvent* kev)
{
FWidget* widget = this;
FWidget* widget(this);
while ( widget )
{
@ -2151,7 +2150,7 @@ void FWidget::draw()
void FWidget::drawWindows()
{
// redraw windows
charData default_char;
charData default_char{};
default_char.code = ' ';
default_char.fg_color = fc::Black;
default_char.bg_color = fc::Black;
@ -2216,7 +2215,7 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow();
for (std::size_t y = 1; y < getHeight(); y++)
for (std::size_t y{1}; y < getHeight(); y++)
{
print() << FPoint(x2 + 1, y1 + int(y)) << " ";
}
@ -2229,7 +2228,7 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow();
for (std::size_t x = 2; x <= getWidth() + 1; x++)
for (std::size_t x{2}; x <= getWidth() + 1; x++)
print (' ');
unsetTransShadow();
@ -2263,7 +2262,7 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
if ( isWindowWidget() )
unsetInheritBackground();
for (std::size_t y = 1; y < getHeight(); y++)
for (std::size_t y{1}; y < getHeight(); y++)
{
print() << FPoint(x2 + 1, y1 + int(y)) << block; // █
}
@ -2273,7 +2272,7 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
if ( isWindowWidget() )
setInheritBackground();
for (std::size_t x = 1; x <= getWidth(); x++)
for (std::size_t x{1}; x <= getWidth(); x++)
print (fc::UpperHalfBlock); // ▀
if ( isWindowWidget() )
@ -2330,7 +2329,7 @@ FKey getHotkey (const FString& text)
std::size_t length = text.getLength();
for (std::size_t i = 0; i < length; i++)
for (std::size_t i{0}; i < length; i++)
{
try
{
@ -2350,11 +2349,11 @@ std::size_t getHotkeyPos (wchar_t src[], wchar_t dest[], std::size_t length)
{
// Find hotkey position in string
// + generate a new string without the '&'-sign
wchar_t* txt = src;
const wchar_t* txt = src;
constexpr std::size_t NOT_SET = static_cast<std::size_t>(-1);
std::size_t hotkeypos = NOT_SET;
std::size_t hotkeypos{NOT_SET};
for (std::size_t i = 0; i < length; i++)
for (std::size_t i{0}; i < length; i++)
{
if ( i < length && txt[i] == L'&' && hotkeypos == NOT_SET )
{

View File

@ -32,7 +32,7 @@ namespace finalcut
{
// static attributes
FWindow* FWindow::previous_window = nullptr;
FWindow* FWindow::previous_window{nullptr};
//----------------------------------------------------------------------
@ -45,7 +45,7 @@ FWindow::FWindow(FWidget* parent)
: FWidget(parent)
{
setWindowWidget();
FRect geometry = getTermGeometry();
FRect geometry (getTermGeometry());
geometry.move(-1, -1);
createArea (geometry, getShadow(), vwin);
addWindow (this);
@ -322,7 +322,7 @@ void FWindow::setY (int y, bool adjust)
//----------------------------------------------------------------------
void FWindow::setPos (const FPoint& p, bool adjust)
{
FPoint pos = p;
FPoint pos(p);
if ( pos.getY() < 1 )
pos.setY(1);
@ -344,7 +344,7 @@ void FWindow::setWidth (std::size_t w, bool adjust)
if ( isVirtualWindow() && getWidth() != old_width )
{
FRect geometry = getTermGeometry();
FRect geometry (getTermGeometry());
geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin);
}
@ -358,7 +358,7 @@ void FWindow::setHeight (std::size_t h, bool adjust)
if ( isVirtualWindow() && getHeight() != old_height )
{
FRect geometry = getTermGeometry();
FRect geometry (getTermGeometry());
geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin);
}
@ -374,7 +374,7 @@ void FWindow::setSize (const FSize& size, bool adjust)
if ( isVirtualWindow()
&& (getWidth() != old_width || getHeight() != old_height) )
{
FRect geometry = getTermGeometry();
FRect geometry (getTermGeometry());
geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin);
}
@ -387,8 +387,8 @@ void FWindow::setGeometry ( const FPoint& p, const FSize& size, bool adjust)
int old_x = getX();
int old_y = getY();
FPoint pos = p;
FSize old_size = getSize();
FPoint pos(p);
FSize old_size(getSize());
if ( pos.getY() < 1 )
pos.setY(1);
@ -400,7 +400,7 @@ void FWindow::setGeometry ( const FPoint& p, const FSize& size, bool adjust)
if ( getSize() != old_size )
{
FRect geometry = getTermGeometry();
FRect geometry (getTermGeometry());
geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin);
}
@ -659,7 +659,7 @@ bool FWindow::zoomWindow()
if ( zoomed )
{
zoomed = false;
FRect oldGeometry = getTermGeometryWithShadow();
FRect oldGeometry (getTermGeometryWithShadow());
setGeometry (normalGeometry);
restoreVTerm (oldGeometry);
redraw();
@ -669,7 +669,7 @@ bool FWindow::zoomWindow()
zoomed = true;
// save the current geometry
normalGeometry = getGeometry();
FRect oldGeometry = getTermGeometryWithShadow();
FRect oldGeometry (getTermGeometryWithShadow());
setGeometry (FPoint(1, 1), FSize(getMaxWidth(), getMaxHeight()));
restoreVTerm (oldGeometry);
redraw();

View File

@ -275,7 +275,7 @@ inline bool FDialog::unsetScrollable()
//----------------------------------------------------------------------
inline void FDialog::setText (const FString& txt)
{ tb_text = txt; }
{ tb_text.setString(txt); }
//----------------------------------------------------------------------
inline bool FDialog::isModal()

View File

@ -126,7 +126,7 @@ inline FDataPtr FListBoxItem::getData() const
//----------------------------------------------------------------------
inline void FListBoxItem::setText (const FString& txt)
{ text = txt; }
{ text.setString(txt); }
//----------------------------------------------------------------------
inline void FListBoxItem::setData (FDataPtr data)

View File

@ -587,7 +587,7 @@ FObject::FObjectIterator
, std::back_inserter(str_cols)
, [] (const T& col) -> const FString
{
const FString s = FString() << col;
const FString s(FString() << col);
return s;
}
);
@ -623,7 +623,7 @@ FObject::FObjectIterator
, std::back_inserter(str_cols)
, [] (const ColT& col) -> const FString
{
const FString s = FString() << col;
const FString s(FString() << col);
return s;
}
);

View File

@ -213,12 +213,11 @@ int FMessageBox::info ( FWidget* parent
, int button1
, int button2 )
{
int reply;
FMessageBox mbox ( caption
, FString() << message
, button0, button1, button2
, parent );
reply = mbox.exec();
int reply = mbox.exec();
return reply;
}
@ -230,8 +229,7 @@ int FMessageBox::error ( FWidget* parent
, int button1
, int button2 )
{
int reply;
const FString& caption = "Error message";
const FString caption{"Error message"};
FMessageBox mbox ( caption
, FString() << message
, button0, button1, button2
@ -242,7 +240,7 @@ int FMessageBox::error ( FWidget* parent
mbox.setForegroundColor(mbox.wc.error_box_fg);
mbox.setBackgroundColor(mbox.wc.error_box_bg);
mbox.emphasis_color = mbox.wc.error_box_emphasis_fg;
reply = mbox.exec();
int reply = mbox.exec();
return reply;
}

View File

@ -243,7 +243,7 @@ inline void FObject::setWidgetProperty (bool property)
static inline timeval operator + (const timeval& t1, const timeval& t2)
{
timeval tmp;
timeval tmp{};
tmp.tv_sec = t1.tv_sec + t2.tv_sec;
if ( (tmp.tv_usec = t1.tv_usec + t2.tv_usec) >= 1000000 )
@ -258,7 +258,7 @@ static inline timeval operator + (const timeval& t1, const timeval& t2)
//----------------------------------------------------------------------
static inline timeval operator - (const timeval& t1, const timeval& t2)
{
timeval tmp;
timeval tmp{};
tmp.tv_sec = t1.tv_sec - t2.tv_sec;
if ( (tmp.tv_usec = t1.tv_usec - t2.tv_usec) < 0 )

View File

@ -153,7 +153,7 @@ inline void FStatusKey::setKey (FKey k)
//----------------------------------------------------------------------
inline void FStatusKey::setText (const FString& txt)
{ text = txt; }
{ text.setString(txt); }
//----------------------------------------------------------------------
inline void FStatusKey::unsetActive()

View File

@ -138,7 +138,7 @@ class FSystemImpl : public FSystem
int ioctl (int fd, uLong request, ...) override
{
va_list args;
va_list args{};
va_start (args, request);
void* argp = va_arg (args, void*);
int ret = ::ioctl (fd, request, argp);
@ -148,7 +148,7 @@ class FSystemImpl : public FSystem
int open (const char* pathname, int flags, ...) override
{
va_list args;
va_list args{};
va_start (args, flags);
mode_t mode = static_cast<mode_t>(va_arg (args, int));
int ret = ::open (pathname, flags, mode);

View File

@ -206,38 +206,20 @@ class FTermDetection final
static struct colorEnv
{
void setDefault()
{
string1 = nullptr;
string2 = nullptr;
string3 = nullptr;
string4 = nullptr;
string5 = nullptr;
string6 = nullptr;
string7 = nullptr;
}
char* string1;
char* string2;
char* string3;
char* string4;
char* string5;
char* string6;
char* string7;
char* string1{nullptr};
char* string2{nullptr};
char* string3{nullptr};
char* string4{nullptr};
char* string5{nullptr};
char* string6{nullptr};
char* string7{nullptr};
} color_env;
static struct secondaryDA
{
void setDefault()
{
terminal_id_type = -1;
terminal_id_version = -1;
terminal_id_hardware = -1;
}
int terminal_id_type;
int terminal_id_version;
int terminal_id_hardware;
int terminal_id_type{-1};
int terminal_id_version{-1};
int terminal_id_hardware{-1};
} secondary_da;
};
#pragma pack(pop)