Refactoring FOptiMove::verticalMove and FOptiMove::horizontalMove
This commit is contained in:
parent
c2d7f8b8ee
commit
2af1b1d0d4
|
@ -1,3 +1,8 @@
|
|||
2017-10-02 Markus Gans <guru.mail@muenster.de>
|
||||
* Refactoring FOptiMove::verticalMove and FOptiMove::horizontalMove
|
||||
* Refactoring FVTerm::getCharacter
|
||||
* Refactoring FWidget::drawBorder
|
||||
|
||||
2017-02-02 Markus Gans <guru.mail@muenster.de>
|
||||
* Avoids flickering when redrawing a focused widget
|
||||
|
||||
|
|
|
@ -139,7 +139,12 @@ class FOptiMove
|
|||
int repeatedAppend (const capability&, volatile int, char*);
|
||||
int relativeMove (char[], int, int, int, int);
|
||||
int verticalMove (char[], int, int);
|
||||
void downMove (char[], int&, int, int);
|
||||
void upMove (char[], int&, int, int);
|
||||
int horizontalMove (char[], int, int);
|
||||
void rightMove (char[], int&, int, int);
|
||||
void leftMove (char[], int&, int, int);
|
||||
|
||||
bool isWideMove (int, int, int, int);
|
||||
bool isMethod0Faster (int&, int, int);
|
||||
bool isMethod1Faster (int&, int, int, int, int);
|
||||
|
|
|
@ -401,6 +401,8 @@ class FVTerm : public FTerm
|
|||
static void putAreaLine (char_data*, char_data*, int);
|
||||
static void putAreaCharacter ( int, int, FVTerm*
|
||||
, char_data*, char_data* );
|
||||
static void getAreaCharacter ( int, int, term_area*
|
||||
, char_data*& );
|
||||
static bool clearTerm (int = ' ');
|
||||
static bool clearFullArea (term_area*, char_data&);
|
||||
static void clearAreaWithShadow (term_area*, char_data&);
|
||||
|
@ -412,6 +414,7 @@ class FVTerm : public FTerm
|
|||
static exit_state eraseCharacters (uInt&, uInt, uInt, bool);
|
||||
static exit_state repeatCharacter (uInt&, uInt, uInt);
|
||||
static void cursorWrap();
|
||||
bool printWrap (term_area*);
|
||||
static void updateTerminalLine (uInt);
|
||||
static bool updateTerminalCursor();
|
||||
static bool isInsideTerminal (int, int);
|
||||
|
@ -436,6 +439,8 @@ class FVTerm : public FTerm
|
|||
static std::queue<int>* output_buffer;
|
||||
static char_data term_attribute;
|
||||
static char_data next_attribute;
|
||||
static char_data s_ch; // shadow character
|
||||
static char_data i_ch; // inherit background character
|
||||
static FPoint* term_pos; // terminal cursor position
|
||||
static termcap_map* tcap;
|
||||
static bool hidden_cursor;
|
||||
|
@ -570,24 +575,9 @@ inline void FVTerm::setColor (register short fg, register short bg)
|
|||
inline void FVTerm::setNormal()
|
||||
{
|
||||
// reset all character attributes
|
||||
next_attribute.attr.bit.bold = \
|
||||
next_attribute.attr.bit.dim = \
|
||||
next_attribute.attr.bit.italic = \
|
||||
next_attribute.attr.bit.underline = \
|
||||
next_attribute.attr.bit.blink = \
|
||||
next_attribute.attr.bit.reverse = \
|
||||
next_attribute.attr.bit.standout = \
|
||||
next_attribute.attr.bit.invisible = \
|
||||
next_attribute.attr.bit.protect = \
|
||||
next_attribute.attr.bit.crossed_out = \
|
||||
next_attribute.attr.bit.dbl_underline = \
|
||||
next_attribute.attr.bit.alt_charset = \
|
||||
next_attribute.attr.bit.pc_charset = \
|
||||
next_attribute.attr.bit.transparent = \
|
||||
next_attribute.attr.bit.trans_shadow = \
|
||||
next_attribute.attr.bit.inherit_bg = \
|
||||
next_attribute.attr.bit.no_changes = false;
|
||||
|
||||
next_attribute.attr.byte[0] = 0;
|
||||
next_attribute.attr.byte[1] = 0;
|
||||
next_attribute.attr.bit.no_changes = false;
|
||||
next_attribute.fg_color = fc::Default;
|
||||
next_attribute.bg_color = fc::Default;
|
||||
}
|
||||
|
|
|
@ -394,9 +394,9 @@ class FWidget : public FVTerm, public FObject
|
|||
void drawChildren();
|
||||
void drawTransparentShadow (int, int, int, int);
|
||||
void drawBlockShadow (int, int, int, int);
|
||||
void drawBox (int, int, int, int);
|
||||
void drawNewFontBox (int, int, int, int);
|
||||
static void setColorTheme();
|
||||
static void set8ColorTheme();
|
||||
static void set16ColorTheme();
|
||||
|
||||
// Data Members
|
||||
bool enable;
|
||||
|
@ -598,6 +598,7 @@ inline const FRect& FWidget::getGeometryWithShadow()
|
|||
adjust_wsize.x2_ref() + wshadow.x_ref(),
|
||||
adjust_wsize.y2_ref() + wshadow.y_ref()
|
||||
);
|
||||
|
||||
return adjust_wsize_shadow;
|
||||
}
|
||||
|
||||
|
@ -611,6 +612,7 @@ inline const FRect& FWidget::getTermGeometry()
|
|||
adjust_wsize.x2_ref() + offset.x1_ref(),
|
||||
adjust_wsize.y2_ref() + offset.y1_ref()
|
||||
);
|
||||
|
||||
return adjust_wsize_term;
|
||||
}
|
||||
|
||||
|
@ -624,6 +626,7 @@ inline const FRect& FWidget::getTermGeometryWithShadow()
|
|||
adjust_wsize.x2_ref() + offset.x1_ref() + wshadow.x_ref(),
|
||||
adjust_wsize.y2_ref() + offset.y1_ref() + wshadow.y_ref()
|
||||
);
|
||||
|
||||
return adjust_wsize_term_shadow;
|
||||
}
|
||||
|
||||
|
|
|
@ -1437,23 +1437,23 @@ inline void FDialog::moveSizeKey (FKeyEvent* ev)
|
|||
switch ( ev->key() )
|
||||
{
|
||||
case fc::Fkey_up:
|
||||
if ( moveUp(1) )
|
||||
ev->accept();
|
||||
moveUp(1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_down:
|
||||
if ( moveDown(1) )
|
||||
ev->accept();
|
||||
moveDown(1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_left:
|
||||
if ( moveLeft(1) )
|
||||
ev->accept();
|
||||
moveLeft(1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
if ( moveRight(1) )
|
||||
ev->accept();
|
||||
moveRight(1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fmkey_up:
|
||||
|
|
|
@ -727,61 +727,71 @@ inline int FOptiMove::verticalMove (char move[], int from_y, int to_y)
|
|||
}
|
||||
|
||||
if ( to_y > from_y )
|
||||
{
|
||||
int num = to_y - from_y;
|
||||
|
||||
if ( F_parm_down_cursor.cap && F_parm_down_cursor.duration < vtime )
|
||||
{
|
||||
if ( move )
|
||||
std::strncpy ( move
|
||||
, tparm(F_parm_down_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, BUF_SIZE - 1 );
|
||||
|
||||
vtime = F_parm_down_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_down.cap && (num * F_cursor_down.duration < vtime) )
|
||||
{
|
||||
if ( move )
|
||||
move[0] = '\0';
|
||||
|
||||
vtime = repeatedAppend (F_cursor_down, num, move);
|
||||
}
|
||||
}
|
||||
downMove (move, vtime, from_y, to_y);
|
||||
else // to_y < from_y
|
||||
{
|
||||
int num = from_y - to_y;
|
||||
|
||||
if ( F_parm_up_cursor.cap && F_parm_up_cursor.duration < vtime )
|
||||
{
|
||||
if ( move )
|
||||
std::strncpy ( move
|
||||
, tparm(F_parm_up_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, BUF_SIZE - 1 );
|
||||
|
||||
vtime = F_parm_up_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_up.cap && (num * F_cursor_up.duration < vtime) )
|
||||
{
|
||||
if ( move )
|
||||
move[0] = '\0';
|
||||
|
||||
vtime = repeatedAppend (F_cursor_up, num, move);
|
||||
}
|
||||
}
|
||||
upMove (move, vtime, from_y, to_y);
|
||||
|
||||
return vtime;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::downMove ( char move[], int& vtime
|
||||
, int from_y, int to_y )
|
||||
{
|
||||
int num = to_y - from_y;
|
||||
|
||||
if ( F_parm_down_cursor.cap && F_parm_down_cursor.duration < vtime )
|
||||
{
|
||||
if ( move )
|
||||
std::strncpy ( move
|
||||
, tparm(F_parm_down_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, BUF_SIZE - 1 );
|
||||
|
||||
vtime = F_parm_down_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_down.cap && (num * F_cursor_down.duration < vtime) )
|
||||
{
|
||||
if ( move )
|
||||
move[0] = '\0';
|
||||
|
||||
vtime = repeatedAppend (F_cursor_down, num, move);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::upMove ( char move[], int& vtime
|
||||
, int from_y, int to_y )
|
||||
{
|
||||
int num = from_y - to_y;
|
||||
|
||||
if ( F_parm_up_cursor.cap && F_parm_up_cursor.duration < vtime )
|
||||
{
|
||||
if ( move )
|
||||
std::strncpy ( move
|
||||
, tparm(F_parm_up_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, BUF_SIZE - 1 );
|
||||
|
||||
vtime = F_parm_up_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_up.cap && (num * F_cursor_up.duration < vtime) )
|
||||
{
|
||||
if ( move )
|
||||
move[0] = '\0';
|
||||
|
||||
vtime = repeatedAppend (F_cursor_up, num, move);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
|
||||
{
|
||||
char str[BUF_SIZE] = {};
|
||||
int htime = LONG_DURATION;
|
||||
|
||||
if ( F_column_address.cap )
|
||||
{
|
||||
// Move to fixed column position1
|
||||
std::strncat ( hmove
|
||||
, tparm(F_column_address.cap, to_x, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, BUF_SIZE - std::strlen(hmove) - 1 );
|
||||
|
@ -789,107 +799,119 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
|
|||
}
|
||||
|
||||
if ( to_x > from_x )
|
||||
{
|
||||
int num = to_x - from_x;
|
||||
|
||||
if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime )
|
||||
{
|
||||
std::strncat ( hmove
|
||||
, tparm(F_parm_right_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, BUF_SIZE - std::strlen(hmove) - 1 );
|
||||
htime = F_parm_right_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_right.cap )
|
||||
{
|
||||
int htime_r = 0;
|
||||
str[0] = '\0';
|
||||
|
||||
// try to use tab
|
||||
if ( tabstop > 0 && F_tab.cap )
|
||||
{
|
||||
int pos = from_x;
|
||||
|
||||
while ( true )
|
||||
{
|
||||
int tab_pos = pos + tabstop - (pos % tabstop);
|
||||
|
||||
if ( tab_pos > to_x )
|
||||
break;
|
||||
|
||||
htime_r += repeatedAppend (F_tab, 1, str);
|
||||
|
||||
if ( htime_r >= LONG_DURATION )
|
||||
break;
|
||||
|
||||
pos = tab_pos;
|
||||
}
|
||||
|
||||
num = to_x - pos;
|
||||
}
|
||||
|
||||
htime_r += repeatedAppend (F_cursor_right, num, str);
|
||||
|
||||
if ( htime_r < htime )
|
||||
{
|
||||
std::strncpy (hmove, str, BUF_SIZE - 1);
|
||||
htime = htime_r;
|
||||
}
|
||||
}
|
||||
}
|
||||
rightMove (hmove, htime, from_x, to_x);
|
||||
else // to_x < from_x
|
||||
{
|
||||
int num = from_x - to_x;
|
||||
|
||||
if ( F_parm_left_cursor.cap && F_parm_left_cursor.duration < htime )
|
||||
{
|
||||
std::strncat ( hmove
|
||||
, tparm(F_parm_left_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, BUF_SIZE - std::strlen(hmove) - 1 );
|
||||
htime = F_parm_left_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_left.cap )
|
||||
{
|
||||
int htime_l = 0;
|
||||
str[0] = '\0';
|
||||
|
||||
// try to use backward tab
|
||||
if ( tabstop > 0 && F_back_tab.cap )
|
||||
{
|
||||
int pos = from_x;
|
||||
|
||||
while ( true )
|
||||
{
|
||||
int tab_pos = ( pos > 0 ) ? ((pos - 1) / tabstop) * tabstop : -1;
|
||||
|
||||
if ( tab_pos < to_x )
|
||||
break;
|
||||
|
||||
htime_l += repeatedAppend (F_back_tab, 1, str);
|
||||
|
||||
if ( htime_l >= LONG_DURATION )
|
||||
break;
|
||||
|
||||
pos = tab_pos;
|
||||
}
|
||||
|
||||
num = pos - to_x;
|
||||
}
|
||||
|
||||
htime_l += repeatedAppend (F_cursor_left, num, str);
|
||||
|
||||
if ( htime_l < htime )
|
||||
{
|
||||
std::strncpy (hmove, str, BUF_SIZE - 1);
|
||||
htime = htime_l;
|
||||
}
|
||||
}
|
||||
}
|
||||
leftMove (hmove, htime, from_x, to_x);
|
||||
|
||||
return htime;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::rightMove ( char hmove[], int& htime
|
||||
, int from_x, int to_x )
|
||||
{
|
||||
char str[BUF_SIZE] = {};
|
||||
int num = to_x - from_x;
|
||||
|
||||
if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime )
|
||||
{
|
||||
std::strncpy ( hmove
|
||||
, tparm(F_parm_right_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, BUF_SIZE - 1 );
|
||||
htime = F_parm_right_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_right.cap )
|
||||
{
|
||||
int htime_r = 0;
|
||||
str[0] = '\0';
|
||||
|
||||
// try to use tab
|
||||
if ( tabstop > 0 && F_tab.cap )
|
||||
{
|
||||
int pos = from_x;
|
||||
|
||||
while ( true )
|
||||
{
|
||||
int tab_pos = pos + tabstop - (pos % tabstop);
|
||||
|
||||
if ( tab_pos > to_x )
|
||||
break;
|
||||
|
||||
htime_r += repeatedAppend (F_tab, 1, str);
|
||||
|
||||
if ( htime_r >= LONG_DURATION )
|
||||
break;
|
||||
|
||||
pos = tab_pos;
|
||||
}
|
||||
|
||||
num = to_x - pos;
|
||||
}
|
||||
|
||||
htime_r += repeatedAppend (F_cursor_right, num, str);
|
||||
|
||||
if ( htime_r < htime )
|
||||
{
|
||||
std::strncpy (hmove, str, BUF_SIZE - 1);
|
||||
htime = htime_r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::leftMove ( char hmove[], int& htime
|
||||
, int from_x, int to_x )
|
||||
{
|
||||
char str[BUF_SIZE] = {};
|
||||
int num = from_x - to_x;
|
||||
|
||||
if ( F_parm_left_cursor.cap && F_parm_left_cursor.duration < htime )
|
||||
{
|
||||
std::strncpy ( hmove
|
||||
, tparm(F_parm_left_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, BUF_SIZE - 1 );
|
||||
htime = F_parm_left_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_left.cap )
|
||||
{
|
||||
int htime_l = 0;
|
||||
str[0] = '\0';
|
||||
|
||||
// try to use backward tab
|
||||
if ( tabstop > 0 && F_back_tab.cap )
|
||||
{
|
||||
int pos = from_x;
|
||||
|
||||
while ( true )
|
||||
{
|
||||
int tab_pos = ( pos > 0 ) ? ((pos - 1) / tabstop) * tabstop : -1;
|
||||
|
||||
if ( tab_pos < to_x )
|
||||
break;
|
||||
|
||||
htime_l += repeatedAppend (F_back_tab, 1, str);
|
||||
|
||||
if ( htime_l >= LONG_DURATION )
|
||||
break;
|
||||
|
||||
pos = tab_pos;
|
||||
}
|
||||
|
||||
num = pos - to_x;
|
||||
}
|
||||
|
||||
htime_l += repeatedAppend (F_cursor_left, num, str);
|
||||
|
||||
if ( htime_l < htime )
|
||||
{
|
||||
std::strncpy (hmove, str, BUF_SIZE - 1);
|
||||
htime = htime_l;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FOptiMove::isWideMove ( int xold, int yold
|
||||
, int xnew, int ynew )
|
||||
|
|
190
src/fvterm.cpp
190
src/fvterm.cpp
|
@ -48,6 +48,8 @@ FVTerm::termcap_map* FVTerm::tcap = 0;
|
|||
FTermcap::tcap_map* FTermcap::tcap = 0;
|
||||
FVTerm::char_data FVTerm::term_attribute;
|
||||
FVTerm::char_data FVTerm::next_attribute;
|
||||
FVTerm::char_data FVTerm::s_ch;
|
||||
FVTerm::char_data FVTerm::i_ch;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -517,10 +519,6 @@ int FVTerm::print (term_area* area, const std::vector<char_data>& term_string)
|
|||
|
||||
while ( iter != term_string.end() )
|
||||
{
|
||||
int width = area->width,
|
||||
height = area->height,
|
||||
rsh = area->right_shadow,
|
||||
bsh = area->bottom_shadow;
|
||||
bool printable_character = false;
|
||||
|
||||
switch ( (*iter).code )
|
||||
|
@ -556,26 +554,12 @@ int FVTerm::print (term_area* area, const std::vector<char_data>& term_string)
|
|||
}
|
||||
}
|
||||
|
||||
if ( ! printable_character )
|
||||
{
|
||||
// Line break at right margin
|
||||
if ( area->cursor_x > width + rsh )
|
||||
{
|
||||
area->cursor_x = 1;
|
||||
area->cursor_y++;
|
||||
}
|
||||
|
||||
// Prevent up scrolling
|
||||
if ( area->cursor_y > height + bsh )
|
||||
{
|
||||
area->cursor_y--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( ! printable_character && printWrap(area) )
|
||||
break; // end of area reached
|
||||
|
||||
len++;
|
||||
++iter;
|
||||
} // end of while
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
@ -1979,11 +1963,10 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type
|
|||
, FVTerm* obj )
|
||||
{
|
||||
// Gets the overlapped or the covered character for the position (x,y)
|
||||
int xx, yy;
|
||||
char_data* cc; // covered character
|
||||
char_data s_ch; // shadow character
|
||||
char_data i_ch; // inherit background character
|
||||
FWidget* w;
|
||||
int xx, yy, layer;
|
||||
char_data* cc; // covered character
|
||||
FWidget* w;
|
||||
FWidget::widgetList::const_iterator iter, end;
|
||||
|
||||
x--;
|
||||
y--;
|
||||
|
@ -2005,77 +1988,43 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type
|
|||
cc = &vdesktop->text[yy * vdesktop->width + xx];
|
||||
w = static_cast<FWidget*>(obj);
|
||||
|
||||
if ( w->window_list && ! w->window_list->empty() )
|
||||
if ( ! w->window_list || w->window_list->empty() )
|
||||
return *cc;
|
||||
|
||||
// Get the window layer of this object
|
||||
layer = FWindow::getWindowLayer(w);
|
||||
iter = w->window_list->begin();
|
||||
end = w->window_list->end();
|
||||
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
FWidget::widgetList::const_iterator iter, end;
|
||||
// Get the window layer of this object
|
||||
int layer = FWindow::getWindowLayer(w);
|
||||
iter = w->window_list->begin();
|
||||
end = w->window_list->end();
|
||||
bool significant_char;
|
||||
|
||||
for (; iter != end; ++iter)
|
||||
// char_type can be "overlapped_character"
|
||||
// or "covered_character"
|
||||
if ( char_type == covered_character )
|
||||
significant_char = bool(layer >= FWindow::getWindowLayer(*iter));
|
||||
else
|
||||
significant_char = bool(layer < FWindow::getWindowLayer(*iter));
|
||||
|
||||
if ( obj && *iter != obj && significant_char )
|
||||
{
|
||||
bool significant_char;
|
||||
term_area* win = (*iter)->getVWin();
|
||||
|
||||
// char_type can be "overlapped_character"
|
||||
// or "covered_character"
|
||||
if ( char_type == covered_character )
|
||||
significant_char = bool(layer >= FWindow::getWindowLayer(*iter));
|
||||
else
|
||||
significant_char = bool(layer < FWindow::getWindowLayer(*iter));
|
||||
if ( ! win || ! win->visible )
|
||||
continue;
|
||||
|
||||
if ( obj && *iter != obj && significant_char )
|
||||
{
|
||||
term_area* win = (*iter)->getVWin();
|
||||
FRect geometry ( win->offset_left
|
||||
, win->offset_top
|
||||
, win->width + win->right_shadow
|
||||
, win->height + win->bottom_shadow );
|
||||
|
||||
if ( ! win )
|
||||
continue;
|
||||
|
||||
if ( ! win->visible )
|
||||
continue;
|
||||
|
||||
int win_x = win->offset_left;
|
||||
int win_y = win->offset_top;
|
||||
FRect geometry ( win_x
|
||||
, win_y
|
||||
, win->width + win->right_shadow
|
||||
, win->height + win->bottom_shadow );
|
||||
|
||||
// Window visible and contains current character
|
||||
if ( geometry.contains(x, y) )
|
||||
{
|
||||
char_data* tmp;
|
||||
int line_len = win->width + win->right_shadow;
|
||||
tmp = &win->text[(y - win_y) * line_len + (x - win_x)];
|
||||
|
||||
// Current character not transparent
|
||||
if ( ! tmp->attr.bit.transparent )
|
||||
{
|
||||
if ( tmp->attr.bit.trans_shadow ) // transparent shadow
|
||||
{
|
||||
// Keep the current vterm character
|
||||
std::memcpy (&s_ch, cc, sizeof(char_data));
|
||||
s_ch.fg_color = tmp->fg_color;
|
||||
s_ch.bg_color = tmp->bg_color;
|
||||
s_ch.attr.bit.reverse = false;
|
||||
s_ch.attr.bit.standout = false;
|
||||
cc = &s_ch;
|
||||
}
|
||||
else if ( tmp->attr.bit.inherit_bg )
|
||||
{
|
||||
// Add the covered background to this character
|
||||
std::memcpy (&i_ch, tmp, sizeof(char_data));
|
||||
i_ch.bg_color = cc->bg_color; // last background color
|
||||
cc = &i_ch;
|
||||
}
|
||||
else // default
|
||||
cc = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( char_type == covered_character )
|
||||
break;
|
||||
// Window visible and contains current character
|
||||
if ( geometry.contains(x, y) )
|
||||
getAreaCharacter (x, y, win, cc);
|
||||
}
|
||||
else if ( char_type == covered_character )
|
||||
break;
|
||||
}
|
||||
|
||||
return *cc;
|
||||
|
@ -2303,6 +2252,41 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FVTerm::getAreaCharacter ( int x, int y, term_area* area
|
||||
, char_data*& cc )
|
||||
{
|
||||
char_data* tmp;
|
||||
int area_x = area->offset_left;
|
||||
int area_y = area->offset_top;
|
||||
int line_len = area->width + area->right_shadow;
|
||||
tmp = &area->text[(y - area_y) * line_len + (x - area_x)];
|
||||
|
||||
// Current character not transparent
|
||||
if ( ! tmp->attr.bit.transparent )
|
||||
{
|
||||
if ( tmp->attr.bit.trans_shadow ) // transparent shadow
|
||||
{
|
||||
// Keep the current vterm character
|
||||
std::memcpy (&s_ch, cc, sizeof(char_data));
|
||||
s_ch.fg_color = tmp->fg_color;
|
||||
s_ch.bg_color = tmp->bg_color;
|
||||
s_ch.attr.bit.reverse = false;
|
||||
s_ch.attr.bit.standout = false;
|
||||
cc = &s_ch;
|
||||
}
|
||||
else if ( tmp->attr.bit.inherit_bg )
|
||||
{
|
||||
// Add the covered background to this character
|
||||
std::memcpy (&i_ch, tmp, sizeof(char_data));
|
||||
i_ch.bg_color = cc->bg_color; // last background color
|
||||
cc = &i_ch;
|
||||
}
|
||||
else // default
|
||||
cc = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FVTerm::clearTerm (int fillchar)
|
||||
{
|
||||
|
@ -2735,6 +2719,32 @@ void FVTerm::cursorWrap()
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FVTerm::printWrap (term_area* area)
|
||||
{
|
||||
bool end_of_area = false;
|
||||
int width = area->width,
|
||||
height = area->height,
|
||||
rsh = area->right_shadow,
|
||||
bsh = area->bottom_shadow;
|
||||
|
||||
// Line break at right margin
|
||||
if ( area->cursor_x > width + rsh )
|
||||
{
|
||||
area->cursor_x = 1;
|
||||
area->cursor_y++;
|
||||
}
|
||||
|
||||
// Prevent up scrolling
|
||||
if ( area->cursor_y > height + bsh )
|
||||
{
|
||||
area->cursor_y--;
|
||||
end_of_area = true;
|
||||
}
|
||||
|
||||
return end_of_area;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FVTerm::updateTerminalLine (uInt y)
|
||||
{
|
||||
|
|
130
src/fwidget.cpp
130
src/fwidget.cpp
|
@ -1572,65 +1572,9 @@ void FWidget::drawBorder (int x1, int y1, int x2, int y2)
|
|||
y2 = getHeight();
|
||||
|
||||
if ( isNewFont() )
|
||||
{
|
||||
setPrintPos (x1, y1);
|
||||
print (fc::NF_border_corner_middle_upper_left); // ┌
|
||||
|
||||
for (int x = x1 + 1; x < x2; x++)
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
print (fc::NF_border_corner_middle_upper_right); // ┐
|
||||
|
||||
for (int y = y1 + 1; y <= y2; y++)
|
||||
{
|
||||
setPrintPos (x1, y);
|
||||
print (fc::NF_border_line_left); // border left ⎸
|
||||
setPrintPos (x2, y);
|
||||
print (fc::NF_rev_border_line_right); // border right⎹
|
||||
}
|
||||
|
||||
setPrintPos (x1, y2);
|
||||
print (fc::NF_border_corner_middle_lower_left); // └
|
||||
|
||||
for (int x = x1 + 1; x < x2; x++)
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
print (fc::NF_border_corner_middle_lower_right); // ┘
|
||||
}
|
||||
drawNewFontBox (x1, y1, x2, y2);
|
||||
else
|
||||
{
|
||||
setPrintPos (x1, y1);
|
||||
print (fc::BoxDrawingsDownAndRight); // ┌
|
||||
|
||||
for (int x = x1 + 1; x < x2; x++)
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
print (fc::BoxDrawingsDownAndLeft); // ┐
|
||||
|
||||
for (int y = y1 + 1; y < y2; y++)
|
||||
{
|
||||
setPrintPos (x1, y);
|
||||
print (fc::BoxDrawingsVertical); // │
|
||||
setPrintPos (x2, y);
|
||||
print (fc::BoxDrawingsVertical); // │
|
||||
}
|
||||
|
||||
setPrintPos (x1, y2);
|
||||
print (fc::BoxDrawingsUpAndRight); // └
|
||||
|
||||
for (int x = x1 + 1; x < x2; x++)
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
print (fc::BoxDrawingsUpAndLeft); // ┘
|
||||
|
||||
for (int x = x1 + 1; x < x2; x++)
|
||||
{
|
||||
setPrintPos (x, y1);
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
setPrintPos (x, y2);
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
}
|
||||
}
|
||||
drawBox (x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -2492,9 +2436,79 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
|
|||
unsetInheritBackground();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FWidget::drawBox (int x1, int y1, int x2, int y2)
|
||||
{
|
||||
// Use box-drawing characters to draw a border
|
||||
|
||||
setPrintPos (x1, y1);
|
||||
print (fc::BoxDrawingsDownAndRight); // ┌
|
||||
|
||||
for (int x = x1 + 1; x < x2; x++)
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
print (fc::BoxDrawingsDownAndLeft); // ┐
|
||||
|
||||
for (int y = y1 + 1; y < y2; y++)
|
||||
{
|
||||
setPrintPos (x1, y);
|
||||
print (fc::BoxDrawingsVertical); // │
|
||||
setPrintPos (x2, y);
|
||||
print (fc::BoxDrawingsVertical); // │
|
||||
}
|
||||
|
||||
setPrintPos (x1, y2);
|
||||
print (fc::BoxDrawingsUpAndRight); // └
|
||||
|
||||
for (int x = x1 + 1; x < x2; x++)
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
print (fc::BoxDrawingsUpAndLeft); // ┘
|
||||
|
||||
for (int x = x1 + 1; x < x2; x++)
|
||||
{
|
||||
setPrintPos (x, y1);
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
setPrintPos (x, y2);
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FWidget::drawNewFontBox (int x1, int y1, int x2, int y2)
|
||||
{
|
||||
// Use new graphical font characters to draw a border
|
||||
|
||||
setPrintPos (x1, y1);
|
||||
print (fc::NF_border_corner_middle_upper_left); // ┌
|
||||
|
||||
for (int x = x1 + 1; x < x2; x++)
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
print (fc::NF_border_corner_middle_upper_right); // ┐
|
||||
|
||||
for (int y = y1 + 1; y <= y2; y++)
|
||||
{
|
||||
setPrintPos (x1, y);
|
||||
print (fc::NF_border_line_left); // border left ⎸
|
||||
setPrintPos (x2, y);
|
||||
print (fc::NF_rev_border_line_right); // border right⎹
|
||||
}
|
||||
|
||||
setPrintPos (x1, y2);
|
||||
print (fc::NF_border_corner_middle_lower_left); // └
|
||||
|
||||
for (int x = x1 + 1; x < x2; x++)
|
||||
print (fc::BoxDrawingsHorizontal); // ─
|
||||
|
||||
print (fc::NF_border_corner_middle_lower_right); // ┘
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::setColorTheme()
|
||||
{
|
||||
// Sets the default color theme
|
||||
|
||||
if ( getMaxColor() < 16 ) // for 8 color mode
|
||||
{
|
||||
wc.set8ColorTheme();
|
||||
|
|
Loading…
Reference in New Issue