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> 2017-08-24 Markus Gans <guru.mail@muenster.de>
* Rename fapp.{cpp,h} to fapplication.{cpp,h} * Rename fapp.{cpp,h} to fapplication.{cpp,h}

View File

@ -423,7 +423,7 @@ int FApplication::gpmEvent (bool clear)
FD_SET(gpm_fd, &ifds); FD_SET(gpm_fd, &ifds);
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 100000; // 100 ms tv.tv_usec = 100000; // 100 ms
result = select (max+1, &ifds, 0, 0, &tv); result = select (max + 1, &ifds, 0, 0, &tv);
if ( FD_ISSET(stdin_no, &ifds) ) if ( FD_ISSET(stdin_no, &ifds) )
{ {
@ -454,7 +454,7 @@ inline bool FApplication::KeyPressed()
FD_SET(stdin_no, &ifds); FD_SET(stdin_no, &ifds);
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 100000; // 100 ms tv.tv_usec = 100000; // 100 ms
result = select (stdin_no+1, &ifds, 0, 0, &tv); result = select (stdin_no + 1, &ifds, 0, 0, &tv);
if ( FD_ISSET(stdin_no, &ifds) ) if ( FD_ISSET(stdin_no, &ifds) )
FD_CLR (stdin_no, &ifds); FD_CLR (stdin_no, &ifds);
@ -467,7 +467,7 @@ inline ssize_t FApplication::readKey()
{ {
register ssize_t bytes; register ssize_t bytes;
setNonBlockingInput(); setNonBlockingInput();
bytes = read(stdin_no, &k_buf, sizeof(k_buf)-1); bytes = read(stdin_no, &k_buf, sizeof(k_buf) - 1);
unsetNonBlockingInput(); unsetNonBlockingInput();
return bytes; return bytes;
} }
@ -546,7 +546,7 @@ void FApplication::processKeyboardEvent()
{ {
if ( bytesread + fifo_offset <= fifo_buf_size ) if ( bytesread + fifo_offset <= fifo_buf_size )
{ {
for (int i=0; i < bytesread; i++) for (int i = 0; i < bytesread; i++)
{ {
fifo_buf[fifo_offset] = k_buf[i]; fifo_buf[fifo_offset] = k_buf[i];
fifo_offset++; fifo_offset++;
@ -585,14 +585,14 @@ void FApplication::processKeyboardEvent()
x11_mouse[3] = '\0'; x11_mouse[3] = '\0';
// Remove founded entry // Remove founded entry
for (n=len; n < fifo_buf_size; n++) for (n = len; n < fifo_buf_size; n++)
fifo_buf[n-len] = fifo_buf[n]; fifo_buf[n - len] = fifo_buf[n];
n = fifo_buf_size - len - 1; n = fifo_buf_size - len - 1;
// Fill rest with '\0' // Fill rest with '\0'
for (; n < fifo_buf_size; n++) for (; n < fifo_buf_size; n++)
fifo_buf[n-len] = '\0'; fifo_buf[n - len] = '\0';
unprocessedInput() = bool(fifo_buf[0] != '\0'); unprocessedInput() = bool(fifo_buf[0] != '\0');
processMouseEvent(); processMouseEvent();
@ -606,22 +606,22 @@ void FApplication::processKeyboardEvent()
while ( n < len && n < fifo_buf_size ) while ( n < len && n < fifo_buf_size )
{ {
sgr_mouse[n-3] = fifo_buf[n]; sgr_mouse[n - 3] = fifo_buf[n];
n++; n++;
if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' ) if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' )
len = n + 1; len = n + 1;
} }
sgr_mouse[n-3] = '\0'; sgr_mouse[n - 3] = '\0';
for (n=len; n < fifo_buf_size; n++) // Remove founded entry for (n = len; n < fifo_buf_size; n++) // Remove founded entry
fifo_buf[n-len] = fifo_buf[n]; fifo_buf[n - len] = fifo_buf[n];
n = fifo_buf_size-len-1; n = fifo_buf_size - len - 1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0' for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0'; fifo_buf[n - len] = '\0';
unprocessedInput() = bool(fifo_buf[0] != '\0'); unprocessedInput() = bool(fifo_buf[0] != '\0');
processMouseEvent(); processMouseEvent();
@ -635,22 +635,22 @@ void FApplication::processKeyboardEvent()
while ( n < len && n < fifo_buf_size ) while ( n < len && n < fifo_buf_size )
{ {
urxvt_mouse[n-2] = fifo_buf[n]; urxvt_mouse[n - 2] = fifo_buf[n];
n++; n++;
if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' ) if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' )
len = n + 1; len = n + 1;
} }
urxvt_mouse[n-2] = '\0'; urxvt_mouse[n - 2] = '\0';
for (n=len; n < fifo_buf_size; n++) // Remove founded entry for (n = len; n < fifo_buf_size; n++) // Remove founded entry
fifo_buf[n-len] = fifo_buf[n]; fifo_buf[n - len] = fifo_buf[n];
n = fifo_buf_size-len-1; n = fifo_buf_size - len - 1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0' for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0'; fifo_buf[n - len] = '\0';
unprocessedInput() = bool(fifo_buf[0] != '\0'); unprocessedInput() = bool(fifo_buf[0] != '\0');
processMouseEvent(); processMouseEvent();
@ -1024,7 +1024,7 @@ bool FApplication::processDialogSwitchAccelerator()
} }
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget); FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
sendEvent (dialog_list->at(n-1), &a_ev); sendEvent (dialog_list->at(n - 1), &a_ev);
return true; return true;
} }
} }

View File

@ -255,7 +255,7 @@ void FButton::hide()
try try
{ {
blank = new char[size+1]; blank = new char[size + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -265,9 +265,9 @@ void FButton::hide()
std::memset(blank, ' ', uLong(size)); std::memset(blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < getHeight()+s+(f << 1); y++) for (int y = 0; y < getHeight() + s + (f << 1); y++)
{ {
setPrintPos (1-f, 1+y-f); setPrintPos (1 - f, 1 + y - f);
print (blank); print (blank);
} }
@ -444,16 +444,16 @@ uChar FButton::getHotkey()
length = int(text.getLength()); length = int(text.getLength());
for (int i=0; i < length; i++) for (int i = 0; i < length; i++)
{ {
try try
{ {
if ( (i+1 < length) && (text[uInt(i)] == '&') ) if ( i + 1 < length && text[uInt(i)] == '&' )
return uChar(text[uInt(++i)]); return uChar(text[uInt(++i)]);
} }
catch (const std::out_of_range&) catch (const std::out_of_range&)
{ {
return 0;; return 0;
} }
} }
@ -513,9 +513,9 @@ void FButton::draw()
try try
{ {
if ( isMonochron() || getMaxColor() < 16 ) if ( isMonochron() || getMaxColor() < 16 )
ButtonText = new wchar_t[length+3](); ButtonText = new wchar_t[length + 3]();
else else
ButtonText = new wchar_t[length+1](); ButtonText = new wchar_t[length + 1]();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -532,7 +532,7 @@ void FButton::draw()
is_Active = ((flags & fc::active) != 0); is_Active = ((flags & fc::active) != 0);
is_Focus = ((flags & fc::focus) != 0); is_Focus = ((flags & fc::focus) != 0);
is_Flat = isFlat(); is_Flat = isFlat();
is_NonFlatShadow = ((flags & (fc::shadow+fc::flat)) == fc::shadow); is_NonFlatShadow = ((flags & (fc::shadow + fc::flat)) == fc::shadow);
is_NoUnderline = ((flags & fc::no_underline) != 0); is_NoUnderline = ((flags & fc::no_underline) != 0);
if ( isMonochron() ) if ( isMonochron() )
@ -550,7 +550,7 @@ void FButton::draw()
setColor ( parent_widget->getForegroundColor() setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() ); , parent_widget->getBackgroundColor() );
for (int y=1; y <= getHeight(); y++) for (int y = 1; y <= getHeight(); y++)
{ {
setPrintPos (1, y); setPrintPos (1, y);
print (' '); // clear one left █ print (' '); // clear one left █
@ -580,9 +580,9 @@ void FButton::draw()
// find hotkey position in string // find hotkey position in string
// + generate a new string without the '&'-sign // + generate a new string without the '&'-sign
for (i=0; i < length; i++) for (i = 0; i < length; i++)
{ {
if ( (i < length) && (txt[uInt(i)] == '&') && (hotkeypos == -1) ) if ( i < length && txt[uInt(i)] == '&' && hotkeypos == -1 )
{ {
hotkeypos = i; hotkeypos = i;
i++; i++;
@ -595,7 +595,7 @@ void FButton::draw()
if ( hotkeypos != -1 ) if ( hotkeypos != -1 )
hotkey_offset = 1; hotkey_offset = 1;
if ( (length - hotkey_offset + mono_offset - hotkey_offset) <= getWidth() ) if ( length - hotkey_offset + mono_offset - hotkey_offset <= getWidth() )
margin = 1; margin = 1;
else else
margin = 0; margin = 0;
@ -607,9 +607,9 @@ void FButton::draw()
{ {
setColor (getForegroundColor(), button_bg); setColor (getForegroundColor(), button_bg);
for (int y=0; y < getHeight(); y++) for (int y = 0; y < getHeight(); y++)
{ {
setPrintPos (1+d, 1+y); setPrintPos (1 + d, 1 + y);
print (space); // full block █ print (space); // full block █
} }
} }
@ -626,12 +626,12 @@ void FButton::draw()
setColor ( parent_widget->getForegroundColor() setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() ); , parent_widget->getBackgroundColor() );
for (int y=1; y <= getHeight(); y++) for (int y = 1; y <= getHeight(); y++)
{ {
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
setPrintPos (1+getWidth(), y); setPrintPos (1 + getWidth(), y);
print (' '); // clear right print (' '); // clear right
if ( isMonochron() ) if ( isMonochron() )
@ -646,25 +646,25 @@ void FButton::draw()
i = int(i / 2); i = int(i / 2);
if ( getHeight() >= 2 ) if ( getHeight() >= 2 )
j = int((getHeight()-1) / 2); j = int((getHeight() - 1) / 2);
else else
j=0; j=0;
setPrintPos (1+margin+d, 1+j); setPrintPos (1 + margin + d, 1 + j);
setColor (button_fg, button_bg); setColor (button_fg, button_bg);
for (x=0; x < i; x++) for (x = 0; x < i; x++)
print (space); // █ print (space); // █
if ( hotkeypos == -1 ) if ( hotkeypos == -1 )
setCursorPos (1+margin+i+mono_1st_char, 1+j ); // first character setCursorPos (1 + margin + i + mono_1st_char, 1 + j ); // first character
else else
setCursorPos (1+margin+i+hotkeypos, 1+j ); // hotkey setCursorPos (1 + margin + i + hotkeypos, 1 + j ); // hotkey
if ( is_ActiveFocus && (isMonochron() || getMaxColor() < 16) ) if ( is_ActiveFocus && (isMonochron() || getMaxColor() < 16) )
setBold(); setBold();
for (int z=0; x < i+length && z < getWidth(); z++,x++) for (int z = 0; x < i + length && z < getWidth(); z++,x++)
{ {
if ( (z == hotkeypos) && is_Active ) if ( (z == hotkeypos) && is_Active )
{ {
@ -695,23 +695,23 @@ void FButton::draw()
if ( is_ActiveFocus && (isMonochron() || getMaxColor() < 16) ) if ( is_ActiveFocus && (isMonochron() || getMaxColor() < 16) )
unsetBold(); unsetBold();
for (x=i+length; x < getWidth()-1; x++) for (x = i + length; x < getWidth() - 1; x++)
print (space); // █ print (space); // █
if ( getHeight() >= 2 ) if ( getHeight() >= 2 )
{ {
for (i=0; i < j; i++) for (i = 0; i < j; i++)
{ {
setPrintPos (2+d, 1+i); setPrintPos (2 + d, 1 + i);
for (int z=1; z < getWidth(); z++) for (int z = 1; z < getWidth(); z++)
print (space); // █ print (space); // █
} }
for (i=j+1; i < getHeight(); i++) for (i = j + 1; i < getHeight(); i++)
{ {
setPrintPos (2+d, 1+i); setPrintPos (2 + d, 1 + i);
for (int z=1; z < getWidth(); z++) for (int z = 1; z < getWidth(); z++)
print (space); // █ print (space); // █
} }
} }

View File

@ -208,7 +208,7 @@ void FButtonGroup::hide()
try try
{ {
blank = new char[size+1]; blank = new char[size + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -219,9 +219,9 @@ void FButtonGroup::hide()
std::memset(blank, ' ', uLong(size)); std::memset(blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < getHeight(); y++) for (int y = 0; y < getHeight(); y++)
{ {
FWidget::setPrintPos (1, 1+y); FWidget::setPrintPos (1, 1 + y);
print (blank); print (blank);
} }
@ -431,16 +431,16 @@ uChar FButtonGroup::getHotkey()
length = text.getLength(); length = text.getLength();
for (uInt i=0; i < length; i++) for (uInt i = 0; i < length; i++)
{ {
try try
{ {
if ( (i+1 < length) && (text[i] == '&') ) if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]); return uChar(text[++i]);
} }
catch (const std::out_of_range&) catch (const std::out_of_range&)
{ {
return 0;; return 0;
} }
} }
return 0; return 0;
@ -503,7 +503,7 @@ void FButtonGroup::drawLabel()
try try
{ {
LabelText = new wchar_t[length+1](); LabelText = new wchar_t[length + 1]();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -520,7 +520,7 @@ void FButtonGroup::drawLabel()
// find hotkey position in string // find hotkey position in string
// + generate a new string without the '&'-sign // + generate a new string without the '&'-sign
for (uInt i=0; i < length; i++) for (uInt i = 0; i < length; i++)
{ {
if ( (i < length) && (txt[i] == '&') && (hotkeypos == -1) ) if ( (i < length) && (txt[i] == '&') && (hotkeypos == -1) )
{ {
@ -544,7 +544,7 @@ void FButtonGroup::drawLabel()
else else
setColor(wc.label_inactive_fg, wc.label_inactive_bg); setColor(wc.label_inactive_fg, wc.label_inactive_bg);
for (int z=0; z < int(length); z++) for (int z = 0; z < int(length); z++)
{ {
if ( (z == hotkeypos) && isActive ) if ( (z == hotkeypos) && isActive )
{ {

View File

@ -188,7 +188,7 @@ void FDialog::setPos (int x, int y, bool)
height = getHeight(); height = getHeight();
// Avoid to move widget completely outside the terminal // Avoid to move widget completely outside the terminal
if ( x+width <= 1 || x > getMaxWidth() || y < 1 || y > getMaxHeight() ) if ( x + width <= 1 || x > getMaxWidth() || y < 1 || y > getMaxHeight() )
return; return;
if ( isZoomed() ) if ( isZoomed() )
@ -220,22 +220,25 @@ void FDialog::setPos (int x, int y, bool)
if ( dx > 0 ) if ( dx > 0 )
{ {
if ( dy > 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 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 else
{ {
if ( dy > 0 ) if ( dy > 0 )
restoreVTerm (old_x, old_y, std::abs(dx), height+bsh-dy); restoreVTerm (old_x, old_y, std::abs(dx), height + bsh - dy);
else 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 ) if ( dy > 0 )
restoreVTerm (old_x, old_y+height+bsh-dy, width+rsw, dy); restoreVTerm (old_x, old_y + height + bsh - dy, width + rsw, dy);
else else
restoreVTerm (old_x, old_y, width+rsw, std::abs(dy)); restoreVTerm (old_x, old_y, width + rsw, std::abs(dy));
} }
else else
{ {
@ -321,10 +324,10 @@ void FDialog::setSize (int w, int h, bool adjust)
// restoring the non-covered terminal areas // restoring the non-covered terminal areas
if ( dw > 0 ) if ( dw > 0 )
restoreVTerm (x+w+rsw, y, dw, h+bsh+dh); // restore right restoreVTerm (x + w + rsw, y, dw, h + bsh + dh); // restore right
if ( dh > 0 ) if ( dh > 0 )
restoreVTerm (x, y+h+bsh, w+rsw+dw, dh); // restore bottom restoreVTerm (x, y + h + bsh, w + rsw + dw, dh); // restore bottom
redraw(); redraw();
@ -528,7 +531,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
{ {
int mouse_x = ev->getX(); int mouse_x = ev->getX();
int mouse_y = ev->getY(); int mouse_y = ev->getY();
int zoom_btn;; int zoom_btn;
if ( ! isResizeable() ) if ( ! isResizeable() )
zoom_btn = 0; zoom_btn = 0;
@ -549,7 +552,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
bool has_raised; bool has_raised;
// click on titlebar or window: raise + activate // click on titlebar or window: raise + activate
if ( mouse_x >= 4 && mouse_x <= getWidth()-zoom_btn && mouse_y == 1 ) if ( mouse_x >= 4 && mouse_x <= getWidth() - zoom_btn && mouse_y == 1 )
titlebar_click_pos.setPoint (ev->getTermX(), ev->getTermY()); titlebar_click_pos.setPoint (ev->getTermX(), ev->getTermY());
else else
titlebar_click_pos.setPoint (0,0); titlebar_click_pos.setPoint (0,0);
@ -565,7 +568,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
// click on titlebar menu button // click on titlebar menu button
if ( mouse_x < 4 && mouse_y == 1 ) if ( mouse_x < 4 && mouse_y == 1 )
openMenu(); openMenu();
else if ( mouse_x > getWidth()-zoom_btn && mouse_y == 1 ) else if ( mouse_x > getWidth() - zoom_btn && mouse_y == 1 )
{ {
zoom_button_pressed = true; zoom_button_pressed = true;
zoom_button_active = true; zoom_button_active = true;
@ -575,8 +578,8 @@ void FDialog::onMouseDown (FMouseEvent* ev)
// click on the lower right resize corner // click on the lower right resize corner
if ( isResizeable() if ( isResizeable()
&& ( (mouse_x == getWidth() && mouse_y == getHeight()) && ( (mouse_x == getWidth() && mouse_y == getHeight())
|| (mouse_x == getWidth()-1 && mouse_y == getHeight()) || (mouse_x == getWidth() - 1 && mouse_y == getHeight())
|| (mouse_x == getWidth() && mouse_y == getHeight()-1) ) ) || (mouse_x == getWidth() && mouse_y == getHeight() - 1) ) )
{ {
resize_click_pos = ev->getTermPos(); resize_click_pos = ev->getTermPos();
FPoint lower_right_pos = getTermGeometry().getLowerRightPos(); FPoint lower_right_pos = getTermGeometry().getLowerRightPos();
@ -1088,7 +1091,7 @@ void FDialog::init()
return; return;
} }
dialog_menu->setPos (getX(), getY()+1); dialog_menu->setPos (getX(), getY() + 1);
dgl_menuitem = dialog_menu->getItem(); dgl_menuitem = dialog_menu->getItem();
if ( dgl_menuitem ) if ( dgl_menuitem )
@ -1170,7 +1173,7 @@ void FDialog::drawBorder()
if ( isNewFont() ) if ( isNewFont() )
{ {
for (int y=y1; y < y2; y++) for (int y = y1; y < y2; y++)
{ {
setPrintPos (x1, y); setPrintPos (x1, y);
// border left ⎸ // border left ⎸
@ -1184,7 +1187,7 @@ void FDialog::drawBorder()
// lower left corner border ⎣ // lower left corner border ⎣
print (fc::NF_border_corner_lower_left); print (fc::NF_border_corner_lower_left);
for (int x=1; x < getWidth()-1; x++) // low line _ for (int x = 1; x < getWidth() - 1; x++) // low line _
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
setPrintPos (x2, y2); setPrintPos (x2, y2);
@ -1269,7 +1272,7 @@ void FDialog::drawTitleBar()
i = getWidth() - length - menu_btn - zoom_btn; i = getWidth() - length - menu_btn - zoom_btn;
i = int(i/2); i = int(i/2);
for (x=1; x <= i; x++) for (x = 1; x <= i; x++)
print (' '); print (' ');
// the title bar text // the title bar text
@ -1285,7 +1288,7 @@ void FDialog::drawTitleBar()
} }
// fill the rest of the bar // fill the rest of the bar
for (; x+1+length < getWidth()-zoom_btn-1; x++) for ( ; x + 1 + length < getWidth() - zoom_btn - 1; x++)
print (' '); print (' ');
if ( getMaxColor() < 16 ) if ( getMaxColor() < 16 )
@ -1351,7 +1354,7 @@ void FDialog::drawTitleBar()
setReverse(false); setReverse(false);
/* print the number of window in stack */ /* print the number of window in stack */
//setPrintPos (getWidth()-2, 1); //setPrintPos (getWidth() - 2, 1);
//printf ("(%d)", getWindowLayer(this)); //printf ("(%d)", getWindowLayer(this));
} }
@ -1390,7 +1393,7 @@ void FDialog::openMenu()
else else
{ {
setOpenMenu(dialog_menu); setOpenMenu(dialog_menu);
dialog_menu->setPos (getX(), getY()+1); dialog_menu->setPos (getX(), getY() + 1);
dialog_menu->setVisible(); dialog_menu->setVisible();
drawTitleBar(); drawTitleBar();
dialog_menu->show(); dialog_menu->show();

View File

@ -182,7 +182,7 @@ void FFileDialog::setPath (const FString& dir)
else else
r_dir = dir; r_dir = dir;
if ( r_dir[r_dir.getLength()-1] != '/' ) if ( r_dir[r_dir.getLength() - 1] != '/' )
directory = r_dir + "/"; directory = r_dir + "/";
else else
directory = r_dir; directory = r_dir;
@ -326,11 +326,11 @@ int FFileDialog::readDir()
dir_num = numOfDirs(); dir_num = numOfDirs();
// directories first // directories first
std::sort(dir_entries.begin()+start, dir_entries.end(), sortDirFirst); std::sort(dir_entries.begin() + start, dir_entries.end(), sortDirFirst);
// sort directories by name // sort directories by name
std::sort(dir_entries.begin()+start, dir_entries.begin()+dir_num, sortByName); std::sort(dir_entries.begin() + start, dir_entries.begin() + dir_num, sortByName);
// sort files by name // sort files by name
std::sort(dir_entries.begin()+dir_num, dir_entries.end(), sortByName); std::sort(dir_entries.begin() + dir_num, dir_entries.end(), sortByName);
// fill list with directory entries // fill list with directory entries
filebrowser->clear(); filebrowser->clear();
@ -472,10 +472,10 @@ void FFileDialog::adjustSize()
X = 1 + int((max_width - getWidth()) / 2); X = 1 + int((max_width - getWidth()) / 2);
Y = 1 + int((max_height - getHeight()) / 3); Y = 1 + int((max_height - getHeight()) / 3);
setPos(X, Y, false); setPos(X, Y, false);
filebrowser->setHeight (h-8, false); filebrowser->setHeight (h - 8, false);
hidden->setY(h-4, false); hidden->setY (h - 4, false);
cancel->setY(h-4, false); cancel->setY (h - 4, false);
open->setY(h-4, false); open->setY (h - 4, false);
FDialog::adjustSize(); FDialog::adjustSize();
printPath(directory); printPath(directory);
} }
@ -495,8 +495,8 @@ void FFileDialog::init()
if ( parent_widget ) if ( parent_widget )
{ {
x = 1 + int((parent_widget->getWidth()-w)/2); x = 1 + int((parent_widget->getWidth() - w) / 2);
y = 1 + int((parent_widget->getHeight()-h)/3); y = 1 + int((parent_widget->getHeight() - h) / 3);
} }
else else
x = y = 1; x = y = 1;
@ -739,7 +739,7 @@ void FFileDialog::printPath (const FString& txt)
uInt max_width = uInt(filebrowser->getWidth()) - 4; uInt max_width = uInt(filebrowser->getWidth()) - 4;
if ( path.getLength() > max_width ) if ( path.getLength() > max_width )
filebrowser->setText(".." + path.right(max_width-2)); filebrowser->setText(".." + path.right(max_width - 2));
else else
filebrowser->setText(path); filebrowser->setText(path);
} }
@ -805,9 +805,9 @@ void FFileDialog::cb_processRowChanged (FWidget*, data_ptr)
if ( n == 0 ) if ( n == 0 )
return; return;
FString name = dir_entries[uLong(n-1)].name; FString name = dir_entries[uLong(n - 1)].name;
if ( dir_entries[uLong(n-1)].type == DT_DIR ) if ( dir_entries[uLong(n - 1)].type == DT_DIR )
filename->setText( name + '/' ); filename->setText( name + '/' );
else else
filename->setText( name ); filename->setText( name );

View File

@ -160,7 +160,7 @@ void FLabel::hide()
try try
{ {
blank = new char[size+1]; blank = new char[size + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -297,16 +297,16 @@ uChar FLabel::getHotkey()
length = text.getLength(); length = text.getLength();
for (uInt i=0; i < length; i++) for (uInt i = 0; i < length; i++)
{ {
try try
{ {
if ( (i+1 < length) && (text[i] == '&') ) if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]); return uChar(text[++i]);
} }
catch (const std::out_of_range&) catch (const std::out_of_range&)
{ {
return 0;; return 0;
} }
} }
@ -321,9 +321,9 @@ int FLabel::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length)
int hotkeypos = -1; int hotkeypos = -1;
wchar_t* txt = src; wchar_t* txt = src;
for (uInt i=0; i < length; i++) 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); hotkeypos = int(i);
i++; i++;
@ -403,7 +403,7 @@ void FLabel::printLine ( wchar_t*& line
if ( hasReverseMode() ) if ( hasReverseMode() )
setReverse(true); setReverse(true);
for (int z=0; z < to_char; z++) for (int z = 0; z < to_char; z++)
{ {
if ( ! std::iswprint(wint_t(line[z])) ) if ( ! std::iswprint(wint_t(line[z])) )
{ {
@ -489,7 +489,7 @@ void FLabel::draw()
try try
{ {
LabelText = new wchar_t[length+1](); LabelText = new wchar_t[length + 1]();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -505,12 +505,12 @@ void FLabel::draw()
else else
std::wcsncpy(dest, src, length); std::wcsncpy(dest, src, length);
setPrintPos (1, 1+int(y)); setPrintPos (1, 1 + int(y));
if ( hotkeypos != -1 ) if ( hotkeypos != -1 )
{ {
align_offset = getAlignOffset (int(length-1)); align_offset = getAlignOffset (int(length - 1));
printLine (LabelText, length-1, hotkeypos, align_offset); printLine (LabelText, length - 1, hotkeypos, align_offset);
hotkey_printed = true; hotkey_printed = true;
hotkeypos = -1; hotkeypos = -1;
} }
@ -530,7 +530,7 @@ void FLabel::draw()
try try
{ {
LabelText = new wchar_t[length+1](); LabelText = new wchar_t[length + 1]();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {

View File

@ -195,7 +195,7 @@ void FLineEdit::hide()
try try
{ {
blank = new char[size+1]; blank = new char[size + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -206,9 +206,9 @@ void FLineEdit::hide()
std::memset(blank, ' ', uLong(size)); std::memset(blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < getHeight()+s; y++) for (int y = 0; y < getHeight() + s; y++)
{ {
setPrintPos (1, 1+y); setPrintPos (1, 1 + y);
print (blank); print (blank);
} }
@ -252,7 +252,8 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
if ( cursor_pos >= len ) if ( cursor_pos >= len )
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++; text_offset++;
ev->accept(); ev->accept();
@ -266,8 +267,8 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
case fc::Fkey_end: case fc::Fkey_end:
cursor_pos=len; cursor_pos=len;
if ( cursor_pos >= getWidth()-1 ) if ( cursor_pos >= getWidth() - 1 )
text_offset=len-getWidth()+2; text_offset = len - getWidth() + 2;
ev->accept(); ev->accept();
break; break;
@ -282,9 +283,9 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
cursor_pos=len; cursor_pos=len;
if ( cursor_pos < 0 ) if ( cursor_pos < 0 )
cursor_pos=0; cursor_pos = 0;
if ( text_offset > 0 && len-text_offset < getWidth()-1 ) if ( text_offset > 0 && len - text_offset < getWidth() - 1 )
text_offset--; text_offset--;
ev->accept(); ev->accept();
@ -294,7 +295,7 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
case fc::Fkey_backspace: case fc::Fkey_backspace:
if ( len > 0 && cursor_pos > 0 ) if ( len > 0 && cursor_pos > 0 )
{ {
text.remove(uInt(cursor_pos-1), 1); text.remove(uInt(cursor_pos - 1), 1);
processChanged(); processChanged();
cursor_pos--; cursor_pos--;
@ -350,7 +351,7 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
} }
cursor_pos++; cursor_pos++;
if ( cursor_pos >= getWidth()-1 ) if ( cursor_pos >= getWidth() - 1 )
text_offset++; text_offset++;
ev->accept(); ev->accept();
@ -463,14 +464,14 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
else if ( mouse_x >= getWidth() ) else if ( mouse_x >= getWidth() )
{ {
// drag right // drag right
if ( ! scroll_timer && text_offset <= len-getWidth()+1 ) if ( ! scroll_timer && text_offset <= len - getWidth() + 1 )
{ {
scroll_timer = true; scroll_timer = true;
addTimer(scroll_repeat); addTimer(scroll_repeat);
drag_scroll = FLineEdit::scrollRight; drag_scroll = FLineEdit::scrollRight;
} }
if ( text_offset == len-getWidth()+2 ) if ( text_offset == len - getWidth() + 2 )
{ {
delOwnTimer(); delOwnTimer();
drag_scroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
@ -515,7 +516,7 @@ void FLineEdit::onTimer (FTimerEvent*)
break; break;
case FLineEdit::scrollRight: case FLineEdit::scrollRight:
if ( text_offset == len-getWidth()+2 ) if ( text_offset == len - getWidth() + 2 )
{ {
drag_scroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
return; return;
@ -523,8 +524,8 @@ void FLineEdit::onTimer (FTimerEvent*)
text_offset++; text_offset++;
if ( text_offset > len-getWidth()+2 ) if ( text_offset > len - getWidth() + 2 )
text_offset = len-getWidth()+2; text_offset = len - getWidth() + 2;
cursor_pos++; cursor_pos++;
@ -623,11 +624,11 @@ void FLineEdit::adjustLabel()
switch ( label_orientation ) switch ( label_orientation )
{ {
case label_above: case label_above:
label->setGeometry(getX(), getY()-1, label_length, 1); label->setGeometry(getX(), getY() - 1, label_length, 1);
break; break;
case label_left: case label_left:
label->setGeometry(getX()-label_length-1, getY(), label_length, 1); label->setGeometry(getX() - label_length - 1, getY(), label_length, 1);
break; break;
} }
} }
@ -727,7 +728,7 @@ void FLineEdit::drawInputField()
if ( isActiveFocus && getMaxColor() < 16 ) if ( isActiveFocus && getMaxColor() < 16 )
setBold(); setBold();
show_text = text.mid(uInt(1+text_offset), uInt(getWidth()-2)); show_text = text.mid(uInt(1 + text_offset), uInt(getWidth() - 2));
if ( isUTF8_linux_terminal() ) if ( isUTF8_linux_terminal() )
{ {
@ -743,7 +744,7 @@ void FLineEdit::drawInputField()
x = int(show_text.getLength()); x = int(show_text.getLength());
while ( x < getWidth()-1 ) while ( x < getWidth() - 1 )
{ {
print (' '); print (' ');
x++; x++;
@ -762,7 +763,7 @@ void FLineEdit::drawInputField()
drawShadow (); drawShadow ();
// set the cursor to the first pos. // set the cursor to the first pos.
setCursorPos (2+cursor_pos-text_offset, 1); setCursorPos (2 + cursor_pos - text_offset, 1);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -174,13 +174,13 @@ void FListBox::setGeometry (int x, int y, int w, int h, bool adjust)
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (getWidth(), 2, 2, getHeight()-2); vbar->setGeometry (getWidth(), 2, 2, getHeight() - 2);
hbar->setGeometry (1, getHeight(), getWidth()-2, 1); hbar->setGeometry (1, getHeight(), getWidth() - 2, 1);
} }
else else
{ {
vbar->setGeometry (getWidth(), 2, 1, getHeight()-2); vbar->setGeometry (getWidth(), 2, 1, getHeight() - 2);
hbar->setGeometry (2, getHeight(), getWidth()-2, 1); hbar->setGeometry (2, getHeight(), getWidth() - 2, 1);
} }
} }
@ -245,7 +245,7 @@ void FListBox::hide()
try try
{ {
blank = new char[size+1]; blank = new char[size + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -256,7 +256,7 @@ void FListBox::hide()
std::memset (blank, ' ', uLong(size)); std::memset (blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < getHeight(); y++) for (int y = 0; y < getHeight(); y++)
{ {
setPrintPos (1, 1 + y); setPrintPos (1, 1 + y);
print (blank); print (blank);
@ -380,7 +380,7 @@ void FListBox::clear()
try try
{ {
blank = new char[size+1]; blank = new char[size + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -391,7 +391,7 @@ void FListBox::clear()
std::memset (blank, ' ', uLong(size)); std::memset (blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < getHeight()-2; y++) for (int y = 0; y < getHeight() - 2; y++)
{ {
setPrintPos (2, 2 + y); setPrintPos (2, 2 + y);
print (blank); print (blank);
@ -537,7 +537,7 @@ void FListBox::onKeyPress (FKeyEvent* ev)
if ( current > element_count ) if ( current > element_count )
current = element_count; current = element_count;
if ( current-yoffset >= getHeight() - 1 ) if ( current - yoffset >= getHeight() - 1 )
yoffset++; yoffset++;
ev->accept(); ev->accept();
@ -560,7 +560,7 @@ void FListBox::onKeyPress (FKeyEvent* ev)
{ {
if ( ! inc_found if ( ! inc_found
&& inc_search.toLower() && inc_search.toLower()
== iter->getText().left(inc_len+1).toLower() ) == iter->getText().left(inc_len + 1).toLower() )
{ {
setCurrentItem(iter); setCurrentItem(iter);
inc_found = true; inc_found = true;
@ -599,7 +599,7 @@ void FListBox::onKeyPress (FKeyEvent* ev)
if ( inc_len > 0 ) if ( inc_len > 0 )
{ {
inc_search.remove(inc_len-1, 1); inc_search.remove(inc_len - 1, 1);
if ( inc_len > 1 ) if ( inc_len > 1 )
{ {
@ -608,7 +608,7 @@ void FListBox::onKeyPress (FKeyEvent* ev)
while ( iter != data.end() ) while ( iter != data.end() )
{ {
if ( inc_search.toLower() if ( inc_search.toLower()
== iter->getText().left(inc_len-1).toLower() ) == iter->getText().left(inc_len - 1).toLower() )
{ {
setCurrentItem(iter); setCurrentItem(iter);
break; break;
@ -663,7 +663,7 @@ void FListBox::onKeyPress (FKeyEvent* ev)
if ( ! inc_found ) if ( ! inc_found )
{ {
inc_search.remove(inc_len-1, 1); inc_search.remove(inc_len - 1, 1);
if ( inc_len == 1 ) if ( inc_len == 1 )
ev->ignore(); ev->ignore();
@ -852,7 +852,7 @@ void FListBox::onMouseMove (FMouseEvent* ev)
from = secect_from_item + 1; from = secect_from_item + 1;
to = current; to = current;
} }
for (int i=from; i <= to; i++) for (int i = from; i <= to; i++)
{ {
if ( mouse_select ) if ( mouse_select )
{ {
@ -1100,7 +1100,7 @@ void FListBox::onWheel (FWheelEvent* ev)
if ( yoffset < 0 ) if ( yoffset < 0 )
{ {
current -= 4+yoffset; current -= 4 + yoffset;
yoffset=0; yoffset=0;
} }
else else
@ -1304,7 +1304,7 @@ void FListBox::draw()
{ {
setColor(); setColor();
for (int y=2; y < getHeight(); y++) for (int y = 2; y < getHeight(); y++)
{ {
setPrintPos (getWidth(),y); setPrintPos (getWidth(),y);
print (' '); // clear right side of the scrollbar print (' '); // clear right side of the scrollbar
@ -1360,7 +1360,7 @@ void FListBox::drawLabel()
print (txt); print (txt);
else else
{ {
print (text.left(uInt(getClientWidth()-2))); print (text.left(uInt(getClientWidth() - 2)));
setColor (wc.label_ellipsis_fg, wc.label_bg); setColor (wc.label_ellipsis_fg, wc.label_bg);
print(".."); print("..");
} }
@ -1398,7 +1398,7 @@ void FListBox::drawList()
iter = index2iterator(int(start) + yoffset); iter = index2iterator(int(start) + yoffset);
for (uInt y=start; y < end; y++) for (uInt y = start; y < end; y++)
{ {
bool serach_mark = false; bool serach_mark = false;
bool lineHasBrackets = hasBrackets(iter); bool lineHasBrackets = hasBrackets(iter);
@ -1524,12 +1524,12 @@ void FListBox::drawList()
break; break;
} }
element = getString(iter).mid ( uInt(1+xoffset) element = getString(iter).mid ( uInt(1 + xoffset)
, uInt(getWidth()-nf_offset-5) ); , uInt(getWidth() - nf_offset - 5) );
} }
else else
element = getString(iter).mid ( uInt(xoffset) element = getString(iter).mid ( uInt(xoffset)
, uInt(getWidth()-nf_offset-4) ); , uInt(getWidth() - nf_offset - 4) );
const wchar_t* const& element_str = element.wc_str(); const wchar_t* const& element_str = element.wc_str();
len = element.getLength(); len = element.getLength();
@ -1549,7 +1549,8 @@ void FListBox::drawList()
full_length = int(getString(iter).getLength()); 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 ) if ( serach_mark && i == inc_len )
setColor ( wc.current_element_focus_fg setColor ( wc.current_element_focus_fg
@ -1586,14 +1587,14 @@ void FListBox::drawList()
i++; i++;
} }
for (; b+i < uInt(getWidth()-nf_offset-3); i++) for (; b + i < uInt(getWidth() - nf_offset - 3); i++)
print (' '); print (' ');
} }
else // line has no brackets else // line has no brackets
{ {
uInt i, len; uInt i, len;
element = getString(iter).mid ( uInt(1+xoffset) element = getString(iter).mid ( uInt(1 + xoffset)
, uInt(getWidth()-nf_offset-4) ); , uInt(getWidth() - nf_offset - 4) );
const wchar_t* const& element_str = element.wc_str(); const wchar_t* const& element_str = element.wc_str();
len = element.getLength(); len = element.getLength();
@ -1601,7 +1602,7 @@ void FListBox::drawList()
setColor ( wc.current_inc_search_element_fg setColor ( wc.current_inc_search_element_fg
, wc.current_element_focus_bg ); , wc.current_element_focus_bg );
for (i=0; i < len; i++) for (i = 0; i < len; i++)
{ {
if ( serach_mark && i == inc_len ) if ( serach_mark && i == inc_len )
setColor ( wc.current_element_focus_fg setColor ( wc.current_element_focus_fg
@ -1616,7 +1617,7 @@ void FListBox::drawList()
i++; i++;
} }
for (; i < uInt(getWidth()-nf_offset-3); i++) for (; i < uInt(getWidth() - nf_offset - 3); i++)
print (' '); print (' ');
} }
@ -1853,7 +1854,7 @@ void FListBox::cb_HBarChange (FWidget*, data_ptr)
xoffset -= 4; xoffset -= 4;
if ( xoffset < 0 ) if ( xoffset < 0 )
xoffset=0; xoffset = 0;
break; break;

View File

@ -273,13 +273,13 @@ void FListView::setGeometry (int x, int y, int w, int h, bool adjust)
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (getWidth(), 2, 2, getHeight()-2); vbar->setGeometry (getWidth(), 2, 2, getHeight() - 2);
hbar->setGeometry (1, getHeight(), getWidth()-2, 1); hbar->setGeometry (1, getHeight(), getWidth() - 2, 1);
} }
else else
{ {
vbar->setGeometry (getWidth(), 2, 1, getHeight()-2); vbar->setGeometry (getWidth(), 2, 1, getHeight() - 2);
hbar->setGeometry (2, getHeight(), getWidth()-2, 1); hbar->setGeometry (2, getHeight(), getWidth() - 2, 1);
} }
} }
@ -403,7 +403,7 @@ void FListView::insert ( const std::vector<long>& cols
if ( ! cols.empty() ) if ( ! cols.empty() )
{ {
for (uInt i=0; i < cols.size(); i++) for (uInt i = 0; i < cols.size(); i++)
str_cols.push_back (FString().setNumber(cols[i])); str_cols.push_back (FString().setNumber(cols[i]));
} }
@ -437,7 +437,7 @@ void FListView::onKeyPress (FKeyEvent* ev)
current--; current--;
if ( current < 1 ) if ( current < 1 )
current=1; current = 1;
if ( current <= yoffset ) if ( current <= yoffset )
yoffset--; yoffset--;
@ -482,14 +482,14 @@ void FListView::onKeyPress (FKeyEvent* ev)
current -= getClientHeight() - 1; current -= getClientHeight() - 1;
if ( current < 1 ) if ( current < 1 )
current=1; current = 1;
if ( current <= yoffset ) if ( current <= yoffset )
{ {
yoffset -= getClientHeight() - 1; yoffset -= getClientHeight() - 1;
if ( yoffset < 0 ) if ( yoffset < 0 )
yoffset=0; yoffset = 0;
} }
ev->accept(); ev->accept();
@ -776,13 +776,13 @@ void FListView::onTimer (FTimerEvent*)
current -= scroll_distance; current -= scroll_distance;
if ( current < 1 ) if ( current < 1 )
current=1; current = 1;
if ( current <= yoffset ) if ( current <= yoffset )
yoffset -= scroll_distance; yoffset -= scroll_distance;
if ( yoffset < 0 ) if ( yoffset < 0 )
yoffset=0; yoffset = 0;
break; break;
case fc::scrollDown: case fc::scrollDown:
@ -854,7 +854,7 @@ void FListView::onWheel (FWheelEvent* ev)
if ( yoffset < 0 ) if ( yoffset < 0 )
{ {
current -= 4+yoffset; current -= 4 + yoffset;
yoffset=0; yoffset=0;
} }
else else
@ -902,6 +902,7 @@ void FListView::onWheel (FWheelEvent* ev)
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::onFocusIn (FFocusEvent*) void FListView::onFocusIn (FFocusEvent*)
{ {
@ -1067,7 +1068,7 @@ void FListView::draw()
{ {
setColor(); setColor();
for (int y=2; y < getHeight(); y++) for (int y = 2; y < getHeight(); y++)
{ {
setPrintPos (getWidth(),y); setPrintPos (getWidth(),y);
print (' '); // clear right side of the scrollbar print (' '); // clear right side of the scrollbar
@ -1203,7 +1204,7 @@ void FListView::drawList()
iter = index2iterator(int(start) + yoffset); iter = index2iterator(int(start) + yoffset);
for (uInt y=start; y < end; y++) for (uInt y = start; y < end; y++)
{ {
bool isCurrentLine = bool(y + uInt(yoffset) + 1 == uInt(current)); bool isCurrentLine = bool(y + uInt(yoffset) + 1 == uInt(current));
setPrintPos (2, 2 + int(y)); setPrintPos (2, 2 + int(y));
@ -1244,14 +1245,14 @@ void FListView::drawList()
// print columns // print columns
if ( ! (*iter)->column_line.empty() ) if ( ! (*iter)->column_line.empty() )
{ {
for (uInt i=0; i < (*iter)->column_line.size(); i++) for (uInt i = 0; i < (*iter)->column_line.size(); i++)
{ {
static const int leading_space = 1; static const int leading_space = 1;
static const int ellipsis_length = 2; static const int ellipsis_length = 2;
FString text = (*iter)->column_line[i]; FString text = (*iter)->column_line[i];
int width = header[i].width; int width = header[i].width;
uInt txt_length = text.getLength(); uInt txt_length = text.getLength();
fc::text_alignment align = getColumnAlignment(int(i+1)); fc::text_alignment align = getColumnAlignment(int(i + 1));
uInt align_offset = getAlignOffset (align, txt_length, uInt(width)); uInt align_offset = getAlignOffset (align, txt_length, uInt(width));
if ( align_offset > 0 ) if ( align_offset > 0 )
@ -1282,7 +1283,7 @@ void FListView::drawList()
uInt len = line.getLength(); uInt len = line.getLength();
uInt i; uInt i;
for (i=0; i < len; i++) for (i = 0; i < len; i++)
print (element_str[i]); print (element_str[i]);
for (; i < uInt(getWidth() - nf_offset - 2); i++) for (; i < uInt(getWidth() - nf_offset - 2); i++)
@ -1505,7 +1506,7 @@ void FListView::cb_HBarChange (FWidget*, data_ptr)
xoffset -= 4; xoffset -= 4;
if ( xoffset < 0 ) if ( xoffset < 0 )
xoffset=0; xoffset = 0;
break; break;

View File

@ -909,7 +909,7 @@ void FMenu::adjustItems()
int FMenu::adjustX (int x_pos) int FMenu::adjustX (int x_pos)
{ {
// Is menu outside on the right of the screen? // Is menu outside on the right of the screen?
if ( x_pos+int(max_item_width) >= getColumnNumber()-1 ) if ( x_pos + int(max_item_width) >= getColumnNumber() - 1 )
{ {
x_pos = getColumnNumber() - int(max_item_width + 1); x_pos = getColumnNumber() - int(max_item_width + 1);
// Menu to large for the screen // Menu to large for the screen
@ -1204,9 +1204,9 @@ int FMenu::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length)
int hotkeypos = -1; int hotkeypos = -1;
wchar_t* txt = src; wchar_t* txt = src;
for (uInt i=0; i < length; i++) 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); hotkeypos = int(i);
i++; i++;
@ -1346,7 +1346,7 @@ void FMenu::drawItems()
try try
{ {
item_text = new wchar_t[txt_length+1](); item_text = new wchar_t[txt_length + 1]();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -1385,7 +1385,7 @@ void FMenu::drawItems()
to_char--; to_char--;
} }
for (int z=0; z < to_char; z++) for (int z = 0; z < to_char; z++)
{ {
if ( ! std::iswprint(wint_t(item_text[z])) ) if ( ! std::iswprint(wint_t(item_text[z])) )
{ {
@ -1444,7 +1444,7 @@ void FMenu::drawItems()
if ( is_selected ) if ( is_selected )
{ {
for (uInt i=uInt(to_char+c); i < max_item_width - 1; i++) for (uInt i = uInt(to_char + c); i < max_item_width - 1; i++)
print (' '); print (' ');
} }
@ -1471,14 +1471,14 @@ inline void FMenu::drawSeparator(int y)
if ( isNewFont() ) if ( isNewFont() )
{ {
print (fc::NF_border_line_vertical_right); print (fc::NF_border_line_vertical_right);
FString line(getWidth()-2, wchar_t(fc::BoxDrawingsHorizontal)); FString line(getWidth() - 2, wchar_t(fc::BoxDrawingsHorizontal));
print (line); print (line);
print (fc::NF_rev_border_line_vertical_left); print (fc::NF_rev_border_line_vertical_left);
} }
else else
{ {
print (fc::BoxDrawingsVerticalAndRight); print (fc::BoxDrawingsVerticalAndRight);
FString line(getWidth()-2, wchar_t(fc::BoxDrawingsHorizontal)); FString line(getWidth() - 2, wchar_t(fc::BoxDrawingsHorizontal));
print (line); print (line);
print (fc::BoxDrawingsVerticalAndLeft); print (fc::BoxDrawingsVerticalAndLeft);
} }

View File

@ -45,7 +45,7 @@ void FMenuBar::hide()
try try
{ {
blank = new char[screenWidth+1]; blank = new char[screenWidth + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -729,9 +729,9 @@ int FMenuBar::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length)
int hotkeypos = -1; int hotkeypos = -1;
wchar_t* txt = src; wchar_t* txt = src;
for (uInt i=0; i < length; i++) 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); hotkeypos = int(i);
i++; i++;
@ -819,7 +819,7 @@ void FMenuBar::drawItems()
try try
{ {
item_text = new wchar_t[txt_length+1](); item_text = new wchar_t[txt_length + 1]();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -830,10 +830,10 @@ void FMenuBar::drawItems()
src = const_cast<wchar_t*>(txt.wc_str()); src = const_cast<wchar_t*>(txt.wc_str());
dest = const_cast<wchar_t*>(item_text); dest = const_cast<wchar_t*>(item_text);
if ( x-1 <= screenWidth ) if ( x - 1 <= screenWidth )
to_char = int(txt_length); to_char = int(txt_length);
else else
to_char = int(txt_length) - (screenWidth-x-1); to_char = int(txt_length) - (screenWidth - x - 1);
hotkeypos = getHotkeyPos (src, dest, txt_length); hotkeypos = getHotkeyPos (src, dest, txt_length);
@ -845,9 +845,9 @@ void FMenuBar::drawItems()
x += int(txt_length); x += int(txt_length);
for (int z=0; z < to_char; z++) for (int z = 0; z < to_char; z++)
{ {
if ( startpos > screenWidth-z ) if ( startpos > screenWidth - z )
break; break;
if ( ! std::iswprint(wint_t(item_text[z])) ) if ( ! std::iswprint(wint_t(item_text[z])) )
@ -878,14 +878,14 @@ void FMenuBar::drawItems()
print (item_text[z]); print (item_text[z]);
} }
if ( x > screenWidth+1 ) if ( x > screenWidth + 1 )
{ {
if ( startpos < screenWidth ) if ( startpos < screenWidth )
{ {
setPrintPos (screenWidth - 1, 1); setPrintPos (screenWidth - 1, 1);
print (".."); print ("..");
} }
else if ( startpos-1 <= screenWidth ) else if ( startpos - 1 <= screenWidth )
{ {
setPrintPos (screenWidth, 1); setPrintPos (screenWidth, 1);
print (' '); print (' ');

View File

@ -688,7 +688,7 @@ void FMenuItem::init (FWidget* parent)
if ( hotkey ) if ( hotkey )
text_length--; text_length--;
setGeometry (1,1,int(text_length+2),1, false); setGeometry (1, 1, int(text_length + 2), 1, false);
if ( parent ) if ( parent )
{ {
@ -741,16 +741,16 @@ uChar FMenuItem::hotKey()
length = text.getLength(); length = text.getLength();
for (uInt i=0; i < length; i++) for (uInt i = 0; i < length; i++)
{ {
try try
{ {
if ( (i+1 < length) && (text[i] == '&') ) if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]); return uChar(text[++i]);
} }
catch (const std::out_of_range&) catch (const std::out_of_range&)
{ {
return 0;; return 0;
} }
} }

View File

@ -90,7 +90,7 @@ FMessageBox::FMessageBox ( const FString& caption
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMessageBox::~FMessageBox() // destructor FMessageBox::~FMessageBox() // destructor
{ {
for (uInt n=0; n < num_buttons; n++) for (uInt n = 0; n < num_buttons; n++)
delete button[n]; delete button[n];
} }
@ -105,7 +105,7 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
} }
else else
{ {
for (uInt n=0; n < num_buttons; n++) for (uInt n = 0; n < num_buttons; n++)
delete button[n]; delete button[n];
if ( mbox.getParentWidget() ) if ( mbox.getParentWidget() )
@ -136,8 +136,8 @@ void FMessageBox::setHeadline (const FString& headline)
headline_text = headline; headline_text = headline;
setHeight(getHeight() + 2, true); setHeight(getHeight() + 2, true);
for (uInt n=0; n < num_buttons; n++) for (uInt n = 0; n < num_buttons; n++)
button[n]->setY(getHeight()-4, false); button[n]->setY (getHeight() - 4, false);
uInt len = headline_text.getLength(); uInt len = headline_text.getLength();
@ -150,13 +150,13 @@ void FMessageBox::setText (const FString& txt)
{ {
text = txt; text = txt;
calculateDimensions(); calculateDimensions();
button[0]->setY(getHeight()-4, false); button[0]->setY (getHeight() - 4, false);
if ( button_digit[1] != 0 ) if ( button_digit[1] != 0 )
button[1]->setY(getHeight()-4, false); button[1]->setY (getHeight() - 4, false);
if ( button_digit[2] != 0 ) if ( button_digit[2] != 0 )
button[2]->setY(getHeight()-4, false); button[2]->setY (getHeight() - 4, false);
adjustButtons(); adjustButtons();
} }
@ -272,8 +272,8 @@ void FMessageBox::adjustSize()
max_height = 24; max_height = 24;
} }
X = 1 + int((max_width-getWidth())/2); X = 1 + int((max_width - getWidth()) / 2);
Y = 1 + int((max_height-getHeight())/3); Y = 1 + int((max_height - getHeight()) / 3);
setPos(X, Y, false); setPos(X, Y, false);
FDialog::adjustSize(); FDialog::adjustSize();
} }
@ -315,7 +315,7 @@ void FMessageBox::init (int button0, int button1, int button2)
{ {
button[0] = new FButton (this); button[0] = new FButton (this);
button[0]->setText(button_text[button0]); button[0]->setText(button_text[button0]);
button[0]->setPos(3, getHeight()-4, false); button[0]->setPos(3, getHeight() - 4, false);
button[0]->setWidth(1, false); button[0]->setWidth(1, false);
button[0]->setHeight(1, false); button[0]->setHeight(1, false);
button[0]->setFocus(); button[0]->setFocus();
@ -324,7 +324,7 @@ void FMessageBox::init (int button0, int button1, int button2)
{ {
button[1] = new FButton(this); button[1] = new FButton(this);
button[1]->setText(button_text[button1]); button[1]->setText(button_text[button1]);
button[1]->setPos(17, getHeight()-4, false); button[1]->setPos(17, getHeight() - 4, false);
button[1]->setWidth(0, false); button[1]->setWidth(0, false);
button[1]->setHeight(1, false); button[1]->setHeight(1, false);
} }
@ -333,7 +333,7 @@ void FMessageBox::init (int button0, int button1, int button2)
{ {
button[2] = new FButton(this); button[2] = new FButton(this);
button[2]->setText(button_text[button2]); button[2]->setText(button_text[button2]);
button[2]->setPos(32, getHeight()-4, false); button[2]->setPos(32, getHeight() - 4, false);
button[2]->setWidth(0, false); button[2]->setWidth(0, false);
button[2]->setHeight(1, false); button[2]->setHeight(1, false);
} }
@ -394,7 +394,7 @@ void FMessageBox::calculateDimensions()
if ( ! headline_text.isNull() ) if ( ! headline_text.isNull() )
headline_height = 2; headline_height = 2;
for (uInt i=0; i < text_num_lines; i++) for (uInt i = 0; i < text_num_lines; i++)
{ {
uInt len = text_components[i].getLength(); uInt len = text_components[i].getLength();
@ -410,8 +410,8 @@ void FMessageBox::calculateDimensions()
if ( parent_widget ) if ( parent_widget )
{ {
x = 1 + int((parent_widget->getWidth()-w)/2); x = 1 + int((parent_widget->getWidth() - w) / 2);
y = 1 + int((parent_widget->getHeight()-h)/3); y = 1 + int((parent_widget->getHeight() - h) / 3);
} }
else else
x = y = 1; x = y = 1;
@ -446,7 +446,7 @@ void FMessageBox::draw()
setColor(); setColor();
for (int i=0; i < int(text_num_lines); i++) for (int i = 0; i < int(text_num_lines); i++)
{ {
uInt line_length = text_components[i].getLength(); uInt line_length = text_components[i].getLength();
@ -466,7 +466,7 @@ void FMessageBox::resizeButtons()
{ {
uInt len[3], max_size; uInt len[3], max_size;
for (uInt n=0; n < num_buttons; n++) for (uInt n = 0; n < num_buttons; n++)
{ {
len[n] = button[n]->getText().getLength(); len[n] = button[n]->getText().getLength();
@ -488,7 +488,7 @@ void FMessageBox::resizeButtons()
if ( max_size < 7 ) if ( max_size < 7 )
max_size = 7; max_size = 7;
for (uInt n=0; n < num_buttons; n++) for (uInt n = 0; n < num_buttons; n++)
button[n]->setWidth(int(max_size + 3), false); button[n]->setWidth(int(max_size + 3), false);
} }
@ -498,26 +498,26 @@ void FMessageBox::adjustButtons()
static const int gap = 4; static const int gap = 4;
int btn_width = 0; int btn_width = 0;
for (uInt n=0; n < num_buttons; n++) for (uInt n = 0; n < num_buttons; n++)
{ {
if ( n == num_buttons-1 ) if ( n == num_buttons - 1 )
btn_width += button[n]->getWidth(); btn_width += button[n]->getWidth();
else else
btn_width += button[n]->getWidth() + gap; btn_width += button[n]->getWidth() + gap;
} }
if ( btn_width >= getWidth()-4 ) if ( btn_width >= getWidth() - 4 )
{ {
int max_width; int max_width;
FWidget* root_widget = getRootWidget(); FWidget* root_widget = getRootWidget();
setWidth(btn_width + 5); setWidth(btn_width + 5);
max_width = ( root_widget ) ? root_widget->getClientWidth() : 80; max_width = ( root_widget ) ? root_widget->getClientWidth() : 80;
setX (int((max_width-getWidth()) / 2)); setX (int((max_width - getWidth()) / 2));
} }
int btn_x = int((getWidth()-btn_width) / 2); int btn_x = int((getWidth() - btn_width) / 2);
for (uInt n=0; n < num_buttons; n++) for (uInt n = 0; n < num_buttons; n++)
{ {
if ( n == 0 ) if ( n == 0 )
button[n]->setX(btn_x); button[n]->setX(btn_x);

View File

@ -1236,7 +1236,7 @@ inline void FOptiAttr::prevent_no_color_video_attributes (char_data*& attr)
if ( hasColor(attr) && attr_without_color > 0 ) if ( hasColor(attr) && attr_without_color > 0 )
{ {
for (int bit=1; bit < no_mode; bit <<= 1) for (int bit = 1; bit < no_mode; bit <<= 1)
{ {
switch ( bit & attr_without_color ) switch ( bit & attr_without_color )
{ {

View File

@ -533,7 +533,7 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
// Method 4: home-down + local movement // Method 4: home-down + local movement
if ( F_cursor_to_ll.cap ) if ( F_cursor_to_ll.cap )
{ {
new_time = relativeMove (null_ptr, 0, screen_height-1, xnew, ynew); new_time = relativeMove (null_ptr, 0, screen_height - 1, xnew, ynew);
if ( new_time < LONG_DURATION if ( new_time < LONG_DURATION
&& F_cursor_to_ll.duration + new_time < move_time ) && F_cursor_to_ll.duration + new_time < move_time )
@ -549,7 +549,7 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
&& yold > 0 && yold > 0
&& F_cursor_left.cap ) && F_cursor_left.cap )
{ {
new_time = relativeMove (null_ptr, screen_width-1, yold-1, xnew, ynew); new_time = relativeMove (null_ptr, screen_width - 1, yold - 1, xnew, ynew);
if ( new_time < LONG_DURATION if ( new_time < LONG_DURATION
&& F_carriage_return.cap && F_carriage_return.cap
@ -588,7 +588,7 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
case 4: case 4:
std::strncpy (move_ptr, F_cursor_to_ll.cap, sizeof(move_buf) - 1); std::strncpy (move_ptr, F_cursor_to_ll.cap, sizeof(move_buf) - 1);
move_ptr += F_cursor_to_ll.length; move_ptr += F_cursor_to_ll.length;
relativeMove (move_ptr, 0, screen_height-1, xnew, ynew); relativeMove (move_ptr, 0, screen_height - 1, xnew, ynew);
break; break;
case 5: case 5:
@ -603,7 +603,7 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
, F_cursor_left.cap , F_cursor_left.cap
, sizeof(move_buf) - std::strlen(move_ptr) - 1 ); , sizeof(move_buf) - std::strlen(move_ptr) - 1 );
move_ptr += std::strlen(move_buf); move_ptr += std::strlen(move_buf);
relativeMove (move_ptr, screen_width-1, yold-1, xnew, ynew); relativeMove (move_ptr, screen_width - 1, yold - 1, xnew, ynew);
break; break;
default: default:
@ -620,24 +620,24 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::printDurations() void FOptiMove::printDurations()
{ {
std::printf (" speed: %d baud\r\n", baudrate); std::cout << " speed: " << baudrate << " baud\r\n";
std::printf (" char_duration: %d ms\r\n", char_duration); std::cout << " char_duration: " << char_duration << " ms\r\n";
std::printf (" cursor_home: %d ms\r\n", F_cursor_home.duration); std::cout << " cursor_home: " << F_cursor_home.duration << " ms\r\n";
std::printf (" cursor_to_ll: %d ms\r\n", F_cursor_to_ll.duration); std::cout << " cursor_to_ll: " << F_cursor_to_ll.duration << " ms\r\n";
std::printf (" carriage_return: %d ms\r\n", F_carriage_return.duration); std::cout << " carriage_return: " << F_carriage_return.duration << " ms\r\n";
std::printf (" tab: %d ms\r\n", F_tab.duration); std::cout << " tab: " << F_tab.duration << " ms\r\n";
std::printf (" back_tab: %d ms\r\n", F_back_tab.duration); std::cout << " back_tab: " << F_back_tab.duration << " ms\r\n";
std::printf (" cursor_up: %d ms\r\n", F_cursor_up.duration); std::cout << " cursor_up: " << F_cursor_up.duration << " ms\r\n";
std::printf (" cursor_down: %d ms\r\n", F_cursor_down.duration); std::cout << " cursor_down: " << F_cursor_down.duration << " ms\r\n";
std::printf (" cursor_left: %d ms\r\n", F_cursor_left.duration); std::cout << " cursor_left: " << F_cursor_left.duration << " ms\r\n";
std::printf (" cursor_right: %d ms\r\n", F_cursor_right.duration); std::cout << " cursor_right: " << F_cursor_right.duration << " ms\r\n";
std::printf (" cursor_address: %d ms\r\n", F_cursor_address.duration); std::cout << " cursor_address: " << F_cursor_address.duration << " ms\r\n";
std::printf (" column_address: %d ms\r\n", F_column_address.duration); std::cout << " column_address: " << F_column_address.duration << " ms\r\n";
std::printf (" row_address: %d ms\r\n", F_row_address.duration); std::cout << " row_address: " << F_row_address.duration << " ms\r\n";
std::printf (" parm_up_cursor: %d ms\r\n", F_parm_up_cursor.duration); std::cout << " parm_up_cursor: " << F_parm_up_cursor.duration << " ms\r\n";
std::printf (" parm_down_cursor: %d ms\r\n", F_parm_down_cursor.duration); std::cout << " parm_down_cursor: " << F_parm_down_cursor.duration << " ms\r\n";
std::printf (" parm_left_cursor: %d ms\r\n", F_parm_left_cursor.duration); std::cout << " parm_left_cursor: " << F_parm_left_cursor.duration << " ms\r\n";
std::printf ("parm_right_cursor: %d ms\r\n", F_parm_right_cursor.duration); std::cout << "parm_right_cursor: " << F_parm_right_cursor.duration << " ms\r\n";
} }
@ -671,7 +671,7 @@ int FOptiMove::capDuration (char*& cap, int affcnt)
const char* p; const char* p;
float ms = 0; float ms = 0;
for (p=cap; *p; p++) for (p = cap; *p; p++)
{ {
// check for delay with padding character // check for delay with padding character
if ( p[0] == '$' && p[1] == '<' && std::strchr(p, '>') ) if ( p[0] == '$' && p[1] == '<' && std::strchr(p, '>') )
@ -901,7 +901,7 @@ int FOptiMove::relativeMove ( char*& move
while ( true ) while ( true )
{ {
int tab_pos = ( pos > 0 ) ? ((pos-1)/tabstop)*tabstop : -1; int tab_pos = ( pos > 0 ) ? ((pos - 1) / tabstop) * tabstop : -1;
if ( tab_pos < to_x ) if ( tab_pos < to_x )
break; break;
@ -949,5 +949,5 @@ inline bool FOptiMove::isWideMove ( int xold, int yold
{ {
return bool ( (xnew > MOVE_LIMIT) return bool ( (xnew > MOVE_LIMIT)
&& (xnew < screen_width - 1 - MOVE_LIMIT) && (xnew < screen_width - 1 - MOVE_LIMIT)
&& (std::abs(xnew-xold) + std::abs(ynew-yold) > MOVE_LIMIT) ); && (std::abs(xnew - xold) + std::abs(ynew - yold) > MOVE_LIMIT) );
} }

View File

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

View File

@ -104,7 +104,7 @@ void FProgressbar::hide()
try try
{ {
blank = new char[size+1]; blank = new char[size + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -115,7 +115,7 @@ void FProgressbar::hide()
std::memset(blank, ' ', uLong(size)); std::memset(blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < getHeight()+s; y++) for (int y = 0; y < getHeight() + s; y++)
{ {
setPrintPos (1, 1 + y); setPrintPos (1, 1 + y);
print (blank); print (blank);

View File

@ -24,7 +24,7 @@ FRect::~FRect() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FRect::isNull() const bool FRect::isNull() const
{ {
return X2 == X1-1 && Y2 == Y1-1; return X2 == X1 - 1 && Y2 == Y1 - 1;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -111,7 +111,7 @@ void FRect::setSize (int w, int h)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FRect::setRect (const FRect& r) void FRect::setRect (const FRect& r)
{ {
setRect (r.X1, r.Y1, r.X2-r.X1+1, r.Y2-r.Y1+1); setRect (r.X1, r.Y1, r.X2 - r.X1 + 1, r.Y2 - r.Y1 + 1);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -119,8 +119,8 @@ void FRect::setRect (int x, int y, int width, int height)
{ {
X1 = short(x); X1 = short(x);
Y1 = short(y); Y1 = short(y);
X2 = short(x+width-1); X2 = short(x + width - 1);
Y2 = short(y+height-1); Y2 = short(y + height - 1);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -247,7 +247,7 @@ void FScrollbar::drawButtons()
{ {
print (fc::NF_rev_left_arrow1); print (fc::NF_rev_left_arrow1);
print (fc::NF_rev_left_arrow2); print (fc::NF_rev_left_arrow2);
setPrintPos (length-1, 1); setPrintPos (length - 1, 1);
print (fc::NF_rev_right_arrow1); print (fc::NF_rev_right_arrow1);
print (fc::NF_rev_right_arrow2); print (fc::NF_rev_right_arrow2);
} }
@ -289,7 +289,7 @@ void FScrollbar::drawBar()
{ {
setColor (wc.scrollbar_fg, wc.scrollbar_bg); setColor (wc.scrollbar_fg, wc.scrollbar_bg);
for (z=1; z <= slider_pos; z++) for (z = 1; z <= slider_pos; z++)
{ {
setPrintPos (1, 1 + z); setPrintPos (1, 1 + z);
@ -307,7 +307,7 @@ void FScrollbar::drawBar()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
for (z=1; z <= slider_length; z++) for (z = 1; z <= slider_length; z++)
{ {
setPrintPos (1, 1 + slider_pos + z); setPrintPos (1, 1 + slider_pos + z);
@ -322,7 +322,7 @@ void FScrollbar::drawBar()
setColor (wc.scrollbar_fg, wc.scrollbar_bg); setColor (wc.scrollbar_fg, wc.scrollbar_bg);
for (z=slider_pos+slider_length+1; z <= bar_length; z++) for (z = slider_pos + slider_length + 1; z <= bar_length; z++)
{ {
setPrintPos (1, 1 + z); setPrintPos (1, 1 + z);
@ -416,19 +416,22 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
{ {
if ( bar_orientation == fc::vertical ) 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 slider_click_pos = mouse_y; // on slider
} }
else // horizontal else // horizontal
{ {
if ( isNewFont() ) 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 slider_click_pos = mouse_x; // on slider
} }
else 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 slider_click_pos = mouse_x; // on slider
} }
} }
@ -576,11 +579,11 @@ void FScrollbar::onTimer (FTimerEvent*)
if ( ( scroll_type == FScrollbar::scrollPageBackward if ( ( scroll_type == FScrollbar::scrollPageBackward
&& slider_pos < slider_click_stop_pos ) && slider_pos < slider_click_stop_pos )
|| ( scroll_type == FScrollbar::scrollPageForward || ( scroll_type == FScrollbar::scrollPageForward
&& slider_pos+slider_length > slider_click_stop_pos ) ) && slider_pos + slider_length > slider_click_stop_pos ) )
{ {
// Scroll to the end // Scroll to the end
if ( scroll_type == FScrollbar::scrollPageForward if ( scroll_type == FScrollbar::scrollPageForward
&& slider_pos+slider_length > slider_click_stop_pos ) && slider_pos + slider_length > slider_click_stop_pos )
{ {
setValue(max); setValue(max);
processScroll(); processScroll();
@ -625,11 +628,11 @@ FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y)
{ {
stype = FScrollbar::scrollStepBackward; // decrement button stype = FScrollbar::scrollStepBackward; // decrement button
} }
else if ( y >1 && y <= slider_pos+1 ) else if ( y > 1 && y <= slider_pos + 1 )
{ {
stype = FScrollbar::scrollPageBackward; // before slider stype = FScrollbar::scrollPageBackward; // before slider
} }
else if ( y > slider_pos+slider_length+1 && y < getHeight() ) else if ( y > slider_pos + slider_length + 1 && y < getHeight() )
{ {
stype = FScrollbar::scrollPageForward; // after slider stype = FScrollbar::scrollPageForward; // after slider
} }
@ -648,15 +651,15 @@ FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y)
{ {
stype = FScrollbar::scrollStepBackward; // decrement button stype = FScrollbar::scrollStepBackward; // decrement button
} }
else if ( x >2 && x <= slider_pos+2 ) else if ( x > 2 && x <= slider_pos + 2 )
{ {
stype = FScrollbar::scrollPageBackward; // before slider stype = FScrollbar::scrollPageBackward; // before slider
} }
else if ( x > slider_pos+slider_length+2 && x < getWidth()-1 ) else if ( x > slider_pos + slider_length + 2 && x < getWidth() - 1 )
{ {
stype = FScrollbar::scrollPageForward; // after slider stype = FScrollbar::scrollPageForward; // after slider
} }
else if ( x == getWidth()-1 || x == getWidth() ) else if ( x == getWidth() - 1 || x == getWidth() )
{ {
stype = FScrollbar::scrollStepForward; // increment button stype = FScrollbar::scrollStepForward; // increment button
} }
@ -669,11 +672,11 @@ FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y)
{ {
stype = FScrollbar::scrollStepBackward; // decrement button stype = FScrollbar::scrollStepBackward; // decrement button
} }
else if ( x >1 && x <= slider_pos+1 ) else if ( x > 1 && x <= slider_pos + 1 )
{ {
stype = FScrollbar::scrollPageBackward; // before slider stype = FScrollbar::scrollPageBackward; // before slider
} }
else if ( x > slider_pos+slider_length+1 && x < getWidth() ) else if ( x > slider_pos + slider_length + 1 && x < getWidth() )
{ {
stype = FScrollbar::scrollPageForward; // after slider stype = FScrollbar::scrollPageForward; // after slider
} }

View File

@ -710,21 +710,21 @@ void FScrollView::copy2area()
y_end = getViewportHeight(); y_end = getViewportHeight();
x_end = getViewportWidth(); x_end = getViewportWidth();
for (int y=0; y < y_end; y++) // line loop for (int y = 0; y < y_end; y++) // line loop
{ {
char_data* vc; // viewport character char_data* vc; // viewport character
char_data* ac; // area character char_data* ac; // area character
int v_line_len = viewport->width; int v_line_len = viewport->width;
int a_line_len = print_area->width + print_area->right_shadow; int a_line_len = print_area->width + print_area->right_shadow;
vc = &viewport->text[(dy+y) * v_line_len + dx]; vc = &viewport->text[(dy + y) * v_line_len + dx];
ac = &print_area->text[(ay+y) * a_line_len + ax]; ac = &print_area->text[(ay + y) * a_line_len + ax];
std::memcpy (ac, vc, sizeof(char_data) * unsigned(x_end)); std::memcpy (ac, vc, sizeof(char_data) * unsigned(x_end));
if ( short(print_area->changes[ay+y].xmin) > ax ) if ( short(print_area->changes[ay + y].xmin) > ax )
print_area->changes[ay+y].xmin = uInt(ax); print_area->changes[ay + y].xmin = uInt(ax);
if ( short(print_area->changes[ay+y].xmax) < ax+x_end-1 ) if ( short(print_area->changes[ay + y].xmax) < ax + x_end - 1 )
print_area->changes[ay+y].xmax = uInt(ax+x_end-1); print_area->changes[ay + y].xmax = uInt(ax + x_end - 1);
} }
setViewportCursor(); setViewportCursor();
@ -747,10 +747,10 @@ inline FPoint FScrollView::getViewportCursorPos()
- viewport_geometry.getX(); - viewport_geometry.getX();
int y = widget_offsetY + viewport->input_cursor_y int y = widget_offsetY + viewport->input_cursor_y
- viewport_geometry.getY(); - viewport_geometry.getY();
return FPoint(x,y); return FPoint (x, y);
} }
else else
return FPoint(-1,-1); return FPoint (-1, -1);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -827,13 +827,13 @@ void FScrollView::calculateScrollbarPos()
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (width, 2, 2, height-2); vbar->setGeometry (width, 2, 2, height - 2);
hbar->setGeometry (1, height, width-2, 1); hbar->setGeometry (1, height, width - 2, 1);
} }
else else
{ {
vbar->setGeometry (width, 2, 1, height-2); vbar->setGeometry (width, 2, 1, height - 2);
hbar->setGeometry (2, height, width-2, 1); hbar->setGeometry (2, height, width - 2, 1);
} }
vbar->resize(); vbar->resize();

View File

@ -186,7 +186,7 @@ void FStatusBar::hide()
try try
{ {
blank = new char[screenWidth+1]; blank = new char[screenWidth + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -220,8 +220,8 @@ void FStatusBar::drawMessage()
if ( hasKeys ) if ( hasKeys )
{ {
std::vector<FStatusKey*>::const_iterator iter = key_list.end(); std::vector<FStatusKey*>::const_iterator iter = key_list.end();
isLastActiveFocus = bool ( (*(iter-1))->isActivated() isLastActiveFocus = bool ( (*(iter - 1))->isActivated()
|| (*(iter-1))->hasMouseFocus() ); || (*(iter - 1))->hasMouseFocus() );
} }
else else
isLastActiveFocus = false; isLastActiveFocus = false;
@ -235,7 +235,7 @@ void FStatusBar::drawMessage()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
if ( x+space_offset+3 < termWidth ) if ( x + space_offset + 3 < termWidth )
{ {
if ( text ) if ( text )
{ {
@ -255,17 +255,17 @@ void FStatusBar::drawMessage()
int msg_length = int(getMessage().getLength()); int msg_length = int(getMessage().getLength());
x += msg_length; x += msg_length;
if ( x-1 <= termWidth ) if ( x - 1 <= termWidth )
print (getMessage()); print (getMessage());
else else
{ {
print ( getMessage().left(uInt(msg_length+termWidth-x-1)) ); print ( getMessage().left(uInt(msg_length + termWidth - x - 1)) );
print (".."); print ("..");
} }
} }
} }
for (int i=x; i <= termWidth; i++) for (int i = x; i <= termWidth; i++)
print (' '); print (' ');
if ( isMonochron() ) if ( isMonochron() )
@ -317,7 +317,7 @@ void FStatusBar::remove (int pos)
if ( int(getCount()) < pos ) if ( int(getCount()) < pos )
return; return;
key_list.erase (key_list.begin()+pos-1); key_list.erase (key_list.begin() + pos - 1);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -461,7 +461,7 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
{ {
std::vector<FStatusKey*>::const_iterator iter, end; std::vector<FStatusKey*>::const_iterator iter, end;
bool focus_changed = false; bool focus_changed = false;
int X=1; int X = 1;
iter = key_list.begin(); iter = key_list.begin();
end = key_list.end(); end = key_list.end();
@ -583,7 +583,7 @@ void FStatusBar::drawKeys()
{ {
int kname_len = int(getKeyName((*iter)->getKey()).getLength()); int kname_len = int(getKeyName((*iter)->getKey()).getLength());
if ( x+kname_len+2 < screenWidth ) if ( x + kname_len + 2 < screenWidth )
{ {
if ( (*iter)->isActivated() || (*iter)->hasMouseFocus() ) if ( (*iter)->isActivated() || (*iter)->hasMouseFocus() )
{ {
@ -612,7 +612,7 @@ void FStatusBar::drawKeys()
else else
{ {
print ( (*iter)->getText() print ( (*iter)->getText()
.left(uInt(txt_length+screenWidth-x-1)) ); .left(uInt(txt_length + screenWidth - x - 1)) );
print (".."); print ("..");
} }
@ -635,18 +635,18 @@ void FStatusBar::drawKeys()
txt_length = int((*iter)->getText().getLength()); txt_length = int((*iter)->getText().getLength());
x += txt_length; x += txt_length;
if ( x-1 <= screenWidth ) if ( x - 1 <= screenWidth )
print ((*iter)->getText()); print ((*iter)->getText());
else else
{ {
print ( (*iter)->getText() print ( (*iter)->getText()
.left(uInt(txt_length+screenWidth-x-1)) ); .left(uInt(txt_length + screenWidth - x - 1)) );
print (".."); print ("..");
} }
if ( iter+1 != key_list.end() if ( iter + 1 != key_list.end()
&& ( (*(iter+1))->isActivated() || (*(iter+1))->hasMouseFocus() ) && ( (*(iter + 1))->isActivated() || (*(iter + 1))->hasMouseFocus() )
&& x + int(getKeyName((*(iter+1))->getKey()).getLength()) + 3 && x + int(getKeyName((*(iter + 1))->getKey()).getLength()) + 3
< screenWidth ) < screenWidth )
{ {
// next element is active // next element is active
@ -666,7 +666,7 @@ void FStatusBar::drawKeys()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
} }
else if ( iter+1 != key_list.end() && x < screenWidth ) else if ( iter + 1 != key_list.end() && x < screenWidth )
{ {
// not the last element // not the last element
setColor (wc.statusbar_separator_fg, wc.statusbar_bg); setColor (wc.statusbar_separator_fg, wc.statusbar_bg);

View File

@ -530,7 +530,7 @@ FString& FString::sprintf (const char* format, ...)
{ {
try try
{ {
buffer = new char[len+1](); buffer = new char[len + 1]();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -539,7 +539,7 @@ FString& FString::sprintf (const char* format, ...)
} }
va_start (args, format); va_start (args, format);
vsnprintf (buffer, uLong(len+1), format, args); vsnprintf (buffer, uLong(len + 1), format, args);
va_end (args); va_end (args);
} }
@ -853,7 +853,7 @@ FString FString::rtrim() const
if ( last == p && std::iswspace(wint_t(*last)) ) if ( last == p && std::iswspace(wint_t(*last)) )
s.clear(); s.clear();
else else
*(last+1) = '\0'; *(last + 1) = '\0';
return s; return s;
} }
@ -893,7 +893,7 @@ FString FString::left (uInt len) const
p = s.string; p = s.string;
s.length = len; s.length = len;
*(p+len) = '\0'; *(p + len) = '\0';
return s; return s;
} }
@ -920,7 +920,7 @@ FString FString::right (uInt len) const
return s; return s;
p = s.string; p = s.string;
p += (length-len); p += (length - len);
return FString(p); return FString(p);
} }
@ -952,15 +952,15 @@ FString FString::mid (uInt pos, uInt len) const
if ( pos == 0 ) if ( pos == 0 )
pos = 1; pos = 1;
if ( pos <= length && pos+len > length ) if ( pos <= length && pos + len > length )
len = length - pos + 1; len = length - pos + 1;
if ( pos > length || pos+len-1 > length || len == 0 ) if ( pos > length || pos + len - 1 > length || len == 0 )
return FString(L""); return FString(L"");
p = s.string; p = s.string;
first = p + pos - 1; first = p + pos - 1;
*(first+len) = '\0'; *(first + len) = '\0';
return FString(first); return FString(first);
} }
@ -2033,7 +2033,7 @@ FString FString::expandTabs (int tabstop) const
tab_split = instr.split("\t"); tab_split = instr.split("\t");
last = tab_split.size(); last = tab_split.size();
for (uInt i=0; i < last; i++) for (uInt i = 0; i < last; i++)
{ {
uInt len = tab_split[i].getLength(); uInt len = tab_split[i].getLength();
uInt tab_len = uInt(tabstop); uInt tab_len = uInt(tabstop);
@ -2053,8 +2053,8 @@ FString FString::removeDel() const
if ( p ) if ( p )
{ {
uInt i=0; uInt i = 0;
uInt d=0; uInt d = 0;
while ( *p ) while ( *p )
{ {
@ -2093,7 +2093,7 @@ FString FString::removeBackspaces() const
if ( p ) if ( p )
{ {
uInt i=0; uInt i = 0;
while ( *p ) while ( *p )
{ {
@ -2138,7 +2138,7 @@ const FString& FString::overwrite (const wchar_t* s, uInt pos)
{ {
uInt len = uInt(std::wcslen(s)); uInt len = uInt(std::wcslen(s));
if (length >= (pos+len) ) if (length >= (pos +len) )
{ {
std::wcsncpy (string + pos, s, len); std::wcsncpy (string + pos, s, len);
} }
@ -2154,7 +2154,7 @@ const FString& FString::overwrite (const wchar_t* s, uInt pos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FString::overwrite (const wchar_t c, uInt pos) const FString& FString::overwrite (const wchar_t c, uInt pos)
{ {
if ( length >= (pos+1) ) if ( length >= (pos + 1) )
{ {
string[pos] = c; string[pos] = c;
} }
@ -2296,11 +2296,11 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t* s)
if ( (length + len + 1) <= bufsize ) if ( (length + len + 1) <= bufsize )
{ {
// output string <= bufsize // output string <= bufsize
for (x = length; x+1 > pos; x--) // shifting right side + '\0' for (x = length; x + 1 > pos; x--) // shifting right side + '\0'
string[x+len] = string[x]; string[x + len] = string[x];
for (x=0; x < len; x++) // insert string for (x = 0; x < len; x++) // insert string
string[x+pos] = s[x]; string[x + pos] = s[x];
length += len; length += len;
} }
@ -2322,17 +2322,17 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t* s)
uInt y = 0; uInt y = 0;
for (x=0; x < pos; x++) // left side for (x = 0; x < pos; x++) // left side
sptr[y++] = string[x]; sptr[y++] = string[x];
for (x=0; x < len; x++) // insert string for (x = 0 ; x < len; x++) // insert string
sptr[y++] = s[x]; sptr[y++] = s[x];
for (x=pos; x < length+1; x++) // right side + '\0' for (x = pos; x < length + 1; x++) // right side + '\0'
sptr[y++] = string[x]; sptr[y++] = string[x];
length += len; length += len;
delete[](string); // delete old string delete[](string); // delete old string
string = sptr; string = sptr;
} }
} }
@ -2344,8 +2344,8 @@ inline void FString::_remove (uInt pos, uInt len)
if ( (bufsize - length - 1 + len) <= FWDBUFFER ) if ( (bufsize - length - 1 + len) <= FWDBUFFER )
{ {
// shifting left side to pos // 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]; string[i] = string[i + len];
length -= len; length -= len;
} }
@ -2366,10 +2366,10 @@ inline void FString::_remove (uInt pos, uInt len)
uInt x, y = 0; uInt x, y = 0;
for (x=0; x < pos; x++) // left side for (x = 0; x < pos; x++) // left side
sptr[y++] = string[x]; sptr[y++] = string[x];
for (x=pos+len; x < length+1; x++) // right side + '\0' for (x = pos + len; x < length + 1; x++) // right side + '\0'
sptr[y++] = string[x]; sptr[y++] = string[x];
delete[](string); // delete old string delete[](string); // delete old string
@ -2493,7 +2493,7 @@ inline wchar_t* FString::c_to_wc_str (const char* s) const
} }
if ( wclength == size ) if ( wclength == size )
dest[size-1] = '\0'; dest[size - 1] = '\0';
if ( wclength ) if ( wclength )
return dest; return dest;

View File

@ -189,7 +189,7 @@ int FTerm::getColumnNumber()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString FTerm::getKeyName (int keynum) const FString FTerm::getKeyName (int keynum)
{ {
for (int i=0; FkeyName[i].string[0] != 0; i++) for (int i = 0; FkeyName[i].string[0] != 0; i++)
if ( FkeyName[i].num && FkeyName[i].num == keynum ) if ( FkeyName[i].num && FkeyName[i].num == keynum )
return FString(FkeyName[i].string); return FString(FkeyName[i].string);
@ -450,17 +450,17 @@ int FTerm::parseKeyString ( char buffer[]
// SGR mouse tracking // SGR mouse tracking
if ( buffer[1] == '[' && buffer[2] == '<' && buf_len >= 9 if ( buffer[1] == '[' && buffer[2] == '<' && buf_len >= 9
&& (buffer[buf_len-1] == 'M' || buffer[buf_len-1] == 'm') ) && (buffer[buf_len - 1] == 'M' || buffer[buf_len - 1] == 'm') )
return fc::Fkey_extended_mouse; return fc::Fkey_extended_mouse;
// urxvt mouse tracking // urxvt mouse tracking
if ( buffer[1] == '[' && buffer[2] >= '1' && buffer[2] <= '9' if ( buffer[1] == '[' && buffer[2] >= '1' && buffer[2] <= '9'
&& buffer[3] >= '0' && buffer[3] <= '9' && buf_len >= 9 && buffer[3] >= '0' && buffer[3] <= '9' && buf_len >= 9
&& buffer[buf_len-1] == 'M' ) && buffer[buf_len - 1] == 'M' )
return fc::Fkey_urxvt_mouse; return fc::Fkey_urxvt_mouse;
// look for termcap keys // look for termcap keys
for (int i=0; Fkey[i].tname[0] != 0; i++) for (int i = 0; Fkey[i].tname[0] != 0; i++)
{ {
char* k = Fkey[i].string; char* k = Fkey[i].string;
len = (k) ? int(std::strlen(k)) : 0; len = (k) ? int(std::strlen(k)) : 0;
@ -470,10 +470,10 @@ int FTerm::parseKeyString ( char buffer[]
n = len; n = len;
for (; n < buf_size; n++) // Remove founded entry for (; n < buf_size; n++) // Remove founded entry
buffer[n-len] = buffer[n]; buffer[n - len] = buffer[n];
for (; n-len < len; n++) // Fill rest with '\0' for (; n - len < len; n++) // Fill rest with '\0'
buffer[n-len] = '\0'; buffer[n - len] = '\0';
input_data_pending = bool(buffer[0] != '\0'); input_data_pending = bool(buffer[0] != '\0');
return Fkey[i].num; return Fkey[i].num;
@ -481,7 +481,7 @@ int FTerm::parseKeyString ( char buffer[]
} }
// look for meta keys // look for meta keys
for (int i=0; Fmetakey[i].string[0] != 0; i++) for (int i = 0; Fmetakey[i].string[0] != 0; i++)
{ {
char* kmeta = Fmetakey[i].string; // The string is never null char* kmeta = Fmetakey[i].string; // The string is never null
len = int(std::strlen(kmeta)); len = int(std::strlen(kmeta));
@ -498,10 +498,10 @@ int FTerm::parseKeyString ( char buffer[]
n = len; n = len;
for (; n < buf_size; n++) // Remove founded entry for (; n < buf_size; n++) // Remove founded entry
buffer[n-len] = buffer[n]; buffer[n - len] = buffer[n];
for (; n-len < len; n++) // Fill rest with '\0' for (; n - len < len; n++) // Fill rest with '\0'
buffer[n-len] = '\0'; buffer[n - len] = '\0';
input_data_pending = bool(buffer[0] != '\0'); input_data_pending = bool(buffer[0] != '\0');
return Fmetakey[i].num; return Fmetakey[i].num;
@ -527,7 +527,7 @@ int FTerm::parseKeyString ( char buffer[]
else if ((firstchar & 0xf8) == 0xf0) else if ((firstchar & 0xf8) == 0xf0)
len = 4; len = 4;
for (n=0; n < len ; n++) for (n = 0; n < len ; n++)
utf8char[n] = char(buffer[n] & 0xff); utf8char[n] = char(buffer[n] & 0xff);
key = UTF8decode(utf8char); key = UTF8decode(utf8char);
@ -538,9 +538,9 @@ int FTerm::parseKeyString ( char buffer[]
n = len; n = len;
for (; n < buf_size; n++) // remove the key from the buffer front for (; n < buf_size; n++) // remove the key from the buffer front
buffer[n-len] = buffer[n]; buffer[n - len] = buffer[n];
for (n=n-len; n < buf_size; n++) // fill the rest with '\0' bytes for (n = n - len; n < buf_size; n++) // fill the rest with '\0' bytes
buffer[n] = '\0'; buffer[n] = '\0';
input_data_pending = bool(buffer[0] != '\0'); input_data_pending = bool(buffer[0] != '\0');
@ -896,7 +896,7 @@ const FString* FTerm::getXTermFont()
tv.tv_usec = 150000; // 150 ms tv.tv_usec = 150000; // 150 ms
// read the terminal answer // read the terminal answer
if ( select (stdin_no+1, &ifds, 0, 0, &tv) > 0) if ( select (stdin_no + 1, &ifds, 0, 0, &tv) > 0)
{ {
if ( std::scanf("\033]50;%[^\n]s", temp) == 1 ) if ( std::scanf("\033]50;%[^\n]s", temp) == 1 )
{ {
@ -904,8 +904,8 @@ const FString* FTerm::getXTermFont()
std::size_t n = std::strlen(temp); std::size_t n = std::strlen(temp);
// BEL + '\0' = string terminator // BEL + '\0' = string terminator
if ( n >= 5 && temp[n-1] == BEL[0] && temp[n] == '\0' ) if ( n >= 5 && temp[n - 1] == BEL[0] && temp[n] == '\0' )
temp[n-1] = '\0'; temp[n - 1] = '\0';
try try
{ {
@ -944,21 +944,21 @@ const FString* FTerm::getXTermTitle()
tv.tv_usec = 150000; // 150 ms tv.tv_usec = 150000; // 150 ms
// read the terminal answer // read the terminal answer
if ( select (stdin_no+1, &ifds, 0, 0, &tv) > 0) if ( select (stdin_no + 1, &ifds, 0, 0, &tv) > 0)
{ {
if ( std::scanf("\033]l%[^\n]s", temp) == 1 ) if ( std::scanf("\033]l%[^\n]s", temp) == 1 )
{ {
std::size_t n = std::strlen(temp); std::size_t n = std::strlen(temp);
// Esc + \ = OSC string terminator // Esc + \ = OSC string terminator
if ( n >= 2 && temp[n-2] == ESC[0] && temp[n-1] == '\\' ) if ( n >= 2 && temp[n - 2] == ESC[0] && temp[n - 1] == '\\' )
{ {
FString* xtermtitle; FString* xtermtitle;
if ( n < 4 ) if ( n < 4 )
return 0; return 0;
temp[n-2] = '\0'; temp[n - 2] = '\0';
try try
{ {
@ -1001,19 +1001,19 @@ const FString FTerm::getXTermColorName (int color)
tv.tv_usec = 150000; // 150 ms tv.tv_usec = 150000; // 150 ms
// read the terminal answer // read the terminal answer
if ( select (stdin_no+1, &ifds, 0, 0, &tv) > 0) if ( select (stdin_no + 1, &ifds, 0, 0, &tv) > 0)
{ {
if ( std::scanf("\033]4;%d;%[^\n]s", &color, temp) == 2 ) if ( std::scanf("\033]4;%d;%[^\n]s", &color, temp) == 2 )
{ {
std::size_t n = std::strlen(temp); std::size_t n = std::strlen(temp);
// BEL + '\0' = string terminator // BEL + '\0' = string terminator
if ( n >= 6 && temp[n-1] == BEL[0] && temp[n] == '\0' ) if ( n >= 6 && temp[n - 1] == BEL[0] && temp[n] == '\0' )
temp[n-1] = '\0'; temp[n - 1] = '\0';
// Esc + \ = OSC string terminator (mintty) // Esc + \ = OSC string terminator (mintty)
if ( n >= 6 && temp[n-2] == ESC[0] && temp[n-1] == '\\' ) if ( n >= 6 && temp[n - 2] == ESC[0] && temp[n - 1] == '\\' )
temp[n-2] = '\0'; temp[n - 2] = '\0';
color_str = temp; color_str = temp;
} }
@ -1297,7 +1297,7 @@ void FTerm::resetColorMap()
{0x55, 0x55, 0xFF}, {0xFF, 0x55, 0xFF}, {0x55, 0x55, 0xFF}, {0xFF, 0x55, 0xFF},
{0x55, 0xFF, 0xFF}, {0xFF, 0xFF, 0xFF} {0x55, 0xFF, 0xFF}, {0xFF, 0xFF, 0xFF}
}; };
for (int x=0; x<16; x++) for (int x = 0; x < 16; x++)
{ {
color_map.d[x].red = CurrentColors[x].red; color_map.d[x].red = CurrentColors[x].red;
color_map.d[x].green = CurrentColors[x].green; color_map.d[x].green = CurrentColors[x].green;
@ -1504,8 +1504,8 @@ const FString FTerm::getAnswerbackMsg()
tv.tv_usec = 150000; // 150 ms tv.tv_usec = 150000; // 150 ms
// read the answerback message // read the answerback message
if ( select (stdin_no+1, &ifds, 0, 0, &tv) > 0) if ( select (stdin_no + 1, &ifds, 0, 0, &tv) > 0)
if ( std::fgets (temp, sizeof(temp)-1, stdin) != 0 ) if ( std::fgets (temp, sizeof(temp) - 1, stdin) != 0 )
answerback = temp; answerback = temp;
return answerback; return answerback;
@ -1530,7 +1530,7 @@ const FString FTerm::getSecDA()
tv.tv_usec = 600000; // 600 ms tv.tv_usec = 600000; // 600 ms
// read the answer // read the answer
if ( select (stdin_no+1, &ifds, 0, 0, &tv) == 1 ) if ( select (stdin_no + 1, &ifds, 0, 0, &tv) == 1 )
if ( std::scanf("\033[>%d;%d;%dc", &a, &b, &c) == 3 ) if ( std::scanf("\033[>%d;%d;%dc", &a, &b, &c) == 3 )
sec_da_str.sprintf("\033[>%d;%d;%dc", a, b, c); sec_da_str.sprintf("\033[>%d;%d;%dc", a, b, c);
@ -1608,9 +1608,9 @@ int FTerm::putchar_UTF8 (register int c)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FTerm::UTF8decode (const char utf8[]) int FTerm::UTF8decode (const char utf8[])
{ {
register int ucs=0; register int ucs = 0;
for (register int i=0; i < int(std::strlen(utf8)); ++i) for (register int i = 0; i < int(std::strlen(utf8)); ++i)
{ {
register uChar ch = uChar(utf8[i]); register uChar ch = uChar(utf8[i]);
@ -1662,11 +1662,11 @@ void FTerm::initLinuxConsoleCharMap()
if ( screen_unicode_map.entry_ct != 0 ) if ( screen_unicode_map.entry_ct != 0 )
{ {
for (int i=0; i <= lastCharItem; i++ ) for (int i = 0; i <= lastCharItem; i++ )
{ {
bool found = false; bool found = false;
for (uInt n=0; n < screen_unicode_map.entry_ct; n++) for (uInt n = 0; n < screen_unicode_map.entry_ct; n++)
{ {
if ( character[i][fc::UTF8] == screen_unicode_map.entries[n].unicode ) if ( character[i][fc::UTF8] == screen_unicode_map.entries[n].unicode )
{ {
@ -1711,7 +1711,7 @@ void FTerm::initFreeBSDConsoleCharMap()
if ( ! isFreeBSDConsole() ) if ( ! isFreeBSDConsole() )
return; return;
for (int i=0; i <= lastCharItem; i++ ) for (int i = 0; i <= lastCharItem; i++ )
if ( character[i][fc::PC] < 0x1c ) if ( character[i][fc::PC] < 0x1c )
character[i][fc::PC] = character[i][fc::ASCII]; character[i][fc::PC] = character[i][fc::ASCII];
} }
@ -1725,7 +1725,7 @@ void FTerm::initCygwinCharMap()
if ( ! cygwin_terminal ) if ( ! cygwin_terminal )
return; return;
for (int i=0; i <= lastCharItem; i++ ) for (int i = 0; i <= lastCharItem; i++ )
{ {
if ( character[i][fc::UTF8] == fc::BlackUpPointingTriangle // ▲ if ( character[i][fc::UTF8] == fc::BlackUpPointingTriangle // ▲
|| character[i][fc::UTF8] == fc::BlackDownPointingTriangle // ▼ || character[i][fc::UTF8] == fc::BlackDownPointingTriangle // ▼
@ -1742,7 +1742,7 @@ void FTerm::initTeraTermCharMap()
if ( ! tera_terminal ) if ( ! tera_terminal )
return; return;
for (int i=0; i <= lastCharItem; i++ ) for (int i = 0; i <= lastCharItem; i++ )
if ( character[i][fc::PC] < 0x20 ) if ( character[i][fc::PC] < 0x20 )
character[i][fc::PC] = character[i][fc::ASCII]; character[i][fc::PC] = character[i][fc::ASCII];
} }
@ -1763,7 +1763,7 @@ uInt FTerm::charEncode (uInt c)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uInt FTerm::charEncode (uInt c, fc::encoding enc) uInt FTerm::charEncode (uInt c, fc::encoding enc)
{ {
for (uInt i=0; i <= uInt(lastCharItem); i++) for (uInt i = 0; i <= uInt(lastCharItem); i++)
{ {
if ( character[i][0] == c ) if ( character[i][0] == c )
{ {
@ -2117,7 +2117,7 @@ void FTerm::getSystemTermType()
char str[BUFSIZ]; char str[BUFSIZ];
// read and parse the file // read and parse the file
while ( fgets(str, sizeof(str)-1, fp) != 0 ) while ( fgets(str, sizeof(str) - 1, fp) != 0 )
{ {
type = name = 0; // 0 == not found type = name = 0; // 0 == not found
p = str; p = str;
@ -2266,7 +2266,7 @@ int FTerm::setScreenFont ( uChar* fontdata, uInt count
return -1; return -1;
} }
for (uInt i=0; i < count; i++) for (uInt i = 0; i < count; i++)
std::memcpy ( const_cast<uChar*>(font.data + bytes_per_line*32*i) std::memcpy ( const_cast<uChar*>(font.data + bytes_per_line*32*i)
, &fontdata[i * font.height] , &fontdata[i * font.height]
, font.height); , font.height);
@ -2715,7 +2715,7 @@ char* FTerm::parseSecDA (char*& current_termtype)
// remove the first 3 bytes ("\033[>") // 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") // remove the last byte ("c")
temp.remove(temp.getLength()-1, 1); temp.remove(temp.getLength() - 1, 1);
// split into components // split into components
std::vector<FString> sec_da_split = temp.split(';'); std::vector<FString> sec_da_split = temp.split(';');
@ -2892,11 +2892,11 @@ void FTerm::init_alt_charset()
if ( tcap[fc::t_acs_chars].string ) if ( tcap[fc::t_acs_chars].string )
{ {
for (int n=0; tcap[fc::t_acs_chars].string[n]; n += 2) for (int n = 0; tcap[fc::t_acs_chars].string[n]; n += 2)
{ {
// insert the vt100 key/value pairs into a map // insert the vt100 key/value pairs into a map
uChar p1 = uChar(tcap[fc::t_acs_chars].string[n]); uChar p1 = uChar(tcap[fc::t_acs_chars].string[n]);
uChar p2 = uChar(tcap[fc::t_acs_chars].string[n+1]); uChar p2 = uChar(tcap[fc::t_acs_chars].string[n + 1]);
(*vt100_alt_char)[p1] = p2; (*vt100_alt_char)[p1] = p2;
} }
} }
@ -2908,7 +2908,7 @@ void FTerm::init_alt_charset()
}; };
// update array 'character' with discovered vt100 pairs // update array 'character' with discovered vt100 pairs
for (int n=0; n <= lastKeyItem; n++ ) for (int n = 0; n <= lastKeyItem; n++ )
{ {
uChar keyChar = uChar(vt100_key_to_utf8[n][vt100_key]); uChar keyChar = uChar(vt100_key_to_utf8[n][vt100_key]);
uChar altChar = uChar((*vt100_alt_char)[ keyChar ]); uChar altChar = uChar((*vt100_alt_char)[ keyChar ]);
@ -3128,7 +3128,7 @@ void FTerm::init_termcaps()
// ------------------- // -------------------
// read termcap output strings // read termcap output strings
for (int i=0; tcap[i].tname[0] != 0; i++) for (int i = 0; tcap[i].tname[0] != 0; i++)
tcap[i].string = tgetstr(tcap[i].tname, &buffer); tcap[i].string = tgetstr(tcap[i].tname, &buffer);
// set invisible cursor for cygwin terminal // set invisible cursor for cygwin terminal
@ -3405,7 +3405,7 @@ void FTerm::init_termcaps()
#endif #endif
// read termcap key strings // read termcap key strings
for (int i=0; Fkey[i].tname[0] != 0; i++) for (int i = 0; Fkey[i].tname[0] != 0; i++)
{ {
Fkey[i].string = tgetstr(Fkey[i].tname, &buffer); Fkey[i].string = tgetstr(Fkey[i].tname, &buffer);
@ -3442,7 +3442,7 @@ void FTerm::init_termcaps()
|| ( tcap[fc::t_cursor_up].string || ( tcap[fc::t_cursor_up].string
&& (std::strcmp(tcap[fc::t_cursor_up].string, CSI "A") == 0) ) ) && (std::strcmp(tcap[fc::t_cursor_up].string, CSI "A") == 0) ) )
{ {
for (int i=0; Fkey[i].tname[0] != 0; i++) for (int i = 0; Fkey[i].tname[0] != 0; i++)
{ {
if ( std::strncmp(Fkey[i].tname, "kux", 3) == 0 ) if ( std::strncmp(Fkey[i].tname, "kux", 3) == 0 )
Fkey[i].string = const_cast<char*>(CSI "A"); // key up Fkey[i].string = const_cast<char*>(CSI "A"); // key up
@ -3839,7 +3839,7 @@ void FTerm::init()
if ( new_termtype ) if ( new_termtype )
{ {
setenv(const_cast<char*>("TERM"), new_termtype, 1); setenv(const_cast<char*>("TERM"), new_termtype, 1);
std::strncpy (termtype, new_termtype, std::strlen(new_termtype)+1); std::strncpy (termtype, new_termtype, std::strlen(new_termtype) + 1);
} }
// Initializes variables for the current terminal // Initializes variables for the current terminal
@ -4167,7 +4167,7 @@ uInt FTerm::cp437_to_unicode (uChar c)
{ {
register uInt ucs = uInt(c); register uInt ucs = uInt(c);
for (register uInt i=0; i <= lastCP437Item; i++) for (register uInt i = 0; i <= lastCP437Item; i++)
{ {
if ( cp437_to_ucs[i][0] == c ) // found if ( cp437_to_ucs[i][0] == c ) // found
{ {

View File

@ -54,7 +54,7 @@ int FTermBuffer::writef (const char* format, ...)
{ {
try try
{ {
buffer = new char[len+1](); buffer = new char[len + 1]();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -63,7 +63,7 @@ int FTermBuffer::writef (const char* format, ...)
} }
va_start (args, format); va_start (args, format);
vsnprintf (buffer, uLong(len+1), format, args); vsnprintf (buffer, uLong(len + 1), format, args);
va_end (args); va_end (args);
} }

View File

@ -45,20 +45,20 @@ const FString FTextView::getText() const
len = 0; len = 0;
rows = getRows(); rows = getRows();
for (uInt i=0 ; i < rows; i++) for (uInt i = 0 ; i < rows; i++)
len += data[i].getLength() + 1; len += data[i].getLength() + 1;
FString s(len + 1); FString s(len + 1);
idx = 0; idx = 0;
for (uInt i=0 ; i < rows; i++) for (uInt i = 0 ; i < rows; i++)
{ {
const wchar_t* p = data[i].wc_str(); const wchar_t* p = data[i].wc_str();
if ( p ) if ( p )
{ {
while ( (s[idx++] = *p++) != 0 ); while ( (s[idx++] = *p++) != 0 );
s[idx-1] = '\n'; s[idx - 1] = '\n';
} }
else else
{ {
@ -66,7 +66,7 @@ const FString FTextView::getText() const
} }
} }
s[idx-1] = 0; s[idx - 1] = 0;
return s; return s;
} }
@ -81,13 +81,13 @@ void FTextView::setGeometry (int x, int y, int w, int h, bool adjust)
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (width, 1, 2, height-1); vbar->setGeometry (width, 1, 2, height - 1);
hbar->setGeometry (1, height, width-2, 1); hbar->setGeometry (1, height, width - 2, 1);
} }
else else
{ {
vbar->setGeometry (width, 2, 1, height-2); vbar->setGeometry (width, 2, 1, height - 2);
hbar->setGeometry (2, height, width-2, 1); hbar->setGeometry (2, height, width - 2, 1);
} }
vbar->resize(); vbar->resize();
@ -152,7 +152,7 @@ void FTextView::hide()
try try
{ {
blank = new char[size+1]; blank = new char[size + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -163,7 +163,7 @@ void FTextView::hide()
std::memset(blank, ' ', uLong(size)); std::memset(blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < getHeight(); y++) for (int y = 0; y < getHeight(); y++)
{ {
setPrintPos (1, 1 + y); setPrintPos (1, 1 + y);
print (blank); print (blank);
@ -199,7 +199,7 @@ void FTextView::insert (const FString& str, int pos)
text_split = s.split("\r\n"); text_split = s.split("\r\n");
end = text_split.size(); end = text_split.size();
for (uInt i=0; i < end; i++) for (uInt i = 0; i < end; i++)
{ {
uInt len; uInt len;
text_split[i] = text_split[i].removeBackspaces() text_split[i] = text_split[i].removeBackspaces()
@ -253,7 +253,7 @@ void FTextView::replaceRange (const FString& str, int start, int end)
return; return;
iter = data.begin(); iter = data.begin();
data.erase (iter+start, iter+end+1); data.erase (iter + start, iter + end + 1);
if ( ! str.isNull() ) if ( ! str.isNull() )
insert(str, start); insert(str, start);
@ -287,7 +287,7 @@ void FTextView::clear()
try try
{ {
blank = new char[size+1]; blank = new char[size + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -298,7 +298,7 @@ void FTextView::clear()
std::memset(blank, ' ', uLong(size)); std::memset(blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < getHeight() + nf_offset - 2; y++) for (int y = 0; y < getHeight() + nf_offset - 2; y++)
{ {
setPrintPos (2, 2 - nf_offset + y); setPrintPos (2, 2 - nf_offset + y);
print (blank); print (blank);
@ -345,7 +345,7 @@ void FTextView::onKeyPress (FKeyEvent* ev)
break; break;
case fc::Fkey_ppage: case fc::Fkey_ppage:
yoffset -= getHeight()-2; yoffset -= getHeight() - 2;
if ( yoffset < 0 ) if ( yoffset < 0 )
yoffset = 0; yoffset = 0;
@ -355,7 +355,7 @@ void FTextView::onKeyPress (FKeyEvent* ev)
case fc::Fkey_npage: case fc::Fkey_npage:
if ( last_line >= getHeight() ) if ( last_line >= getHeight() )
yoffset += getHeight()-2; yoffset += getHeight() - 2;
if ( yoffset > last_line - getHeight() - nf_offset + 2 ) if ( yoffset > last_line - getHeight() - nf_offset + 2 )
yoffset = last_line - getHeight() - nf_offset + 2; yoffset = last_line - getHeight() - nf_offset + 2;
@ -756,18 +756,18 @@ void FTextView::drawText()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
for (uInt y=start; y < end; y++) for (uInt y = start; y < end; y++)
{ {
uInt i, len; uInt i, len;
FString line; FString line;
const wchar_t* line_str; const wchar_t* line_str;
setPrintPos (2, 2 - nf_offset + int(y)); setPrintPos (2, 2 - nf_offset + int(y));
line = data[y+uInt(yoffset)].mid ( uInt(1 + xoffset) line = data[y + uInt(yoffset)].mid ( uInt(1 + xoffset)
, uInt(getWidth() - nf_offset - 2) ); , uInt(getWidth() - nf_offset - 2) );
line_str = line.wc_str(); line_str = line.wc_str();
len = line.getLength(); len = line.getLength();
for (i=0; i < len; i++) for (i = 0; i < len; i++)
{ {
wchar_t ch = line_str[i]; wchar_t ch = line_str[i];
bool utf8 = (Encoding == fc::UTF8) ? true : false; bool utf8 = (Encoding == fc::UTF8) ? true : false;

View File

@ -219,7 +219,7 @@ void FToggleButton::hide()
try try
{ {
blank = new char[size+1]; blank = new char[size + 1];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -403,16 +403,16 @@ uChar FToggleButton::getHotkey()
length = text.getLength(); length = text.getLength();
for (uInt i=0; i < length; i++) for (uInt i = 0; i < length; i++)
{ {
try try
{ {
if ( (i+1 < length) && (text[i] == '&') ) if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]); return uChar(text[++i]);
} }
catch (const std::out_of_range&) catch (const std::out_of_range&)
{ {
return 0;; return 0;
} }
} }
@ -496,7 +496,7 @@ void FToggleButton::drawLabel()
try try
{ {
LabelText = new wchar_t[length+1](); LabelText = new wchar_t[length + 1]();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -512,9 +512,9 @@ void FToggleButton::drawLabel()
// find hotkey position in string // find hotkey position in string
// + generate a new string without the '&'-sign // + generate a new string without the '&'-sign
for (i=0; i < length; i++) for (i = 0; i < length; i++)
{ {
if ( (i < length) && (txt[i] == '&') && (hotkeypos == -1) ) if ( i < length && txt[i] == '&' && hotkeypos == -1 )
{ {
hotkeypos = int(i); hotkeypos = int(i);
i++; i++;
@ -537,7 +537,7 @@ void FToggleButton::drawLabel()
else else
setColor (wc.label_inactive_fg, wc.label_inactive_bg); setColor (wc.label_inactive_fg, wc.label_inactive_bg);
for (int z=0; z < int(length); z++) for (int z = 0; z < int(length); z++)
{ {
if ( (z == hotkeypos) && isActive ) if ( (z == hotkeypos) && isActive )
{ {

View File

@ -73,7 +73,7 @@ void FToolTip::draw()
clearArea(); clearArea();
drawBorder(); drawBorder();
for (int i=0; i < int(text_num_lines); i++) for (int i = 0; i < int(text_num_lines); i++)
{ {
setPrintPos (3, 2 + i); setPrintPos (3, 2 + i);
print(text_components[i]); print(text_components[i]);
@ -129,7 +129,7 @@ void FToolTip::calculateDimensions()
text_components = &text_split[0]; text_components = &text_split[0];
max_line_width = 0; max_line_width = 0;
for (uInt i=0; i < text_num_lines; i++) for (uInt i = 0; i < text_num_lines; i++)
{ {
uInt len = text_components[i].getLength(); uInt len = text_components[i].getLength();
@ -142,8 +142,8 @@ void FToolTip::calculateDimensions()
if ( r ) if ( r )
{ {
x = 1 + int((r->getWidth()-w)/2); x = 1 + int((r->getWidth() - w) / 2);
y = 1 + int((r->getHeight()-h)/2); y = 1 + int((r->getHeight() - h) / 2);
} }
else else
x = y = 1; x = y = 1;

View File

@ -200,7 +200,7 @@ void FVTerm::resizeVTerm (int width, int height)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::putVTerm() 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].xmin = 0;
vterm->changes[i].xmax = uInt(vterm->width - 1); vterm->changes[i].xmax = uInt(vterm->width - 1);
@ -242,7 +242,7 @@ void FVTerm::updateTerminal()
// Update data on VTerm // Update data on VTerm
updateVTerm(); updateVTerm();
for (register uInt y=0; y < uInt(vterm->height); y++) for (register uInt y = 0; y < uInt(vterm->height); y++)
updateTerminalLine (y); updateTerminalLine (y);
// sets the new input cursor position // sets the new input cursor position
@ -319,7 +319,7 @@ int FVTerm::printf (const char* format, ...)
{ {
try try
{ {
buffer = new char[len+1](); buffer = new char[len + 1]();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -327,7 +327,7 @@ int FVTerm::printf (const char* format, ...)
return -1; return -1;
} }
va_start (args, format); va_start (args, format);
vsnprintf (buffer, uLong(len+1), format, args); vsnprintf (buffer, uLong(len + 1), format, args);
va_end (args); va_end (args);
} }
@ -973,7 +973,7 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
return; return;
} }
area_size = (width+rsw) * (height+bsh); area_size = (width + rsw) * (height + bsh);
if ( area->height + area->bottom_shadow != height + bsh ) if ( area->height + area->bottom_shadow != height + bsh )
{ {
@ -1044,11 +1044,11 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
std::fill_n (area->text, area_size, default_char); std::fill_n (area->text, area_size, default_char);
unchanged.xmin = uInt(width+rsw); unchanged.xmin = uInt(width + rsw);
unchanged.xmax = 0; unchanged.xmax = 0;
unchanged.trans_count = 0; unchanged.trans_count = 0;
std::fill_n (area->changes, height+bsh, unchanged); std::fill_n (area->changes, height + bsh, unchanged);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1105,13 +1105,13 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
if ( w < 0 || h < 0 ) if ( w < 0 || h < 0 )
return; return;
if ( x+w > vterm->width ) if ( x + w > vterm->width )
w = vterm->width - x; w = vterm->width - x;
if ( w < 0 ) if ( w < 0 )
return; return;
if ( y+h > vterm->height ) if ( y + h > vterm->height )
h = vterm->height - y; h = vterm->height - y;
if ( h < 0 ) if ( h < 0 )
@ -1119,12 +1119,12 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
widget = static_cast<FWidget*>(vterm->widget); widget = static_cast<FWidget*>(vterm->widget);
for (register int ty=0; ty < h; ty++) for (register int ty = 0; ty < h; ty++)
{ {
for (register int tx=0; tx < w; tx++) for (register int tx = 0; tx < w; tx++)
{ {
tc = &vterm->text[(y+ty) * vterm->width + (x+tx)]; tc = &vterm->text[(y + ty) * vterm->width + (x + tx)];
sc = &vdesktop->text[(y+ty) * vdesktop->width + (x+tx)]; sc = &vdesktop->text[(y + ty) * vdesktop->width + (x + tx)];
if ( widget->window_list && ! widget->window_list->empty() ) if ( widget->window_list && ! widget->window_list->empty() )
{ {
@ -1150,11 +1150,11 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
, win->height + win->bottom_shadow ); , win->height + win->bottom_shadow );
// window visible and contains current character // window visible and contains current character
if ( geometry.contains(tx+x, ty+y) ) if ( geometry.contains(tx + x, ty + y) )
{ {
char_data* tmp; char_data* tmp;
int line_len = win->width + win->right_shadow; int line_len = win->width + win->right_shadow;
tmp = &win->text[(ty+y-win_y) * line_len + (tx+x-win_x)]; tmp = &win->text[(ty + y - win_y) * line_len + (tx + x - win_x)];
if ( ! tmp->attr.bit.transparent ) // current character not transparent if ( ! tmp->attr.bit.transparent ) // current character not transparent
{ {
@ -1193,11 +1193,11 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
std::memcpy (tc, sc, sizeof(char_data)); std::memcpy (tc, sc, sizeof(char_data));
if ( short(vterm->changes[y+ty].xmin) > x ) if ( short(vterm->changes[y + ty].xmin) > x )
vterm->changes[y+ty].xmin = uInt(x); vterm->changes[y + ty].xmin = uInt(x);
if ( short(vterm->changes[y+ty].xmax) < x+w-1 ) if ( short(vterm->changes[y + ty].xmax) < x + w - 1 )
vterm->changes[y+ty].xmax = uInt(x+w-1); vterm->changes[y + ty].xmax = uInt(x + w - 1);
} }
} }
} }
@ -1252,7 +1252,7 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
{ {
char_data* tmp; char_data* tmp;
int line_len = win->width + win->right_shadow; int line_len = win->width + win->right_shadow;
tmp = &win->text[(y-win_y) * line_len + (x-win_x)]; tmp = &win->text[(y - win_y) * line_len + (x - win_x)];
if ( tmp->attr.bit.trans_shadow ) if ( tmp->attr.bit.trans_shadow )
{ {
@ -1380,7 +1380,7 @@ void FVTerm::updateVTerm (term_area* area)
else else
y_end = ah + bsh; y_end = ah + bsh;
for (int y=0; y < y_end; y++) // line loop for (int y = 0; y < y_end; y++) // line loop
{ {
int line_xmin = int(area->changes[y].xmin); int line_xmin = int(area->changes[y].xmin);
int line_xmax = int(area->changes[y].xmax); int line_xmax = int(area->changes[y].xmax);
@ -1399,7 +1399,7 @@ void FVTerm::updateVTerm (term_area* area)
if ( ax + line_xmin >= vterm->width ) if ( ax + line_xmin >= vterm->width )
continue; continue;
for (int x=line_xmin; x <= line_xmax; x++) // column loop for (int x = line_xmin; x <= line_xmax; x++) // column loop
{ {
int gx, gy, line_len; int gx, gy, line_len;
covered_state is_covered; covered_state is_covered;
@ -1414,7 +1414,7 @@ void FVTerm::updateVTerm (term_area* area)
ac = &area->text[y * line_len + x]; ac = &area->text[y * line_len + x];
tc = &vterm->text[gy * vterm->width + gx - ol]; tc = &vterm->text[gy * vterm->width + gx - ol];
is_covered = isCovered(gx-ol, gy, area); // get covered state is_covered = isCovered(gx - ol, gy, area); // get covered state
if ( is_covered != fully_covered ) if ( is_covered != fully_covered )
{ {
@ -1423,7 +1423,7 @@ void FVTerm::updateVTerm (term_area* area)
// add the overlapping color to this character // add the overlapping color to this character
char_data ch, oc; char_data ch, oc;
std::memcpy (&ch, ac, sizeof(char_data)); std::memcpy (&ch, ac, sizeof(char_data));
oc = getOverlappedCharacter (gx+1 - ol, gy+1, area->widget); oc = getOverlappedCharacter (gx + 1 - ol, gy + 1, area->widget);
ch.fg_color = oc.fg_color; ch.fg_color = oc.fg_color;
ch.bg_color = oc.bg_color; ch.bg_color = oc.bg_color;
ch.attr.bit.reverse = false; ch.attr.bit.reverse = false;
@ -1444,7 +1444,7 @@ void FVTerm::updateVTerm (term_area* area)
{ {
// restore one character on vterm // restore one character on vterm
char_data ch; char_data ch;
ch = getCoveredCharacter (gx+1 - ol, gy+1, area->widget); ch = getCoveredCharacter (gx + 1 - ol, gy + 1, area->widget);
ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch); ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data)); std::memcpy (tc, &ch, sizeof(char_data));
} }
@ -1454,7 +1454,7 @@ void FVTerm::updateVTerm (term_area* area)
{ {
// get covered character + add the current color // get covered character + add the current color
char_data ch; char_data ch;
ch = getCoveredCharacter (gx+1 - ol, gy+1, area->widget); ch = getCoveredCharacter (gx + 1 - ol, gy + 1, area->widget);
ch.fg_color = ac->fg_color; ch.fg_color = ac->fg_color;
ch.bg_color = ac->bg_color; ch.bg_color = ac->bg_color;
ch.attr.bit.reverse = false; ch.attr.bit.reverse = false;
@ -1476,7 +1476,7 @@ void FVTerm::updateVTerm (term_area* area)
// add the covered background to this character // add the covered background to this character
char_data ch, cc; char_data ch, cc;
std::memcpy (&ch, ac, sizeof(char_data)); std::memcpy (&ch, ac, sizeof(char_data));
cc = getCoveredCharacter (gx+1 - ol, gy+1, area->widget); cc = getCoveredCharacter (gx + 1 - ol, gy + 1, area->widget);
ch.bg_color = cc.bg_color; ch.bg_color = cc.bg_color;
ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch); ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data)); std::memcpy (tc, &ch, sizeof(char_data));
@ -1506,14 +1506,14 @@ void FVTerm::updateVTerm (term_area* area)
_xmin = ax + line_xmin - ol; _xmin = ax + line_xmin - ol;
_xmax = ax + line_xmax; _xmax = ax + line_xmax;
if ( _xmin < short(vterm->changes[ay+y].xmin) ) if ( _xmin < short(vterm->changes[ay + y].xmin) )
vterm->changes[ay+y].xmin = uInt(_xmin); vterm->changes[ay + y].xmin = uInt(_xmin);
if ( _xmax >= vterm->width ) if ( _xmax >= vterm->width )
_xmax = vterm->width - 1; _xmax = vterm->width - 1;
if ( _xmax > short(vterm->changes[ay+y].xmax) ) if ( _xmax > short(vterm->changes[ay + y].xmax) )
vterm->changes[ay+y].xmax = uInt(_xmax); vterm->changes[ay + y].xmax = uInt(_xmax);
area->changes[y].xmin = uInt(aw + rsh); area->changes[y].xmin = uInt(aw + rsh);
area->changes[y].xmax = 0; area->changes[y].xmax = 0;
@ -1622,27 +1622,27 @@ void FVTerm::getArea (int ax, int ay, term_area* area)
ax--; ax--;
ay--; ay--;
if ( area->height+ay > vterm->height ) if ( area->height + ay > vterm->height )
y_end = area->height - ay; y_end = area->height - ay;
else else
y_end = area->height; y_end = area->height;
if ( area->width+ax > vterm->width ) if ( area->width + ax > vterm->width )
length = vterm->width - ax; length = vterm->width - ax;
else else
length = area->width; length = area->width;
for (int y=0; y < y_end; y++) // line loop for (int y = 0; y < y_end; y++) // line loop
{ {
tc = &vterm->text[(ay+y) * vterm->width + ax]; tc = &vterm->text[(ay + y) * vterm->width + ax];
ac = &area->text[y * area->width]; ac = &area->text[y * area->width];
std::memcpy (ac, tc, sizeof(char_data) * unsigned(length)); std::memcpy (ac, tc, sizeof(char_data) * unsigned(length));
if ( short(area->changes[y].xmin) > 0 ) if ( short(area->changes[y].xmin) > 0 )
area->changes[y].xmin = 0; area->changes[y].xmin = 0;
if ( short(area->changes[y].xmax) < length-1 ) if ( short(area->changes[y].xmax) < length - 1 )
area->changes[y].xmax = uInt(length-1); area->changes[y].xmax = uInt(length - 1);
} }
} }
@ -1673,12 +1673,12 @@ void FVTerm::getArea (int x, int y, int w, int h, term_area* area)
if ( x < 0 || y < 0 ) if ( x < 0 || y < 0 )
return; return;
if ( y-1+h > vterm->height ) if ( y - 1 + h > vterm->height )
y_end = vterm->height - y + 1; y_end = vterm->height - y + 1;
else else
y_end = h - 1; y_end = h - 1;
if ( x-1+w > vterm->width ) if ( x - 1 + w > vterm->width )
length = vterm->width - x + 1; length = vterm->width - x + 1;
else else
length = w; length = w;
@ -1686,18 +1686,18 @@ void FVTerm::getArea (int x, int y, int w, int h, term_area* area)
if ( length < 1 ) if ( length < 1 )
return; return;
for (int _y=0; _y < y_end; _y++) // line loop for (int _y = 0; _y < y_end; _y++) // line loop
{ {
int line_len = area->width + area->right_shadow; int line_len = area->width + area->right_shadow;
tc = &vterm->text[(y+_y-1) * vterm->width + x-1]; tc = &vterm->text[(y + _y - 1) * vterm->width + x - 1];
ac = &area->text[(dy+_y) * line_len + dx]; ac = &area->text[(dy + _y) * line_len + dx];
std::memcpy (ac, tc, sizeof(char_data) * unsigned(length)); std::memcpy (ac, tc, sizeof(char_data) * unsigned(length));
if ( short(area->changes[dy+_y].xmin) > dx ) if ( short(area->changes[dy + _y].xmin) > dx )
area->changes[dy+_y].xmin = uInt(dx); area->changes[dy + _y].xmin = uInt(dx);
if ( short(area->changes[dy+_y].xmax) < dx+length-1 ) if ( short(area->changes[dy + _y].xmax) < dx + length - 1 )
area->changes[dy+_y].xmax = uInt(dx+length-1); area->changes[dy + _y].xmax = uInt(dx + length - 1);
} }
} }
@ -1755,30 +1755,30 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
if ( length < 1 ) if ( length < 1 )
return; return;
for (register int y=0; y < y_end; y++) // line loop for (register int y = 0; y < y_end; y++) // line loop
{ {
int line_len = aw + rsh; int line_len = aw + rsh;
if ( area->changes[y].trans_count == 0 ) if ( area->changes[y].trans_count == 0 )
{ {
// Line has only covered characters // Line has only covered characters
tc = &vterm->text[(ay+y) * vterm->width + ax]; tc = &vterm->text[(ay + y) * vterm->width + ax];
ac = &area->text[y * line_len + ol]; ac = &area->text[y * line_len + ol];
std::memcpy (tc, ac, sizeof(char_data) * unsigned(length)); std::memcpy (tc, ac, sizeof(char_data) * unsigned(length));
} }
else else
{ {
// Line has one or more transparent characters // Line has one or more transparent characters
for (register int x=0; x < length; x++) // column loop for (register int x = 0; x < length; x++) // column loop
{ {
tc = &vterm->text[(ay+y) * vterm->width + (ax+x)]; tc = &vterm->text[(ay + y) * vterm->width + (ax + x)];
ac = &area->text[y * line_len + ol + x]; ac = &area->text[y * line_len + ol + x];
if ( ac->attr.bit.transparent ) // transparent if ( ac->attr.bit.transparent ) // transparent
{ {
// restore one character on vterm // restore one character on vterm
char_data ch; char_data ch;
ch = getCoveredCharacter (ax+x+1, ay+y+1, area->widget); ch = getCoveredCharacter (ax + x + 1, ay + y + 1, area->widget);
std::memcpy (tc, &ch, sizeof(char_data)); std::memcpy (tc, &ch, sizeof(char_data));
} }
else // not transparent else // not transparent
@ -1787,7 +1787,7 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
{ {
// get covered character + add the current color // get covered character + add the current color
char_data ch; char_data ch;
ch = getCoveredCharacter (ax+x+1, ay+y+1, area->widget); ch = getCoveredCharacter (ax + x + 1, ay + y + 1, area->widget);
ch.fg_color = ac->fg_color; ch.fg_color = ac->fg_color;
ch.bg_color = ac->bg_color; ch.bg_color = ac->bg_color;
ch.attr.bit.reverse = false; ch.attr.bit.reverse = false;
@ -1808,7 +1808,7 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
// add the covered background to this character // add the covered background to this character
char_data ch, cc; char_data ch, cc;
std::memcpy (&ch, ac, sizeof(char_data)); std::memcpy (&ch, ac, sizeof(char_data));
cc = getCoveredCharacter (ax+x+1, ay+y+1, area->widget); cc = getCoveredCharacter (ax + x + 1, ay + y + 1, area->widget);
ch.bg_color = cc.bg_color; ch.bg_color = cc.bg_color;
std::memcpy (tc, &ch, sizeof(char_data)); std::memcpy (tc, &ch, sizeof(char_data));
} }
@ -1818,11 +1818,11 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
} }
} }
if ( ax < short(vterm->changes[ay+y].xmin) ) if ( ax < short(vterm->changes[ay + y].xmin) )
vterm->changes[ay+y].xmin = uInt(ax); vterm->changes[ay + y].xmin = uInt(ax);
if ( ax+length-1 > short(vterm->changes[ay+y].xmax) ) if ( ax + length - 1 > short(vterm->changes[ay + y].xmax) )
vterm->changes[ay+y].xmax = uInt(ax+length-1); vterm->changes[ay + y].xmax = uInt(ax + length - 1);
} }
} }
@ -1848,10 +1848,10 @@ void FVTerm::scrollAreaForward (term_area* area)
total_width = area->width + area->right_shadow; total_width = area->width + area->right_shadow;
y_max = area->height - 1; 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 pos1 = y * total_width;
int pos2 = (y+1) * total_width; int pos2 = (y + 1) * total_width;
sc = &area->text[pos2]; sc = &area->text[pos2];
dc = &area->text[pos1]; dc = &area->text[pos1];
std::memcpy (dc, sc, sizeof(char_data) * unsigned(length)); std::memcpy (dc, sc, sizeof(char_data) * unsigned(length));
@ -1877,8 +1877,8 @@ void FVTerm::scrollAreaForward (term_area* area)
scrollTermForward(); scrollTermForward();
putArea (1, 1, vdesktop); putArea (1, 1, vdesktop);
// avoid update lines from 0 to (y_max-1) // 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].xmin = uInt(area->width - 1);
area->changes[y].xmax = 0; area->changes[y].xmax = 0;
@ -1909,9 +1909,9 @@ void FVTerm::scrollAreaReverse (term_area* area)
total_width = area->width + area->right_shadow; total_width = area->width + area->right_shadow;
y_max = area->height - 1; y_max = area->height - 1;
for (int y=y_max; y > 0; y--) for (int y = y_max; y > 0; y--)
{ {
int pos1 = (y-1) * total_width; int pos1 = (y - 1) * total_width;
int pos2 = y * total_width; int pos2 = y * total_width;
sc = &area->text[pos1]; sc = &area->text[pos1];
dc = &area->text[pos2]; dc = &area->text[pos2];
@ -1939,7 +1939,7 @@ void FVTerm::scrollAreaReverse (term_area* area)
putArea (1, 1, vdesktop); putArea (1, 1, vdesktop);
// avoid update lines from 1 to y_max // 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].xmin = uInt(area->width - 1);
area->changes[y].xmax = 0; area->changes[y].xmax = 0;
@ -1980,7 +1980,7 @@ void FVTerm::clearArea (term_area* area, int fillchar)
} }
else 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].xmin = 0;
vdesktop->changes[i].xmax = uInt(vdesktop->width) - 1; vdesktop->changes[i].xmax = uInt(vdesktop->width) - 1;
@ -1998,24 +1998,24 @@ void FVTerm::clearArea (term_area* area, int fillchar)
char_data t_char = nc; char_data t_char = nc;
t_char.attr.bit.transparent = true; 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; int pos = y * total_width;
// area // area
std::fill_n (&area->text[pos], total_width, nc); std::fill_n (&area->text[pos], total_width, nc);
// right shadow // right shadow
std::fill_n (&area->text[pos+area->width], area->right_shadow, t_char); std::fill_n (&area->text[pos + area->width], area->right_shadow, t_char);
} }
// bottom shadow // bottom shadow
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); int pos = total_width * (y + area->height);
std::fill_n (&area->text[pos], total_width, t_char); std::fill_n (&area->text[pos], total_width, t_char);
} }
} }
for (int i=0; i < area->height; i++) for (int i = 0; i < area->height; i++)
{ {
area->changes[i].xmin = 0; area->changes[i].xmin = 0;
area->changes[i].xmax = w - 1; area->changes[i].xmax = w - 1;
@ -2030,7 +2030,7 @@ void FVTerm::clearArea (term_area* area, int fillchar)
area->changes[i].trans_count = 0; 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; int y = area->height + i;
area->changes[y].xmin = 0; area->changes[y].xmin = 0;
@ -2124,7 +2124,7 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type
{ {
char_data* tmp; char_data* tmp;
int line_len = win->width + win->right_shadow; int line_len = win->width + win->right_shadow;
tmp = &win->text[(y-win_y) * line_len + (x-win_x)]; tmp = &win->text[(y - win_y) * line_len + (x - win_x)];
// current character not transparent // current character not transparent
if ( ! tmp->attr.bit.transparent ) if ( ! tmp->attr.bit.transparent )
@ -2373,7 +2373,7 @@ bool FVTerm::clearTerm (int fillchar)
{ {
term_pos->setPoint(-1,-1); term_pos->setPoint(-1,-1);
for (int i=0; i < getLineNumber(); i++) for (int i = 0; i < getLineNumber(); i++)
{ {
setTermXY (0, i); setTermXY (0, i);
appendOutputBuffer (cb); appendOutputBuffer (cb);
@ -2407,7 +2407,7 @@ void FVTerm::updateTerminalLine (uInt y)
char*& rp = tcap[fc::t_repeat_char].string; char*& rp = tcap[fc::t_repeat_char].string;
bool ut = FTermcap::background_color_erase; bool ut = FTermcap::background_color_erase;
char_data* first_char = &vt->text[y * uInt(vt->width)]; char_data* first_char = &vt->text[y * uInt(vt->width)];
char_data* last_char = &vt->text[(y+1) * uInt(vt->width) - 1]; char_data* last_char = &vt->text[(y + 1) * uInt(vt->width) - 1];
char_data* min_char = &vt->text[y * uInt(vt->width) + xmin]; char_data* min_char = &vt->text[y * uInt(vt->width) + xmin];
// Is the line from xmin to the end of the line blank? // Is the line from xmin to the end of the line blank?
@ -2416,7 +2416,7 @@ void FVTerm::updateTerminalLine (uInt y)
uInt beginning_whitespace = 1; uInt beginning_whitespace = 1;
bool normal = isNormal(min_char); bool normal = isNormal(min_char);
for (uInt x=xmin+1; x < uInt(vt->width); x++) for (uInt x = xmin + 1; x < uInt(vt->width); x++)
{ {
char_data* ch = &vt->text[y * uInt(vt->width) + x]; char_data* ch = &vt->text[y * uInt(vt->width) + x];
@ -2440,7 +2440,7 @@ void FVTerm::updateTerminalLine (uInt y)
uInt leading_whitespace = 1; uInt leading_whitespace = 1;
bool normal = isNormal(first_char); bool normal = isNormal(first_char);
for (uInt x=1; x < uInt(vt->width); x++) for (uInt x = 1; x < uInt(vt->width); x++)
{ {
char_data* ch = &vt->text[y * uInt(vt->width) + x]; char_data* ch = &vt->text[y * uInt(vt->width) + x];
@ -2465,7 +2465,7 @@ void FVTerm::updateTerminalLine (uInt y)
uInt tailing_whitespace = 1; uInt tailing_whitespace = 1;
bool normal = isNormal(last_char); bool normal = isNormal(last_char);
for (uInt x=uInt(vt->width)-1; x > 0 ; x--) for (uInt x = uInt(vt->width) - 1; x > 0 ; x--)
{ {
char_data* ch = &vt->text[y * uInt(vt->width) + x]; char_data* ch = &vt->text[y * uInt(vt->width) + x];
@ -2502,7 +2502,7 @@ void FVTerm::updateTerminalLine (uInt y)
markAsPrinted (0, xmin, y); markAsPrinted (0, xmin, y);
} }
for (uInt x=xmin; x <= xmax; x++) for (uInt x = xmin; x <= xmax; x++)
{ {
char_data* print_char; char_data* print_char;
print_char = &vt->text[y * uInt(vt->width) + x]; print_char = &vt->text[y * uInt(vt->width) + x];
@ -2513,7 +2513,7 @@ void FVTerm::updateTerminalLine (uInt y)
{ {
uInt count = 1; uInt count = 1;
for (uInt i=x+1; i <= xmax; i++) for (uInt i = x + 1; i <= xmax; i++)
{ {
char_data* ch = &vt->text[y * uInt(vt->width) + i]; char_data* ch = &vt->text[y * uInt(vt->width) + i];
@ -2537,7 +2537,7 @@ void FVTerm::updateTerminalLine (uInt y)
uInt whitespace = 1; uInt whitespace = 1;
bool normal = isNormal(print_char); bool normal = isNormal(print_char);
for (uInt i=x+1; i <= xmax; i++) for (uInt i = x + 1; i <= xmax; i++)
{ {
char_data* ch = &vt->text[y * uInt(vt->width) + i]; char_data* ch = &vt->text[y * uInt(vt->width) + i];
@ -2573,7 +2573,7 @@ void FVTerm::updateTerminalLine (uInt y)
{ {
x--; x--;
for (uInt i=0; i < whitespace; i++, x++) for (uInt i = 0; i < whitespace; i++, x++)
appendCharacter (print_char); appendCharacter (print_char);
} }
@ -2584,7 +2584,7 @@ void FVTerm::updateTerminalLine (uInt y)
{ {
uInt repetitions = 1; uInt repetitions = 1;
for (uInt i=x+1; i <= xmax; i++) for (uInt i = x + 1; i <= xmax; i++)
{ {
char_data* ch = &vt->text[y * uInt(vt->width) + i]; char_data* ch = &vt->text[y * uInt(vt->width) + i];
@ -2617,7 +2617,7 @@ void FVTerm::updateTerminalLine (uInt y)
{ {
x--; x--;
for (uInt i=0; i < repetitions; i++, x++) for (uInt i = 0; i < repetitions; i++, x++)
appendCharacter (print_char); appendCharacter (print_char);
} }
@ -2635,7 +2635,7 @@ void FVTerm::updateTerminalLine (uInt y)
{ {
appendAttributes (last_char); appendAttributes (last_char);
appendOutputBuffer (ce); appendOutputBuffer (ce);
markAsPrinted (xmax+1, uInt(vt->width - 1), y); markAsPrinted (xmax + 1, uInt(vt->width - 1), y);
} }
} }
@ -2713,7 +2713,7 @@ inline void FVTerm::markAsPrinted (uInt from, uInt to, uInt line)
{ {
// Marks characters in the specified range [from .. to] as printed // Marks characters in the specified range [from .. to] as printed
for (uInt x=from; x <= to; x++) for (uInt x = from; x <= to; x++)
vterm->text[line * uInt(vterm->width) + x].attr.bit.printed = true; vterm->text[line * uInt(vterm->width) + x].attr.bit.printed = true;
} }

View File

@ -1186,7 +1186,7 @@ void FWidget::resize()
{ {
detectTermSize(); detectTermSize();
FRect term_geometry = getTermGeometry(); FRect term_geometry = getTermGeometry();
term_geometry.move(-1,-1); term_geometry.move (-1, -1);
resizeVTerm (term_geometry); resizeVTerm (term_geometry);
resizeArea (term_geometry, getShadow(), vdesktop); resizeArea (term_geometry, getShadow(), vdesktop);
@ -1433,7 +1433,7 @@ void FWidget::drawShadow()
if ( trans_shadow ) if ( trans_shadow )
{ {
// transparent shadow // transparent shadow
setPrintPos (x2+1, y1); setPrintPos (x2 + 1, y1);
setTransparent(); setTransparent();
print (" "); print (" ");
unsetTransparent(); unsetTransparent();
@ -1441,14 +1441,14 @@ void FWidget::drawShadow()
setColor (wc.shadow_bg, wc.shadow_fg); setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow(); setTransShadow();
for (int i=1; i < getHeight(); i++) for (int i = 1; i < getHeight(); i++)
{ {
setPrintPos (x2+1, y1+i); setPrintPos (x2 + 1, y1 + i);
print (" "); print (" ");
} }
unsetTransShadow(); unsetTransShadow();
setPrintPos (x1, y2+1); setPrintPos (x1, y2 + 1);
setTransparent(); setTransparent();
print (" "); print (" ");
unsetTransparent(); unsetTransparent();
@ -1456,7 +1456,7 @@ void FWidget::drawShadow()
setColor (wc.shadow_bg, wc.shadow_fg); setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow(); setTransShadow();
for (int i=2; i <= getWidth()+1; i++) for (int i = 2; i <= getWidth() + 1; i++)
print (' '); print (' ');
unsetTransShadow(); unsetTransShadow();
@ -1472,7 +1472,7 @@ void FWidget::drawShadow()
if ( no_shadow_character ) if ( no_shadow_character )
return; return;
setPrintPos (x2+1, y1); setPrintPos (x2 + 1, y1);
if ( isWindowWidget() ) if ( isWindowWidget() )
{ {
@ -1488,18 +1488,18 @@ void FWidget::drawShadow()
if ( isWindowWidget() ) if ( isWindowWidget() )
unsetInheritBackground(); unsetInheritBackground();
for (int i=1; i < getHeight(); i++) for (int i = 1; i < getHeight(); i++)
{ {
setPrintPos (x2+1, y1+i); setPrintPos (x2 + 1, y1 + i);
print (block); // █ print (block); // █
} }
setPrintPos (x1+1, y2+1); setPrintPos (x1 + 1, y2 + 1);
if ( isWindowWidget() ) if ( isWindowWidget() )
setInheritBackground(); setInheritBackground();
for (int i=1; i <= getWidth(); i++) for (int i = 1; i <= getWidth(); i++)
print (fc::UpperHalfBlock); // ▀ print (fc::UpperHalfBlock); // ▀
if ( isWindowWidget() ) if ( isWindowWidget() )
@ -1530,18 +1530,18 @@ void FWidget::clearShadow()
if ( x2 <= offset.getX2() ) if ( x2 <= offset.getX2() )
{ {
for (int i=0; i < getHeight(); i++) for (int i = 0; i < getHeight(); i++)
{ {
setPrintPos (x2+1, y1+i); setPrintPos (x2 + 1, y1 + i);
print (' '); // clear █ print (' '); // clear █
} }
} }
if ( y2 <= offset.getY2() ) if ( y2 <= offset.getY2() )
{ {
setPrintPos (x1+1, y2+1); setPrintPos (x1 + 1, y2 + 1);
for (int i=1; i <= getWidth(); i++) for (int i = 1; i <= getWidth(); i++)
print (' '); // clear ▀ print (' '); // clear ▀
} }
@ -1567,9 +1567,9 @@ void FWidget::drawFlatBorder()
else else
setColor (wc.dialog_fg, wc.dialog_bg); setColor (wc.dialog_fg, wc.dialog_bg);
for (int y=0; y < getHeight(); y++) for (int y = 0; y < getHeight(); y++)
{ {
setPrintPos (x1-1, y1+y+1); setPrintPos (x1 - 1, y1 + y + 1);
if ( double_flatline_mask.left[uLong(y)] ) if ( double_flatline_mask.left[uLong(y)] )
print (fc::NF_rev_border_line_right_and_left); // left+right line (on left side) print (fc::NF_rev_border_line_right_and_left); // left+right line (on left side)
@ -1577,21 +1577,21 @@ void FWidget::drawFlatBorder()
print (fc::NF_rev_border_line_right); // right line (on left side) print (fc::NF_rev_border_line_right); // right line (on left side)
} }
setPrintPos (x2, y1+1); setPrintPos (x2, y1 + 1);
for (int y=0; y < getHeight(); y++) for (int y = 0; y < getHeight(); y++)
{ {
if ( double_flatline_mask.right[uLong(y)] ) if ( double_flatline_mask.right[uLong(y)] )
print (fc::NF_rev_border_line_right_and_left); // left+right line (on right side) print (fc::NF_rev_border_line_right_and_left); // left+right line (on right side)
else else
print (fc::NF_border_line_left); // left line (on right side) print (fc::NF_border_line_left); // left line (on right side)
setPrintPos (x2, y1+y+2); setPrintPos (x2, y1 + y + 2);
} }
setPrintPos (x1, y1); setPrintPos (x1, y1);
for (int x=0; x < getWidth(); x++) for (int x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.top[uLong(x)] ) if ( double_flatline_mask.top[uLong(x)] )
print (fc::NF_border_line_up_and_down); // top+bottom line (at top) print (fc::NF_border_line_up_and_down); // top+bottom line (at top)
@ -1601,7 +1601,7 @@ void FWidget::drawFlatBorder()
setPrintPos (x1, y2); setPrintPos (x1, y2);
for (int x=0; x < getWidth(); x++) for (int x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.bottom[uLong(x)] ) if ( double_flatline_mask.bottom[uLong(x)] )
print (fc::NF_border_line_up_and_down); // top+bottom line (at bottom) print (fc::NF_border_line_up_and_down); // top+bottom line (at bottom)
@ -1629,9 +1629,9 @@ void FWidget::clearFlatBorder()
setColor (wc.dialog_fg, wc.dialog_bg); setColor (wc.dialog_fg, wc.dialog_bg);
// clear on left side // clear on left side
for (register int y=0; y < getHeight(); y++) for (register int y = 0; y < getHeight(); y++)
{ {
setPrintPos (x1-1, y1+y+1); setPrintPos (x1 - 1, y1 + y + 1);
if ( double_flatline_mask.left[uLong(y)] ) if ( double_flatline_mask.left[uLong(y)] )
print (fc::NF_border_line_left); print (fc::NF_border_line_left);
@ -1640,9 +1640,9 @@ void FWidget::clearFlatBorder()
} }
// clear on right side // clear on right side
for (register int y=0; y < getHeight(); y++) for (register int y = 0; y < getHeight(); y++)
{ {
setPrintPos (x2, y1+y+1); setPrintPos (x2, y1 + y + 1);
if ( double_flatline_mask.right[uLong(y)] ) if ( double_flatline_mask.right[uLong(y)] )
print (fc::NF_rev_border_line_right); print (fc::NF_rev_border_line_right);
@ -1653,7 +1653,7 @@ void FWidget::clearFlatBorder()
// clear at top // clear at top
setPrintPos (x1, y1); setPrintPos (x1, y1);
for (register int x=0; x < getWidth(); x++) for (register int x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.top[uLong(x)] ) if ( double_flatline_mask.top[uLong(x)] )
print (fc::NF_border_line_upper); print (fc::NF_border_line_upper);
@ -1664,7 +1664,7 @@ void FWidget::clearFlatBorder()
// clear at bottom // clear at bottom
setPrintPos (x1, y2); setPrintPos (x1, y2);
for (register int x=0; x < getWidth(); x++) for (register int x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.bottom[uLong(x)] ) if ( double_flatline_mask.bottom[uLong(x)] )
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
@ -1699,12 +1699,12 @@ void FWidget::drawBorder (int x1, int y1, int x2, int y2)
setPrintPos (x1, y1); setPrintPos (x1, y1);
print (fc::NF_border_corner_middle_upper_left); // ┌ print (fc::NF_border_corner_middle_upper_left); // ┌
for (int x=x1+1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::NF_border_corner_middle_upper_right); // ┐ print (fc::NF_border_corner_middle_upper_right); // ┐
for (int y=y1+1; y <= y2; y++) for (int y = y1 + 1; y <= y2; y++)
{ {
setPrintPos (x1, y); setPrintPos (x1, y);
print (fc::NF_border_line_left); // border left ⎸ print (fc::NF_border_line_left); // border left ⎸
@ -1715,7 +1715,7 @@ void FWidget::drawBorder (int x1, int y1, int x2, int y2)
setPrintPos (x1, y2); setPrintPos (x1, y2);
print (fc::NF_border_corner_middle_lower_left); // └ print (fc::NF_border_corner_middle_lower_left); // └
for (int x=x1+1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::NF_border_corner_middle_lower_right); // ┘ print (fc::NF_border_corner_middle_lower_right); // ┘
@ -1725,12 +1725,12 @@ void FWidget::drawBorder (int x1, int y1, int x2, int y2)
setPrintPos (x1, y1); setPrintPos (x1, y1);
print (fc::BoxDrawingsDownAndRight); // ┌ print (fc::BoxDrawingsDownAndRight); // ┌
for (int x=x1+1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsDownAndLeft); // ┐ print (fc::BoxDrawingsDownAndLeft); // ┐
for (int y=y1+1; y < y2; y++) for (int y = y1 + 1; y < y2; y++)
{ {
setPrintPos (x1, y); setPrintPos (x1, y);
print (fc::BoxDrawingsVertical); // │ print (fc::BoxDrawingsVertical); // │
@ -1741,12 +1741,12 @@ void FWidget::drawBorder (int x1, int y1, int x2, int y2)
setPrintPos (x1, y2); setPrintPos (x1, y2);
print (fc::BoxDrawingsUpAndRight); // └ print (fc::BoxDrawingsUpAndRight); // └
for (int x=x1+1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsUpAndLeft); // ┘ print (fc::BoxDrawingsUpAndLeft); // ┘
for (int x=x1+1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
{ {
setPrintPos (x, y1); setPrintPos (x, y1);
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
@ -2368,7 +2368,7 @@ inline void FWidget::insufficientSpaceAdjust()
return; return;
// move left if not enough space // move left if not enough space
while ( getTermX()+getWidth()-padding.right > offset.getX2()+2 ) while ( getTermX() + getWidth() - padding.right > offset.getX2() + 2 )
{ {
adjust_wsize.x1_ref()--; adjust_wsize.x1_ref()--;
adjust_wsize.x2_ref()--; adjust_wsize.x2_ref()--;
@ -2378,7 +2378,7 @@ inline void FWidget::insufficientSpaceAdjust()
} }
// move up if not enough space // move up if not enough space
while ( getTermY()+getHeight()-padding.bottom > offset.getY2()+2 ) while ( getTermY() + getHeight() - padding.bottom > offset.getY2() + 2 )
{ {
adjust_wsize.y1_ref()--; adjust_wsize.y1_ref()--;
adjust_wsize.y2_ref()--; adjust_wsize.y2_ref()--;
@ -2388,7 +2388,7 @@ inline void FWidget::insufficientSpaceAdjust()
} }
// reduce the width if not enough space // reduce the width if not enough space
while ( offset.getX1()+getWidth()-1 > offset.getX2() ) while ( offset.getX1() + getWidth() - 1 > offset.getX2() )
adjust_wsize.x2_ref()--; adjust_wsize.x2_ref()--;
if ( getWidth() < size_hints.min_width ) if ( getWidth() < size_hints.min_width )
@ -2398,7 +2398,7 @@ inline void FWidget::insufficientSpaceAdjust()
adjust_wsize.setWidth(1); adjust_wsize.setWidth(1);
// reduce the height if not enough space // reduce the height if not enough space
while ( offset.getY1()+getHeight()-1 > offset.getY2() ) while ( offset.getY1() + getHeight() - 1 > offset.getY2() )
adjust_wsize.y2_ref()--; adjust_wsize.y2_ref()--;
if ( getHeight() < size_hints.min_height ) if ( getHeight() < size_hints.min_height )

View File

@ -263,12 +263,12 @@ void FWindow::drawBorder()
setPrintPos (x1, y1); setPrintPos (x1, y1);
print (fc::NF_border_corner_upper_left); // ⎡ print (fc::NF_border_corner_upper_left); // ⎡
for (int x=x1+1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::NF_border_line_upper); // ¯ print (fc::NF_border_line_upper); // ¯
print (fc::NF_rev_border_corner_upper_right); // ⎤ print (fc::NF_rev_border_corner_upper_right); // ⎤
for (int y=y1+1; y < y2; y++) for (int y = y1 + 1; y < y2; y++)
{ {
setPrintPos (x1, y); setPrintPos (x1, y);
// border left ⎸ // border left ⎸
@ -282,7 +282,7 @@ void FWindow::drawBorder()
// lower left corner border ⎣ // lower left corner border ⎣
print (fc::NF_border_corner_lower_left); print (fc::NF_border_corner_lower_left);
for (int x=2; x < getWidth(); x++) // low line _ for (int x = 2; x < getWidth(); x++) // low line _
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
setPrintPos (x2, y2); setPrintPos (x2, y2);

View File

@ -244,7 +244,7 @@ Calc::Calc (FWidget* parent)
setGeometry (19, 6, 37, 18); setGeometry (19, 6, 37, 18);
addAccelerator('q'); // press 'q' to quit addAccelerator('q'); // press 'q' to quit
for (int key=0; key < Calc::NUM_OF_BUTTONS; key++) for (int key = 0; key < Calc::NUM_OF_BUTTONS; key++)
{ {
Button* btn = new Button(this); Button* btn = new Button(this);
button_no[key] = key; button_no[key] = key;
@ -254,9 +254,9 @@ Calc::Calc (FWidget* parent)
else else
{ {
int x, y, n; int x, y, n;
(key <= Three) ? n=0 : n=1; (key <= Three) ? n = 0 : n = 1;
x = (key+n)%5*7 + 2; x = (key + n) % 5 * 7 + 2;
y = (key+n)/5*2 + 3; y = (key + n) / 5 * 2 + 3;
btn->setGeometry(x, y, 5, 1); btn->setGeometry(x, y, 5, 1);
} }
@ -395,9 +395,9 @@ bool Calc::isDataEntryKey (int key)
Nine Nine
}; };
int* iter = std::find (data_entry_keys, data_entry_keys+11, key); int* iter = std::find (data_entry_keys, data_entry_keys + 11, key);
if ( iter != data_entry_keys+11 ) if ( iter != data_entry_keys + 11 )
return true; return true;
else else
return false; return false;
@ -417,9 +417,9 @@ bool Calc::isOperatorKey(int key)
Equals Equals
}; };
int* iter = std::find (operators, operators+6, key); int* iter = std::find (operators, operators + 6, key);
if ( iter != operators+6 ) if ( iter != operators + 6 )
return true; return true;
else else
return false; return false;
@ -476,7 +476,7 @@ void Calc::calcInfixOperator()
case '+': case '+':
if ( std::fabs(a) > LDBL_EPSILON ) // a != 0.0L if ( std::fabs(a) > LDBL_EPSILON ) // a != 0.0L
{ {
if ( std::log(std::abs(a)) + std::log(std::abs(1 + b/a)) <= std::log(LDBL_MAX) ) if ( std::log(std::abs(a)) + std::log(std::abs(1 + b / a)) <= std::log(LDBL_MAX) )
a += b; a += b;
else else
error = true; error = true;
@ -488,7 +488,7 @@ void Calc::calcInfixOperator()
case '-': case '-':
if ( std::fabs(b) > LDBL_EPSILON ) // b != 0.0L if ( std::fabs(b) > LDBL_EPSILON ) // b != 0.0L
{ {
if ( std::log(std::abs(a)) + std::log(std::abs(1 - b/a)) <= std::log(LDBL_MAX) ) if ( std::log(std::abs(a)) + std::log(std::abs(1 - b / a)) <= std::log(LDBL_MAX) )
a -= b; a -= b;
else else
error = true; error = true;
@ -606,11 +606,11 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
else else
{ {
if ( arcus_mode ) if ( arcus_mode )
*x = std::asin(*x) * 180.0L/PI; *x = std::asin(*x) * 180.0L / PI;
else if ( std::fabs(std::fmod(*x,180.0L)) < LDBL_EPSILON ) // x/180 = 0 else if ( std::fabs(std::fmod(*x, 180.0L)) < LDBL_EPSILON ) // x / 180 = 0
*x = 0.0L; *x = 0.0L;
else else
*x = std::sin(*x * PI/180.0L); *x = std::sin(*x * PI / 180.0L);
} }
if ( errno == EDOM ) if ( errno == EDOM )
@ -642,11 +642,11 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
else else
{ {
if ( arcus_mode ) if ( arcus_mode )
*x = std::acos(*x) * 180.0L/PI; *x = std::acos(*x) * 180.0L / PI;
else if ( std::fabs(std::fmod(*x - 90.0L,180.0L)) < LDBL_EPSILON ) // (x - 90)/180 == 0 else if ( std::fabs(std::fmod(*x - 90.0L, 180.0L)) < LDBL_EPSILON ) // (x - 90) / 180 == 0
*x = 0.0L; *x = 0.0L;
else else
*x = std::cos(*x * PI/180.0L); *x = std::cos(*x * PI / 180.0L);
} }
if ( errno == EDOM ) if ( errno == EDOM )
@ -665,7 +665,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
if ( arcus_mode ) if ( arcus_mode )
if ( *x < 1 ) if ( *x < 1 )
{ {
*x = 0.5L * std::log((1+(*x))/(1-(*x))); *x = 0.5L * std::log((1 + (*x)) / (1 - (*x)));
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
@ -678,16 +678,16 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
else else
{ {
if ( arcus_mode ) if ( arcus_mode )
*x = std::atan(*x) * 180.0L/PI; *x = std::atan(*x) * 180.0L / PI;
else else
// Test if (x/180) != 0 and x/90 == 0 // Test if (x / 180) != 0 and x / 90 == 0
if ( std::fabs(std::fmod(*x,180.0L)) > LDBL_EPSILON if ( std::fabs(std::fmod(*x, 180.0L)) > LDBL_EPSILON
&& std::fabs(std::fmod(*x,90.0L)) < LDBL_EPSILON ) && std::fabs(std::fmod(*x, 90.0L)) < LDBL_EPSILON )
error = true; error = true;
else if ( std::fabs(std::fmod(*x,180.0L)) < LDBL_EPSILON ) // x/180 == 0 else if ( std::fabs(std::fmod(*x, 180.0L)) < LDBL_EPSILON ) // x / 180 == 0
*x = 0.0L; *x = 0.0L;
else else
*x = std::tan(*x * PI/180.0L); *x = std::tan(*x * PI / 180.0L);
} }
if ( errno == EDOM ) if ( errno == EDOM )
@ -700,12 +700,12 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
calculator_buttons[Hyperbolic]->setChecked(false); calculator_buttons[Hyperbolic]->setChecked(false);
break; break;
case Reciprocal: // 1/x case Reciprocal: // 1 / x
if ( std::fabs(*x) < LDBL_EPSILON ) // x == 0 if ( std::fabs(*x) < LDBL_EPSILON ) // x == 0
error = true; error = true;
else else
{ {
*x = 1/(*x); *x = 1 / (*x);
setDisplay(*x); setDisplay(*x);
} }
break; break;
@ -984,7 +984,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
while ( ! input.includes(L'e') while ( ! input.includes(L'e')
&& input.includes(L'.') && input.includes(L'.')
&& input.back() == L'0' ) && input.back() == L'0' )
input = input.left(input.getLength()-1); input = input.left(input.getLength() - 1);
} }
} }

View File

@ -91,7 +91,7 @@ Listbox::Listbox (FWidget* parent)
double_list = new std::list<double>; double_list = new std::list<double>;
for (double i=1; i<=15; i++) for (double i=1; i<=15; i++)
double_list->push_back(2*i + (i/100)); double_list->push_back(2 * i + (i / 100));
FListBox* list2 = new FListBox (this); FListBox* list2 = new FListBox (this);
list2->setGeometry(21, 1, 10, 10); list2->setGeometry(21, 1, 10, 10);

View File

@ -107,7 +107,7 @@ Listview::Listview (FWidget* parent)
const int lastItem = int(sizeof(weather) / sizeof(weather[0])) - 1; const int lastItem = int(sizeof(weather) / sizeof(weather[0])) - 1;
for (int i=0; i <= lastItem; i++) for (int i = 0; i <= lastItem; i++)
{ {
std::vector<FString> line (&weather[i][0], &weather[i][0] + 5); std::vector<FString> line (&weather[i][0], &weather[i][0] + 5);
listView->insert (line); listView->insert (line);

View File

@ -67,27 +67,27 @@ void Mandelbrot::draw()
dX = (x_max - x_min) / (Cols - 1); dX = (x_max - x_min) / (Cols - 1);
dY = (y_max - y_min) / Lines; dY = (y_max - y_min) / Lines;
for (y0=y_min; y0 < y_max && current_line < Lines; y0+=dY) for (y0 = y_min; y0 < y_max && current_line < Lines; y0 += dY)
{ {
current_line++; current_line++;
setPrintPos (xoffset, yoffset + current_line); setPrintPos (xoffset, yoffset + current_line);
for (x0=x_min; x0 < x_max; x0+=dX) for (x0 = x_min; x0 < x_max; x0 += dX)
{ {
x = 0.0; x = 0.0;
y = 0.0; y = 0.0;
iter = 0; iter = 0;
while ( x*x + y*y < 4 && iter < max_iter ) while ( x * x + y * y < 4 && iter < max_iter )
{ {
xtemp = x*x - y*y + x0; xtemp = x * x - y * y + x0;
y = 2*x*y + y0; y = 2 * x * y + y0;
x = xtemp; x = xtemp;
iter++; iter++;
} }
if ( iter < max_iter ) if ( iter < max_iter )
setColor(fc::Black, iter%16); setColor(fc::Black, iter % 16);
else else
setColor(fc::Black, 0); setColor(fc::Black, 0);

View File

@ -206,7 +206,7 @@ Menu::~Menu()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Menu::defaultCallback (FMenuList* mb) void Menu::defaultCallback (FMenuList* mb)
{ {
for (uInt i=1; i <= mb->getCount(); i++) for (uInt i = 1; i <= mb->getCount(); i++)
{ {
FMenuItem* item = mb->getItem(int(i)); FMenuItem* item = mb->getItem(int(i));
@ -292,7 +292,7 @@ int main (int argc, char* argv[])
Menu main_dlg (&app); Menu main_dlg (&app);
main_dlg.setText ("Menu example"); main_dlg.setText ("Menu example");
main_dlg.setGeometry (int(1+(app.getWidth()-40)/2), 2, 40, 6); main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6);
main_dlg.setShadow(); main_dlg.setShadow();
app.setMainWidget (&main_dlg); app.setMainWidget (&main_dlg);

View File

@ -81,7 +81,7 @@ void ColorChooser::onMouseDown (FMouseEvent* ev)
if ( ev->getButton() == fc::MiddleButton ) if ( ev->getButton() == fc::MiddleButton )
return; return;
for (int c=0; c < 16; c++) for (int c = 0; c < 16; c++)
{ {
int xmin = 2 + (c / 8) * 3; int xmin = 2 + (c / 8) * 3;
int xmax = 4 + (c / 8) * 3; int xmax = 4 + (c / 8) * 3;
@ -106,9 +106,9 @@ void ColorChooser::draw()
setColor(); setColor();
FWidget::drawBorder (1, 2, 8, 11); FWidget::drawBorder (1, 2, 8, 11);
for (short c=0; c < 16; c++) for (short c = 0; c < 16; c++)
{ {
setPrintPos (2 + (c/8)*3, 3 + c%8); setPrintPos (2 + (c / 8) * 3, 3 + c % 8);
if ( c < 6 ) if ( c < 6 )
setColor (fc::LightGray, c); setColor (fc::LightGray, c);
@ -363,7 +363,7 @@ void MouseDraw::setGeometry (int x, int y, int w, int h, bool adjust)
FDialog::setGeometry (x, y, w, h, adjust); FDialog::setGeometry (x, y, w, h, adjust);
FPoint no_shadow(0,0); FPoint no_shadow(0,0);
FRect scroll_geometry (0, 0, w-11, h-3); FRect scroll_geometry (0, 0, w - 11, h - 3);
old_w = canvas->width; old_w = canvas->width;
old_h = canvas->height; old_h = canvas->height;
resizeArea (scroll_geometry, no_shadow, canvas); resizeArea (scroll_geometry, no_shadow, canvas);
@ -406,7 +406,7 @@ void MouseDraw::draw()
setPrintPos (10, 2); setPrintPos (10, 2);
print (wchar_t(fc::BoxDrawingsDownAndHorizontal)); print (wchar_t(fc::BoxDrawingsDownAndHorizontal));
for (int y=3; y < y_max; y++) for (int y = 3; y < y_max; y++)
{ {
setPrintPos (10, y); setPrintPos (10, y);
print (wchar_t(fc::BoxDrawingsVertical)); print (wchar_t(fc::BoxDrawingsVertical));
@ -457,19 +457,19 @@ void MouseDraw::drawCanvas()
x_end = canvas->width; x_end = canvas->width;
int w_line_len = print_area->width + print_area->right_shadow; int 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
{ {
char_data* cc; // canvas character char_data* cc; // canvas character
char_data* wc; // window character char_data* wc; // window character
cc = &canvas->text[y * x_end]; cc = &canvas->text[y * x_end];
wc = &print_area->text[(ay+y) * w_line_len + ax]; wc = &print_area->text[(ay + y) * w_line_len + ax];
std::memcpy (wc, cc, sizeof(char_data) * unsigned(x_end)); std::memcpy (wc, cc, sizeof(char_data) * unsigned(x_end));
if ( short(print_area->changes[ay+y].xmin) > ax ) if ( short(print_area->changes[ay + y].xmin) > ax )
print_area->changes[ay+y].xmin = uInt(ax); print_area->changes[ay + y].xmin = uInt(ax);
if ( short(print_area->changes[ay+y].xmax) < ax+x_end-1 ) if ( short(print_area->changes[ay + y].xmax) < ax + x_end - 1 )
print_area->changes[ay+y].xmax = uInt(ax+x_end-1); print_area->changes[ay + y].xmax = uInt(ax + x_end - 1);
} }
print_area->has_changes = true; print_area->has_changes = true;

View File

@ -82,7 +82,7 @@ void move (int xold, int yold, int xnew, int ynew)
buffer = terminal->moveCursor (xold, yold, xnew, ynew); buffer = terminal->moveCursor (xold, yold, xnew, ynew);
len = uInt(std::strlen(buffer)); len = uInt(std::strlen(buffer));
for (uInt i=0; i < len; i++) for (uInt i = 0; i < len; i++)
{ {
switch ( buffer[i] ) switch ( buffer[i] )
{ {
@ -134,7 +134,7 @@ int main (int argc, char* argv[])
terminal = new FVTerm(&app); terminal = new FVTerm(&app);
xmax = terminal->getColumnNumber() - 1; xmax = terminal->getColumnNumber() - 1;
ymax = terminal->getLineNumber() - 1; ymax = terminal->getLineNumber() - 1;
FString line(xmax+1, '-'); FString line(xmax + 1, '-');
terminal->setTermXY(0,0); terminal->setTermXY(0,0);
terminal->setNormal(); terminal->setNormal();
@ -154,7 +154,7 @@ int main (int argc, char* argv[])
move (5, ymax, 5, 0); move (5, ymax, 5, 0);
move (xmax, 1, 0, 1); move (xmax, 1, 0, 1);
move (xmax, 1, 0, 2); move (xmax, 1, 0, 2);
move (xmax+1, 1, 0, 2); move (xmax + 1, 1, 0, 2);
move (9, 4, 10, 4); move (9, 4, 10, 4);
move (10, 4, 9, 4); move (10, 4, 9, 4);
move (9, 4, 11, 4); move (9, 4, 11, 4);
@ -165,7 +165,7 @@ int main (int argc, char* argv[])
move (16, 0, 16, 2); move (16, 0, 16, 2);
move (16, 2, 16, 0); move (16, 2, 16, 0);
move (3, 2, xmax, 2); move (3, 2, xmax, 2);
move (5, 5, xmax-5, ymax-5); move (5, 5, xmax - 5, ymax - 5);
keyPressed(); keyPressed();

View File

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

View File

@ -63,10 +63,10 @@ AttribDlg::AttribDlg (FWidget* parent)
+ ")"); + ")");
next_button = new FButton("&Next >", this); next_button = new FButton("&Next >", this);
next_button->setGeometry(getWidth()-13, getHeight()-4, 10, 1); next_button->setGeometry(getWidth() - 13, getHeight() - 4, 10, 1);
next_button->addAccelerator(fc::Fkey_right); next_button->addAccelerator(fc::Fkey_right);
back_button = new FButton("< &Back", this); back_button = new FButton("< &Back", this);
back_button->setGeometry(getWidth()-25, getHeight()-4, 10, 1); back_button->setGeometry(getWidth() - 25, getHeight() - 4, 10, 1);
back_button->addAccelerator(fc::Fkey_left); back_button->addAccelerator(fc::Fkey_left);
// Add function callbacks // Add function callbacks
@ -151,8 +151,8 @@ void AttribDlg::cb_back (FWidget*, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDlg::adjustSize() void AttribDlg::adjustSize()
{ {
int x = ((getParentWidget()->getWidth() - getWidth()) / 2 ); int x = ((getParentWidget()->getWidth() - getWidth()) / 2);
int y = ((getParentWidget()->getHeight() - getHeight()) / 2 ) + 1; int y = ((getParentWidget()->getHeight() - getHeight()) / 2) + 1;
if ( x < 1 ) if ( x < 1 )
x = 1; x = 1;
@ -161,8 +161,8 @@ void AttribDlg::adjustSize()
y = 1; y = 1;
setGeometry(x, y, 69, 21, false); setGeometry(x, y, 69, 21, false);
next_button->setGeometry(getWidth()-13, getHeight()-4, 10, 1, false); next_button->setGeometry(getWidth() - 13, getHeight() - 4, 10, 1, false);
back_button->setGeometry(getWidth()-25, getHeight()-4, 10, 1, false); back_button->setGeometry(getWidth() - 25, getHeight() - 4, 10, 1, false);
FDialog::adjustSize(); FDialog::adjustSize();
} }
@ -222,7 +222,7 @@ void AttribDemo::printColorLine()
{ {
AttribDlg* parent = static_cast<AttribDlg*>(getParent()); AttribDlg* parent = static_cast<AttribDlg*>(getParent());
for (short color=0; color < colors; color++) for (short color = 0; color < colors; color++)
{ {
setColor (color, parent->bgcolor); setColor (color, parent->bgcolor);
print (" # "); print (" # ");
@ -264,9 +264,9 @@ void AttribDemo::draw()
// test alternate character set // test alternate character set
printAltCharset(); printAltCharset();
for (int y=0; y < getParentWidget()->getHeight()-7; y++) for (int y = 0; y < getParentWidget()->getHeight() - 7; y++)
{ {
setPrintPos (1, 2+y); setPrintPos (1, 2 + y);
if ( ! isMonochron() ) if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg); setColor (wc.label_fg, wc.label_bg);

View File

@ -50,7 +50,7 @@ void tcapString (const std::string& name, const char* cap_str)
len = uInt(std::strlen(cap_str)); len = uInt(std::strlen(cap_str));
for (uInt i=0; i < len; i++) for (uInt i = 0; i < len; i++)
{ {
char c = cap_str[i]; char c = cap_str[i];

View File

@ -90,9 +90,9 @@ void Transparent::draw()
FString line(getClientWidth(), wchar_t('.')); FString line(getClientWidth(), wchar_t('.'));
for (int n=1; n <= getClientHeight(); n++) for (int n = 1; n <= getClientHeight(); n++)
{ {
setPrintPos (2, 2+n); setPrintPos (2, 2 + n);
print(line); print(line);
} }

View File

@ -69,7 +69,7 @@ Treeview::Treeview (FWidget* parent)
const int lastItem = int(sizeof(continent) / sizeof(continent[0])) - 1; const int lastItem = int(sizeof(continent) / sizeof(continent[0])) - 1;
for (int i=0; i <= lastItem; i++) for (int i = 0; i <= lastItem; i++)
{ {
std::vector<FString> line (&continent[i][0], &continent[i][0] + 3); std::vector<FString> line (&continent[i][0], &continent[i][0] + 3);
listView->insert (line); listView->insert (line);

View File

@ -52,7 +52,7 @@ ProgressDialog::ProgressDialog (FWidget* parent)
, more() , more()
, quit() , quit()
{ {
setGeometry (int((this->getParentWidget()->getWidth()-40)/2), 7, 40, 10); setGeometry (int((this->getParentWidget()->getWidth() - 40) / 2), 7, 40, 10);
setText("Progress bar"); setText("Progress bar");
//setModal(); //setModal();
@ -198,7 +198,7 @@ TextWindow::TextWindow (FWidget* parent)
{ {
scrollText = new FTextView(this); scrollText = new FTextView(this);
scrollText->ignorePadding(); scrollText->ignorePadding();
scrollText->setGeometry (1, 2, getWidth(), getHeight()-1); scrollText->setGeometry (1, 2, getWidth(), getHeight() - 1);
setMinimumSize (51, 6); setMinimumSize (51, 6);
scrollText->setFocus(); scrollText->setFocus();
scrollText->insert(" -----------------------------------------------\n" scrollText->insert(" -----------------------------------------------\n"
@ -225,7 +225,7 @@ void TextWindow::append (const FString& str)
void TextWindow::adjustSize() void TextWindow::adjustSize()
{ {
FDialog::adjustSize(); FDialog::adjustSize();
scrollText->setGeometry (1, 2, getWidth(), getHeight()-1); scrollText->setGeometry (1, 2, getWidth(), getHeight() - 1);
} }
@ -508,7 +508,7 @@ MyDialog::MyDialog (FWidget* parent)
myList->setStatusbarMessage ("99 items in a list"); myList->setStatusbarMessage ("99 items in a list");
myList->setMultiSelection(); myList->setMultiSelection();
for (int z=1; z < 100; z++) for (int z = 1; z < 100; z++)
myList->insert (FString().setNumber(z) + L" placeholder"); myList->insert (FString().setNumber(z) + L" placeholder");
// Text labels // Text labels
@ -823,7 +823,7 @@ void MyDialog::cb_updateNumber (FWidget* widget, data_ptr data)
int select_num = 0; int select_num = 0;
uInt end = list->getCount(); uInt end = list->getCount();
for (uInt n=1; n <= end; n++) for (uInt n = 1; n <= end; n++)
if ( list->isSelected(int(n)) ) if ( list->isSelected(int(n)) )
select_num++; select_num++;
@ -862,10 +862,10 @@ void MyDialog::cb_view (FWidget*, data_ptr data)
TextWindow* view = new TextWindow(this); TextWindow* view = new TextWindow(this);
FString filename(basename(const_cast<char*>(file.c_str()))); FString filename(basename(const_cast<char*>(file.c_str())));
view->setText ("Viewer: " + filename); view->setText ("Viewer: " + filename);
view->setGeometry (1+int((getRootWidget()->getWidth()-60)/2), view->setGeometry (1 + int((getRootWidget()->getWidth() - 60) / 2),
int(getRootWidget()->getHeight()/6), int(getRootWidget()->getHeight() / 6),
60, 60,
int(getRootWidget()->getHeight()*3/4)); int(getRootWidget()->getHeight() * 3 / 4));
view->setResizeable(); view->setResizeable();
std::string line = ""; std::string line = "";
@ -929,7 +929,7 @@ int main (int argc, char* argv[])
MyDialog d(&app); MyDialog d(&app);
d.setText (title); d.setText (title);
d.setGeometry (int((app.getWidth()-56)/2), 2, 56, app.getHeight()-4); d.setGeometry (int((app.getWidth() - 56) / 2), 2, 56, app.getHeight() - 4);
d.setShadow(); d.setShadow();
app.setMainWidget(&d); app.setMainWidget(&d);

View File

@ -67,7 +67,7 @@ watch::watch (FWidget* parent)
{ {
setText ("Watch"); setText ("Watch");
int pw = getParentWidget()->getWidth(); int pw = getParentWidget()->getWidth();
setGeometry (1+(pw-22)/2, 3, 22, 13); setGeometry (1 + (pw - 22) / 2, 3, 22, 13);
// Create labels // Create labels
time_label = new FLabel(L"Time", this); time_label = new FLabel(L"Time", this);
@ -200,7 +200,7 @@ void watch::cb_exitApp (FWidget*, data_ptr)
void watch::adjustSize() void watch::adjustSize()
{ {
int pw = getParentWidget()->getWidth(); int pw = getParentWidget()->getWidth();
setX (1+(pw-22)/2, false); setX (1 + (pw - 22) / 2, false);
FDialog::adjustSize(); FDialog::adjustSize();
} }

View File

@ -311,7 +311,7 @@ Window::Window (FWidget* parent)
F_METHOD_CALLBACK (this, &Window::cb_exitApp) F_METHOD_CALLBACK (this, &Window::cb_exitApp)
); );
for (int n=1; n <= 6; n++) for (int n = 1; n <= 6; n++)
{ {
win_data* win_dat = new win_data; win_data* win_dat = new win_data;
win_dat->is_open = false; win_dat->is_open = false;
@ -374,8 +374,8 @@ void Window::adjustSize()
{ {
int x,y,n; int x,y,n;
n = int(std::distance(begin, iter)); n = int(std::distance(begin, iter));
x = dx + 5 + (n%3)*25 + int(n/3)*3; x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
y = dy + 11 + int(n/3)*3; y = dy + 11 + int(n / 3) * 3;
(*iter)->dgl->setPos (x, y); (*iter)->dgl->setPos (x, y);
} }
@ -424,8 +424,8 @@ void Window::cb_createWindows (FWidget*, data_ptr)
win_dat->is_open = true; win_dat->is_open = true;
win->setText(*(win_dat)->title); win->setText(*(win_dat)->title);
n = int(std::distance(begin, iter)); n = int(std::distance(begin, iter));
x = dx + 5 + (n%3)*25 + int(n/3)*3; x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
y = dy + 11 + int(n/3)*3; y = dy + 11 + int(n / 3) * 3;
win->setGeometry (x, y, 20, 8); win->setGeometry (x, y, 20, 8);
win->setMinimumSize (20, 8); win->setMinimumSize (20, 8);
win->setResizeable(); win->setResizeable();
@ -579,7 +579,7 @@ int main (int argc, char* argv[])
Window main_dlg (&app); Window main_dlg (&app);
main_dlg.setText ("Main window"); main_dlg.setText ("Main window");
main_dlg.setGeometry (int(1+(app.getWidth()-40)/2), 2, 40, 6); main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6);
app.setMainWidget (&main_dlg); app.setMainWidget (&main_dlg);
main_dlg.show(); main_dlg.show();