Some small code improvements
This commit is contained in:
parent
076598c988
commit
fc45c3c1a5
|
@ -1,6 +1,7 @@
|
|||
2018-09-02 Markus Gans <guru.mail@muenster.de>
|
||||
* Fix mouse wheel behavior over horizontal scroll bars
|
||||
in FTextView
|
||||
* Some small code improvements
|
||||
|
||||
2018-09-01 Markus Gans <guru.mail@muenster.de>
|
||||
* Compiles now with newer gcc
|
||||
|
|
|
@ -91,7 +91,7 @@ void move (int xold, int yold, int xnew, int ynew)
|
|||
// prints the cursor move escape sequence
|
||||
std::string sequence;
|
||||
char* buffer;
|
||||
char from[10], to[10], byte[20];
|
||||
char from[26], to[26], byte[20];
|
||||
uInt len;
|
||||
const std::string ctrl_character[] =
|
||||
{
|
||||
|
@ -104,8 +104,8 @@ void move (int xold, int yold, int xnew, int ynew)
|
|||
|
||||
term_boundaries(xold, yold);
|
||||
term_boundaries(xnew, ynew);
|
||||
snprintf (from, sizeof(from), "(%d;%d)", xold, yold);
|
||||
snprintf (to, sizeof(to), "(%d;%d)", xnew, ynew);
|
||||
snprintf (from, sizeof(from), "(%3d;%3d)", xold, yold);
|
||||
snprintf (to, sizeof(to), "(%3d;%3d)", xnew, ynew);
|
||||
std::cout << std::right << std::setw(10) << from
|
||||
<< " -> "
|
||||
<< std::left << std::setw(10) << to
|
||||
|
|
|
@ -372,8 +372,12 @@ int FKeyboard::UTF8decode (const char utf8[])
|
|||
{
|
||||
register int ucs = 0;
|
||||
const int max = 4;
|
||||
int len = int(std::strlen(utf8));
|
||||
|
||||
for (register int i = 0; i < int(std::strlen(utf8)) && i < max; ++i)
|
||||
if ( len > max )
|
||||
len = max;
|
||||
|
||||
for (register int i = 0; i < len; ++i)
|
||||
{
|
||||
register uChar ch = uChar(utf8[i]);
|
||||
|
||||
|
|
|
@ -538,16 +538,12 @@ void FLineEdit::onTimer (FTimerEvent*)
|
|||
return;
|
||||
}
|
||||
|
||||
if ( text_offset > 0 )
|
||||
text_offset--;
|
||||
|
||||
if ( text_offset < 0 )
|
||||
text_offset = 0;
|
||||
|
||||
if ( cursor_pos > 0 )
|
||||
cursor_pos--;
|
||||
|
||||
if ( cursor_pos < 0 )
|
||||
cursor_pos = 0;
|
||||
|
||||
break;
|
||||
|
||||
case FLineEdit::scrollRight:
|
||||
|
@ -557,16 +553,12 @@ void FLineEdit::onTimer (FTimerEvent*)
|
|||
return;
|
||||
}
|
||||
|
||||
if ( text_offset <= len - getWidth() + 1 )
|
||||
text_offset++;
|
||||
|
||||
if ( text_offset > len - getWidth() + 2 )
|
||||
text_offset = len - getWidth() + 2;
|
||||
|
||||
if ( cursor_pos < len )
|
||||
cursor_pos++;
|
||||
|
||||
if ( cursor_pos > len )
|
||||
cursor_pos = len;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -804,11 +796,9 @@ void FLineEdit::drawInputField()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::keyLeft()
|
||||
{
|
||||
if ( cursor_pos > 0 )
|
||||
cursor_pos--;
|
||||
|
||||
if ( cursor_pos < 0 )
|
||||
cursor_pos = 0;
|
||||
|
||||
if ( cursor_pos < text_offset )
|
||||
text_offset--;
|
||||
}
|
||||
|
@ -817,10 +807,9 @@ inline void FLineEdit::keyLeft()
|
|||
inline void FLineEdit::keyRight()
|
||||
{
|
||||
int len = int(text.getLength());
|
||||
cursor_pos++;
|
||||
|
||||
if ( cursor_pos >= len )
|
||||
cursor_pos = len;
|
||||
if ( cursor_pos < len )
|
||||
cursor_pos++;
|
||||
|
||||
if ( cursor_pos - text_offset >= getWidth() - 2
|
||||
&& text_offset <= len - getWidth() + 1 )
|
||||
|
|
|
@ -1814,10 +1814,8 @@ inline void FListView::keyLeft (int& first_line_position_before)
|
|||
else
|
||||
{
|
||||
// Scroll left
|
||||
if ( xoffset > 0 )
|
||||
xoffset--;
|
||||
|
||||
if ( xoffset < 0 )
|
||||
xoffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1838,11 +1836,9 @@ inline void FListView::keyRight (int& first_line_position_before)
|
|||
else
|
||||
{
|
||||
// Scroll right
|
||||
if ( xoffset < xoffset_end )
|
||||
xoffset++;
|
||||
|
||||
if ( xoffset > xoffset_end )
|
||||
xoffset = xoffset_end;
|
||||
|
||||
if ( xoffset < 0 )
|
||||
xoffset = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue