some code improvements

This commit is contained in:
Markus Gans 2016-01-10 10:42:55 +01:00
parent 8ba652eb07
commit 65047855e9
4 changed files with 32 additions and 30 deletions

View File

@ -297,17 +297,17 @@ void FApplication::processKeyboardEvent()
if ( key == fc::Fkey_mouse ) if ( key == fc::Fkey_mouse )
{ {
int n, len; int n;
const int len = 6;
x11_mouse[0] = fifo_buf[3]; x11_mouse[0] = fifo_buf[3];
x11_mouse[1] = fifo_buf[4]; x11_mouse[1] = fifo_buf[4];
x11_mouse[2] = fifo_buf[5]; x11_mouse[2] = fifo_buf[5];
x11_mouse[3] = '\0'; x11_mouse[3] = '\0';
len = 6;
n = len;
for (; 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];
for (; n-len < len; n++) // Fill rest with '\0' n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0'; fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0'); input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent(); processMouseEvent();
@ -325,9 +325,10 @@ void FApplication::processKeyboardEvent()
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];
for (; n-len < len; n++) // Fill rest with '\0' n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0'; fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0'); input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent(); processMouseEvent();
@ -345,9 +346,10 @@ void FApplication::processKeyboardEvent()
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];
for (; n-len < len; n++) // Fill rest with '\0' n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0'; fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0'); input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent(); processMouseEvent();

View File

@ -229,7 +229,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(maxItemWidth)+2 > getColumnNumber() ) if ( x_pos+int(maxItemWidth) >= getColumnNumber()-1 )
{ {
x_pos = getColumnNumber() - int(maxItemWidth + 1); x_pos = getColumnNumber() - int(maxItemWidth + 1);
// Menu to large for the screen // Menu to large for the screen
@ -1004,13 +1004,13 @@ void FMenu::onMouseDown (FMouseEvent* ev)
int x1, x2, y, mouse_x, mouse_y; int x1, x2, y, mouse_x, mouse_y;
x1 = (*iter)->getX(); x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth() - 1; x2 = (*iter)->getX() + (*iter)->getWidth();
y = (*iter)->getY(); y = (*iter)->getY();
mouse_x = mouse_pos.getX(); mouse_x = mouse_pos.getX();
mouse_y = mouse_pos.getY(); mouse_y = mouse_pos.getY();
if ( mouse_x >= x1 if ( mouse_x >= x1
&& mouse_x <= x2 && mouse_x < x2
&& mouse_y == y ) && mouse_y == y )
{ {
// Mouse pointer over item // Mouse pointer over item
@ -1102,7 +1102,7 @@ void FMenu::onMouseUp (FMouseEvent* ev)
int x1, x2, y; int x1, x2, y;
x1 = (*iter)->getX(); x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth() - 1; x2 = (*iter)->getX() + (*iter)->getWidth();
y = (*iter)->getY(); y = (*iter)->getY();
if ( (*iter)->isSelected() ) if ( (*iter)->isSelected() )
@ -1111,7 +1111,7 @@ void FMenu::onMouseUp (FMouseEvent* ev)
int mouse_y = mouse_pos.getY(); int mouse_y = mouse_pos.getY();
if ( mouse_x >= x1 if ( mouse_x >= x1
&& mouse_x <= x2 && mouse_x < x2
&& mouse_y == y ) && mouse_y == y )
{ {
// Mouse pointer over item // Mouse pointer over item
@ -1208,13 +1208,13 @@ void FMenu::onMouseMove (FMouseEvent* ev)
int x1, x2, y, mouse_x, mouse_y; int x1, x2, y, mouse_x, mouse_y;
x1 = (*iter)->getX(); x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth() - 1; x2 = (*iter)->getX() + (*iter)->getWidth();
y = (*iter)->getY(); y = (*iter)->getY();
mouse_x = mouse_pos.getX(); mouse_x = mouse_pos.getX();
mouse_y = mouse_pos.getY(); mouse_y = mouse_pos.getY();
if ( mouse_x >= x1 if ( mouse_x >= x1
&& mouse_x <= x2 && mouse_x < x2
&& mouse_y == y ) && mouse_y == y )
{ {
if ( (*iter)->isEnabled() if ( (*iter)->isEnabled()

View File

@ -402,7 +402,7 @@ void FMenuBar::drawItems()
gotoxy(screenWidth-1,1); gotoxy(screenWidth-1,1);
print (vmenubar, ".."); print (vmenubar, "..");
} }
else if ( startpos-2 < screenWidth ) else if ( startpos-1 <= screenWidth )
{ {
gotoxy(screenWidth,1); gotoxy(screenWidth,1);
print (vmenubar, ' '); print (vmenubar, ' ');
@ -579,10 +579,10 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
{ {
int x1, x2; int x1, x2;
x1 = (*iter)->getX(); x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth() - 1; x2 = (*iter)->getX() + (*iter)->getWidth();
if ( mouse_x >= x1 if ( mouse_x >= x1
&& mouse_x <= x2 && mouse_x < x2
&& mouse_y == 1 ) && mouse_y == 1 )
{ {
// Mouse pointer over item // Mouse pointer over item
@ -656,10 +656,10 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
int x1, x2; int x1, x2;
x1 = (*iter)->getX(); x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth() - 1; x2 = (*iter)->getX() + (*iter)->getWidth();
if ( mouse_x >= x1 if ( mouse_x >= x1
&& mouse_x <= x2 && mouse_x < x2
&& mouse_y == 1 && mouse_y == 1
&& (*iter)->isEnabled() && (*iter)->isEnabled()
&& (*iter)->isSelected() ) && (*iter)->isSelected() )
@ -744,10 +744,10 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
int x1, x2; int x1, x2;
x1 = (*iter)->getX(); x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth() - 1; x2 = (*iter)->getX() + (*iter)->getWidth();
if ( mouse_x >= x1 if ( mouse_x >= x1
&& mouse_x <= x2 && mouse_x < x2
&& mouse_y == 1 ) && mouse_y == 1 )
{ {
// Mouse pointer over item // Mouse pointer over item

View File

@ -2862,8 +2862,8 @@ void FTerm::updateTerminal()
} }
vt = vterm; vt = vterm;
term_width = term->getWidth(); term_width = term->getWidth() - 1;
term_height = term->getHeight(); term_height = term->getHeight() - 1;
for (register uInt y=0; y < uInt(vt->height); y++) for (register uInt y=0; y < uInt(vt->height); y++)
{ {
@ -2880,8 +2880,8 @@ void FTerm::updateTerminal()
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];
if ( x_term_pos == term_width - 1 if ( x_term_pos == term_width
&& y_term_pos == term_height - 1 ) && y_term_pos == term_height )
appendLowerRight (print_char); appendLowerRight (print_char);
else else
appendCharacter (print_char); appendCharacter (print_char);
@ -2892,9 +2892,9 @@ void FTerm::updateTerminal()
vt->changes[y].xmax = 0; vt->changes[y].xmax = 0;
} }
// cursor wrap // cursor wrap
if ( x_term_pos >= term_width ) if ( x_term_pos > term_width )
{ {
if ( y_term_pos == term_height - 1 ) if ( y_term_pos == term_height )
x_term_pos--; x_term_pos--;
else else
{ {