Improve code readability through spaces between the operands and the operators

This commit is contained in:
Markus Gans 2017-08-27 09:50:30 +02:00
parent 12c0d53192
commit 5f7737bf64
46 changed files with 626 additions and 612 deletions

View File

@ -1,3 +1,7 @@
2017-08-26 Markus Gans <guru.mail@muenster.de>
* Improve code readability through spaces between
the operands and the operators
2017-08-24 Markus Gans <guru.mail@muenster.de>
* Rename fapp.{cpp,h} to fapplication.{cpp,h}

View File

@ -448,12 +448,12 @@ uChar FButton::getHotkey()
{
try
{
if ( (i+1 < length) && (text[uInt(i)] == '&') )
if ( i + 1 < length && text[uInt(i)] == '&' )
return uChar(text[uInt(++i)]);
}
catch (const std::out_of_range&)
{
return 0;;
return 0;
}
}
@ -582,7 +582,7 @@ void FButton::draw()
// + generate a new string without the '&'-sign
for (i = 0; i < length; i++)
{
if ( (i < length) && (txt[uInt(i)] == '&') && (hotkeypos == -1) )
if ( i < length && txt[uInt(i)] == '&' && hotkeypos == -1 )
{
hotkeypos = i;
i++;
@ -595,7 +595,7 @@ void FButton::draw()
if ( hotkeypos != -1 )
hotkey_offset = 1;
if ( (length - hotkey_offset + mono_offset - hotkey_offset) <= getWidth() )
if ( length - hotkey_offset + mono_offset - hotkey_offset <= getWidth() )
margin = 1;
else
margin = 0;

View File

@ -435,12 +435,12 @@ uChar FButtonGroup::getHotkey()
{
try
{
if ( (i+1 < length) && (text[i] == '&') )
if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]);
}
catch (const std::out_of_range&)
{
return 0;;
return 0;
}
}
return 0;

View File

@ -220,16 +220,19 @@ void FDialog::setPos (int x, int y, bool)
if ( dx > 0 )
{
if ( dy > 0 )
restoreVTerm (old_x+width+rsw-dx, old_y, dx, getHeight()+bsh-dy);
restoreVTerm ( old_x + width + rsw - dx, old_y
, dx, getHeight() + bsh - dy );
else
restoreVTerm (old_x+width+rsw-dx, old_y+std::abs(dy), dx, height+bsh-std::abs(dy));
restoreVTerm ( old_x + width + rsw - dx, old_y + std::abs(dy)
, dx, height + bsh - std::abs(dy));
}
else
{
if ( dy > 0 )
restoreVTerm (old_x, old_y, std::abs(dx), height + bsh - dy);
else
restoreVTerm (old_x, old_y+std::abs(dy), std::abs(dx), height+bsh-std::abs(dy));
restoreVTerm ( old_x, old_y + std::abs(dy)
, std::abs(dx), height + bsh - std::abs(dy) );
}
if ( dy > 0 )
@ -528,7 +531,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
{
int mouse_x = ev->getX();
int mouse_y = ev->getY();
int zoom_btn;;
int zoom_btn;
if ( ! isResizeable() )
zoom_btn = 0;

View File

@ -301,12 +301,12 @@ uChar FLabel::getHotkey()
{
try
{
if ( (i+1 < length) && (text[i] == '&') )
if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]);
}
catch (const std::out_of_range&)
{
return 0;;
return 0;
}
}
@ -323,7 +323,7 @@ int FLabel::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length)
for (uInt i = 0; i < length; i++)
{
if ( (i < length) && (txt[i] == L'&') && (hotkeypos == -1) )
if ( i < length && txt[i] == L'&' && hotkeypos == -1 )
{
hotkeypos = int(i);
i++;

View File

@ -252,7 +252,8 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
if ( cursor_pos >= len )
cursor_pos=len;
if ( cursor_pos-text_offset >= getWidth()-2 && text_offset <= len-getWidth()+1 )
if ( cursor_pos - text_offset >= getWidth() - 2
&& text_offset <= len - getWidth() + 1 )
text_offset++;
ev->accept();

View File

@ -1549,7 +1549,8 @@ void FListBox::drawList()
full_length = int(getString(iter).getLength());
if ( b+i < uInt(getWidth()-nf_offset-4) && xoffset <= full_length+1 )
if ( b + i < uInt(getWidth() - nf_offset - 4)
&& xoffset <= full_length + 1 )
{
if ( serach_mark && i == inc_len )
setColor ( wc.current_element_focus_fg

View File

@ -902,6 +902,7 @@ void FListView::onWheel (FWheelEvent* ev)
updateTerminal();
flush_out();
}
//----------------------------------------------------------------------
void FListView::onFocusIn (FFocusEvent*)
{

View File

@ -1206,7 +1206,7 @@ int FMenu::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length)
for (uInt i = 0; i < length; i++)
{
if ( (i < length) && (txt[i] == L'&') && (hotkeypos == -1) )
if ( i < length && txt[i] == L'&' && hotkeypos == -1 )
{
hotkeypos = int(i);
i++;

View File

@ -731,7 +731,7 @@ int FMenuBar::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length)
for (uInt i = 0; i < length; i++)
{
if ( (i < length) && (txt[i] == L'&') && (hotkeypos == -1) )
if ( i < length && txt[i] == L'&' && hotkeypos == -1 )
{
hotkeypos = int(i);
i++;

View File

@ -745,12 +745,12 @@ uChar FMenuItem::hotKey()
{
try
{
if ( (i+1 < length) && (text[i] == '&') )
if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]);
}
catch (const std::out_of_range&)
{
return 0;;
return 0;
}
}

View File

@ -620,24 +620,24 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
//----------------------------------------------------------------------
void FOptiMove::printDurations()
{
std::printf (" speed: %d baud\r\n", baudrate);
std::printf (" char_duration: %d ms\r\n", char_duration);
std::printf (" cursor_home: %d ms\r\n", F_cursor_home.duration);
std::printf (" cursor_to_ll: %d ms\r\n", F_cursor_to_ll.duration);
std::printf (" carriage_return: %d ms\r\n", F_carriage_return.duration);
std::printf (" tab: %d ms\r\n", F_tab.duration);
std::printf (" back_tab: %d ms\r\n", F_back_tab.duration);
std::printf (" cursor_up: %d ms\r\n", F_cursor_up.duration);
std::printf (" cursor_down: %d ms\r\n", F_cursor_down.duration);
std::printf (" cursor_left: %d ms\r\n", F_cursor_left.duration);
std::printf (" cursor_right: %d ms\r\n", F_cursor_right.duration);
std::printf (" cursor_address: %d ms\r\n", F_cursor_address.duration);
std::printf (" column_address: %d ms\r\n", F_column_address.duration);
std::printf (" row_address: %d ms\r\n", F_row_address.duration);
std::printf (" parm_up_cursor: %d ms\r\n", F_parm_up_cursor.duration);
std::printf (" parm_down_cursor: %d ms\r\n", F_parm_down_cursor.duration);
std::printf (" parm_left_cursor: %d ms\r\n", F_parm_left_cursor.duration);
std::printf ("parm_right_cursor: %d ms\r\n", F_parm_right_cursor.duration);
std::cout << " speed: " << baudrate << " baud\r\n";
std::cout << " char_duration: " << char_duration << " ms\r\n";
std::cout << " cursor_home: " << F_cursor_home.duration << " ms\r\n";
std::cout << " cursor_to_ll: " << F_cursor_to_ll.duration << " ms\r\n";
std::cout << " carriage_return: " << F_carriage_return.duration << " ms\r\n";
std::cout << " tab: " << F_tab.duration << " ms\r\n";
std::cout << " back_tab: " << F_back_tab.duration << " ms\r\n";
std::cout << " cursor_up: " << F_cursor_up.duration << " ms\r\n";
std::cout << " cursor_down: " << F_cursor_down.duration << " ms\r\n";
std::cout << " cursor_left: " << F_cursor_left.duration << " ms\r\n";
std::cout << " cursor_right: " << F_cursor_right.duration << " ms\r\n";
std::cout << " cursor_address: " << F_cursor_address.duration << " ms\r\n";
std::cout << " column_address: " << F_column_address.duration << " ms\r\n";
std::cout << " row_address: " << F_row_address.duration << " ms\r\n";
std::cout << " parm_up_cursor: " << F_parm_up_cursor.duration << " ms\r\n";
std::cout << " parm_down_cursor: " << F_parm_down_cursor.duration << " ms\r\n";
std::cout << " parm_left_cursor: " << F_parm_left_cursor.duration << " ms\r\n";
std::cout << "parm_right_cursor: " << F_parm_right_cursor.duration << " ms\r\n";
}

View File

@ -22,6 +22,7 @@
#include <cstdio> // need for printf
#include <cstdlib>
#include <cstring>
#include <iostream>
//----------------------------------------------------------------------

View File

@ -416,19 +416,22 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
{
if ( bar_orientation == fc::vertical )
{
if ( mouse_y > slider_pos+1 && mouse_y <= slider_pos+slider_length+1 )
if ( mouse_y > slider_pos + 1
&& mouse_y <= slider_pos + slider_length + 1 )
slider_click_pos = mouse_y; // on slider
}
else // horizontal
{
if ( isNewFont() )
{
if ( mouse_x > slider_pos+2 && mouse_x <= slider_pos+slider_length+2 )
if ( mouse_x > slider_pos + 2
&& mouse_x <= slider_pos + slider_length + 2 )
slider_click_pos = mouse_x; // on slider
}
else
{
if ( mouse_x > slider_pos+1 && mouse_x <= slider_pos+slider_length+1 )
if ( mouse_x > slider_pos + 1
&& mouse_x <= slider_pos + slider_length + 1 )
slider_click_pos = mouse_x; // on slider
}
}

View File

@ -2344,7 +2344,7 @@ inline void FString::_remove (uInt pos, uInt len)
if ( (bufsize - length - 1 + len) <= FWDBUFFER )
{
// shifting left side to pos
for (uInt i=pos; (i+len) < length+1; i++)
for (uInt i = pos; i + len < length + 1; i++)
string[i] = string[i + len];
length -= len;

View File

@ -407,12 +407,12 @@ uChar FToggleButton::getHotkey()
{
try
{
if ( (i+1 < length) && (text[i] == '&') )
if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]);
}
catch (const std::out_of_range&)
{
return 0;;
return 0;
}
}
@ -514,7 +514,7 @@ void FToggleButton::drawLabel()
// + generate a new string without the '&'-sign
for (i = 0; i < length; i++)
{
if ( (i < length) && (txt[i] == '&') && (hotkeypos == -1) )
if ( i < length && txt[i] == '&' && hotkeypos == -1 )
{
hotkeypos = int(i);
i++;