Refactoring FVTerm::restoreVTerm
This commit is contained in:
parent
f53efc90c5
commit
3419e9e908
|
@ -1,4 +1,8 @@
|
||||||
2017-01-02 Markus Gans <guru.mail@muenster.de>
|
2017-01-05 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Refactoring FVTerm::restoreVTerm
|
||||||
|
* Fixed buffer size in FOptiMove
|
||||||
|
|
||||||
|
2017-01-03 Markus Gans <guru.mail@muenster.de>
|
||||||
* Refactoring FOptiMove::relativeMove
|
* Refactoring FOptiMove::relativeMove
|
||||||
* Refactoring attribute settings in FOptiAttr
|
* Refactoring attribute settings in FOptiAttr
|
||||||
* Refactoring FTerm::parseKeyString and timeout settings
|
* Refactoring FTerm::parseKeyString and timeout settings
|
||||||
|
|
|
@ -14,5 +14,5 @@ doc/terminfo-manual.sh
|
||||||
doc/textview.png
|
doc/textview.png
|
||||||
doc/TODO
|
doc/TODO
|
||||||
doc/vt100_line_drawing_graphics.png
|
doc/vt100_line_drawing_graphics.png
|
||||||
doc/VTerm.txt
|
doc/virtual-terminal.txt
|
||||||
doc/xgraphics
|
doc/xgraphics
|
||||||
|
|
|
@ -21,7 +21,7 @@ EXTRA_DIST = \
|
||||||
textview.png \
|
textview.png \
|
||||||
TODO \
|
TODO \
|
||||||
vt100_line_drawing_graphics.png \
|
vt100_line_drawing_graphics.png \
|
||||||
VTerm.txt \
|
virtual-terminal.txt \
|
||||||
xgraphics
|
xgraphics
|
||||||
|
|
||||||
doc_DATA = \
|
doc_DATA = \
|
||||||
|
@ -41,5 +41,5 @@ doc_DATA = \
|
||||||
textview.png \
|
textview.png \
|
||||||
TODO \
|
TODO \
|
||||||
vt100_line_drawing_graphics.png \
|
vt100_line_drawing_graphics.png \
|
||||||
VTerm.txt \
|
virtual-terminal.txt \
|
||||||
xgraphics
|
xgraphics
|
||||||
|
|
|
@ -285,7 +285,7 @@ EXTRA_DIST = \
|
||||||
textview.png \
|
textview.png \
|
||||||
TODO \
|
TODO \
|
||||||
vt100_line_drawing_graphics.png \
|
vt100_line_drawing_graphics.png \
|
||||||
VTerm.txt \
|
virtual-terminal.txt \
|
||||||
xgraphics
|
xgraphics
|
||||||
|
|
||||||
doc_DATA = \
|
doc_DATA = \
|
||||||
|
@ -305,7 +305,7 @@ doc_DATA = \
|
||||||
textview.png \
|
textview.png \
|
||||||
TODO \
|
TODO \
|
||||||
vt100_line_drawing_graphics.png \
|
vt100_line_drawing_graphics.png \
|
||||||
VTerm.txt \
|
virtual-terminal.txt \
|
||||||
xgraphics
|
xgraphics
|
||||||
|
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
The virtual terminal (vterm)
|
||||||
|
----------------------------
|
||||||
|
|
||||||
print(...)
|
print(...)
|
||||||
printf(...)
|
printf(...)
|
|
@ -516,7 +516,7 @@ void FListBox::insert (Container container, LazyConverter convert)
|
||||||
conv_type = lazy_convert;
|
conv_type = lazy_convert;
|
||||||
source_container = container;
|
source_container = container;
|
||||||
convertToItem = convert;
|
convertToItem = convert;
|
||||||
size_t size = container->size();
|
std::size_t size = container->size();
|
||||||
|
|
||||||
if ( size > 0 )
|
if ( size > 0 )
|
||||||
itemlist.resize(size);
|
itemlist.resize(size);
|
||||||
|
|
|
@ -112,6 +112,9 @@ class FOptiMove
|
||||||
void printDurations();
|
void printDurations();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Constant
|
||||||
|
static const std::size_t BUF_SIZE = 512;
|
||||||
|
|
||||||
// Typedefs
|
// Typedefs
|
||||||
typedef unsigned char uChar;
|
typedef unsigned char uChar;
|
||||||
typedef unsigned int uInt;
|
typedef unsigned int uInt;
|
||||||
|
@ -147,36 +150,36 @@ class FOptiMove
|
||||||
void moveByMethod (int, int, int, int, int);
|
void moveByMethod (int, int, int, int, int);
|
||||||
|
|
||||||
// Data Members
|
// Data Members
|
||||||
capability F_cursor_home;
|
capability F_cursor_home;
|
||||||
capability F_carriage_return;
|
capability F_carriage_return;
|
||||||
capability F_cursor_to_ll;
|
capability F_cursor_to_ll;
|
||||||
capability F_tab;
|
capability F_tab;
|
||||||
capability F_back_tab;
|
capability F_back_tab;
|
||||||
capability F_cursor_up;
|
capability F_cursor_up;
|
||||||
capability F_cursor_down;
|
capability F_cursor_down;
|
||||||
capability F_cursor_left;
|
capability F_cursor_left;
|
||||||
capability F_cursor_right;
|
capability F_cursor_right;
|
||||||
capability F_cursor_address;
|
capability F_cursor_address;
|
||||||
capability F_column_address;
|
capability F_column_address;
|
||||||
capability F_row_address;
|
capability F_row_address;
|
||||||
capability F_parm_up_cursor;
|
capability F_parm_up_cursor;
|
||||||
capability F_parm_down_cursor;
|
capability F_parm_down_cursor;
|
||||||
capability F_parm_left_cursor;
|
capability F_parm_left_cursor;
|
||||||
capability F_parm_right_cursor;
|
capability F_parm_right_cursor;
|
||||||
capability F_erase_chars;
|
capability F_erase_chars;
|
||||||
capability F_repeat_char;
|
capability F_repeat_char;
|
||||||
capability F_clr_bol;
|
capability F_clr_bol;
|
||||||
capability F_clr_eol;
|
capability F_clr_eol;
|
||||||
|
|
||||||
bool automatic_left_margin;
|
bool automatic_left_margin;
|
||||||
bool eat_nl_glitch;
|
bool eat_nl_glitch;
|
||||||
|
|
||||||
char move_buf[512];
|
char move_buf[BUF_SIZE];
|
||||||
int char_duration;
|
int char_duration;
|
||||||
int baudrate;
|
int baudrate;
|
||||||
int tabstop;
|
int tabstop;
|
||||||
int screen_width;
|
int screen_width;
|
||||||
int screen_height;
|
int screen_height;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|
|
@ -329,6 +329,9 @@ class FVTerm : public FTerm
|
||||||
static void scrollAreaReverse (term_area*);
|
static void scrollAreaReverse (term_area*);
|
||||||
static void clearArea (term_area*, int = ' ');
|
static void clearArea (term_area*, int = ' ');
|
||||||
|
|
||||||
|
static char_data generateCharacter (const FPoint&);
|
||||||
|
static char_data generateCharacter (int, int);
|
||||||
|
|
||||||
static char_data getCharacter ( character_type
|
static char_data getCharacter ( character_type
|
||||||
, const FPoint&
|
, const FPoint&
|
||||||
, FVTerm* );
|
, FVTerm* );
|
||||||
|
|
|
@ -651,7 +651,7 @@ int FOptiMove::repeatedAppend ( const capability& o
|
||||||
dst_len = ( dst != 0 ) ? std::strlen(dst) : 0;
|
dst_len = ( dst != 0 ) ? std::strlen(dst) : 0;
|
||||||
total = 0;
|
total = 0;
|
||||||
|
|
||||||
if ( (dst_len + uInt(count) * src_len) < sizeof(move_buf) - 1 )
|
if ( (dst_len + uInt(count) * src_len) < BUF_SIZE - 1 )
|
||||||
{
|
{
|
||||||
total += count * o.duration;
|
total += count * o.duration;
|
||||||
|
|
||||||
|
@ -693,7 +693,7 @@ int FOptiMove::relativeMove ( char move[]
|
||||||
|
|
||||||
if ( to_x != from_x ) // horizontal move
|
if ( to_x != from_x ) // horizontal move
|
||||||
{
|
{
|
||||||
char hmove[sizeof(move_buf)] = {};
|
char hmove[BUF_SIZE] = {};
|
||||||
htime = horizontalMove (hmove, from_x, to_x);
|
htime = horizontalMove (hmove, from_x, to_x);
|
||||||
|
|
||||||
if ( htime >= LONG_DURATION )
|
if ( htime >= LONG_DURATION )
|
||||||
|
@ -702,9 +702,9 @@ int FOptiMove::relativeMove ( char move[]
|
||||||
if ( move )
|
if ( move )
|
||||||
{
|
{
|
||||||
if ( *move )
|
if ( *move )
|
||||||
std::strncat (move, hmove, sizeof(move_buf) - std::strlen(move) - 1);
|
std::strncat (move, hmove, BUF_SIZE - std::strlen(move) - 1);
|
||||||
else
|
else
|
||||||
std::strncpy (move, hmove, sizeof(move_buf) - 1);
|
std::strncpy (move, hmove, BUF_SIZE - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -721,7 +721,7 @@ inline int FOptiMove::verticalMove (char move[], int from_y, int to_y)
|
||||||
if ( move )
|
if ( move )
|
||||||
std::strncpy ( move
|
std::strncpy ( move
|
||||||
, tparm(F_row_address.cap, to_y, 0, 0, 0, 0, 0, 0, 0, 0)
|
, tparm(F_row_address.cap, to_y, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
, sizeof(move_buf) - 1 );
|
, BUF_SIZE - 1 );
|
||||||
|
|
||||||
vtime = F_row_address.duration;
|
vtime = F_row_address.duration;
|
||||||
}
|
}
|
||||||
|
@ -735,7 +735,7 @@ inline int FOptiMove::verticalMove (char move[], int from_y, int to_y)
|
||||||
if ( move )
|
if ( move )
|
||||||
std::strncpy ( move
|
std::strncpy ( move
|
||||||
, tparm(F_parm_down_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
, tparm(F_parm_down_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
, sizeof(move_buf) - 1 );
|
, BUF_SIZE - 1 );
|
||||||
|
|
||||||
vtime = F_parm_down_cursor.duration;
|
vtime = F_parm_down_cursor.duration;
|
||||||
}
|
}
|
||||||
|
@ -757,7 +757,7 @@ inline int FOptiMove::verticalMove (char move[], int from_y, int to_y)
|
||||||
if ( move )
|
if ( move )
|
||||||
std::strncpy ( move
|
std::strncpy ( move
|
||||||
, tparm(F_parm_up_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
, tparm(F_parm_up_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
, sizeof(move_buf) - 1 );
|
, BUF_SIZE - 1 );
|
||||||
|
|
||||||
vtime = F_parm_up_cursor.duration;
|
vtime = F_parm_up_cursor.duration;
|
||||||
}
|
}
|
||||||
|
@ -777,14 +777,14 @@ inline int FOptiMove::verticalMove (char move[], int from_y, int to_y)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
|
inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
|
||||||
{
|
{
|
||||||
char str[sizeof(move_buf)] = {};
|
char str[BUF_SIZE] = {};
|
||||||
int htime = LONG_DURATION;
|
int htime = LONG_DURATION;
|
||||||
|
|
||||||
if ( F_column_address.cap )
|
if ( F_column_address.cap )
|
||||||
{
|
{
|
||||||
std::strncat ( hmove
|
std::strncat ( hmove
|
||||||
, tparm(F_column_address.cap, to_x, 0, 0, 0, 0, 0, 0, 0, 0)
|
, tparm(F_column_address.cap, to_x, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
, sizeof(hmove) - std::strlen(hmove) - 1 );
|
, BUF_SIZE - std::strlen(hmove) - 1 );
|
||||||
htime = F_column_address.duration;
|
htime = F_column_address.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,7 +796,7 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
|
||||||
{
|
{
|
||||||
std::strncat ( hmove
|
std::strncat ( hmove
|
||||||
, tparm(F_parm_right_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
, tparm(F_parm_right_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
, sizeof(hmove) - std::strlen(hmove) - 1 );
|
, BUF_SIZE - std::strlen(hmove) - 1 );
|
||||||
htime = F_parm_right_cursor.duration;
|
htime = F_parm_right_cursor.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -832,7 +832,7 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
|
||||||
|
|
||||||
if ( htime_r < htime )
|
if ( htime_r < htime )
|
||||||
{
|
{
|
||||||
std::strncpy (hmove, str, sizeof(move_buf) - 1);
|
std::strncpy (hmove, str, BUF_SIZE - 1);
|
||||||
htime = htime_r;
|
htime = htime_r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -845,7 +845,7 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
|
||||||
{
|
{
|
||||||
std::strncat ( hmove
|
std::strncat ( hmove
|
||||||
, tparm(F_parm_left_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
, tparm(F_parm_left_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
, sizeof(hmove) - std::strlen(hmove) - 1 );
|
, BUF_SIZE - std::strlen(hmove) - 1 );
|
||||||
htime = F_parm_left_cursor.duration;
|
htime = F_parm_left_cursor.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -881,7 +881,7 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
|
||||||
|
|
||||||
if ( htime_l < htime )
|
if ( htime_l < htime )
|
||||||
{
|
{
|
||||||
std::strncpy (hmove, str, sizeof(move_buf) - 1);
|
std::strncpy (hmove, str, BUF_SIZE - 1);
|
||||||
htime = htime_l;
|
htime = htime_l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -910,7 +910,7 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time
|
||||||
if ( move_xy )
|
if ( move_xy )
|
||||||
{
|
{
|
||||||
char* move_ptr = move_buf;
|
char* move_ptr = move_buf;
|
||||||
std::strncpy (move_ptr, move_xy, sizeof(move_buf) - 1);
|
std::strncpy (move_ptr, move_xy, BUF_SIZE - 1);
|
||||||
move_time = F_cursor_address.duration;
|
move_time = F_cursor_address.duration;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -927,7 +927,7 @@ inline bool FOptiMove::isMethod1Faster ( int& move_time
|
||||||
|
|
||||||
if ( xold >= 0 && yold >= 0 )
|
if ( xold >= 0 && yold >= 0 )
|
||||||
{
|
{
|
||||||
char null_result[sizeof(move_buf)];
|
char null_result[BUF_SIZE];
|
||||||
char* null_ptr = null_result;
|
char* null_ptr = null_result;
|
||||||
int new_time = relativeMove (null_ptr, xold, yold, xnew, ynew);
|
int new_time = relativeMove (null_ptr, xold, yold, xnew, ynew);
|
||||||
|
|
||||||
|
@ -950,7 +950,7 @@ inline bool FOptiMove::isMethod2Faster ( int& move_time
|
||||||
|
|
||||||
if ( yold >= 0 && F_carriage_return.cap )
|
if ( yold >= 0 && F_carriage_return.cap )
|
||||||
{
|
{
|
||||||
char null_result[sizeof(move_buf)];
|
char null_result[BUF_SIZE];
|
||||||
char* null_ptr = null_result;
|
char* null_ptr = null_result;
|
||||||
int new_time = relativeMove (null_ptr, 0, yold, xnew, ynew);
|
int new_time = relativeMove (null_ptr, 0, yold, xnew, ynew);
|
||||||
|
|
||||||
|
@ -973,7 +973,7 @@ inline bool FOptiMove::isMethod3Faster ( int& move_time
|
||||||
|
|
||||||
if ( F_cursor_home.cap )
|
if ( F_cursor_home.cap )
|
||||||
{
|
{
|
||||||
char null_result[sizeof(move_buf)];
|
char null_result[BUF_SIZE];
|
||||||
char* null_ptr = null_result;
|
char* null_ptr = null_result;
|
||||||
int new_time = relativeMove (null_ptr, 0, 0, xnew, ynew);
|
int new_time = relativeMove (null_ptr, 0, 0, xnew, ynew);
|
||||||
|
|
||||||
|
@ -995,7 +995,7 @@ inline bool FOptiMove::isMethod4Faster ( int& move_time
|
||||||
// Test method 4: home-down + local movement
|
// Test method 4: home-down + local movement
|
||||||
if ( F_cursor_to_ll.cap )
|
if ( F_cursor_to_ll.cap )
|
||||||
{
|
{
|
||||||
char null_result[sizeof(move_buf)];
|
char null_result[BUF_SIZE];
|
||||||
char* null_ptr = null_result;
|
char* null_ptr = null_result;
|
||||||
int new_time = relativeMove ( null_ptr
|
int new_time = relativeMove ( null_ptr
|
||||||
, 0, screen_height - 1
|
, 0, screen_height - 1
|
||||||
|
@ -1023,7 +1023,7 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
|
||||||
&& yold > 0
|
&& yold > 0
|
||||||
&& F_cursor_left.cap )
|
&& F_cursor_left.cap )
|
||||||
{
|
{
|
||||||
char null_result[sizeof(move_buf)];
|
char null_result[BUF_SIZE];
|
||||||
char* null_ptr = null_result;
|
char* null_ptr = null_result;
|
||||||
int new_time = relativeMove ( null_ptr
|
int new_time = relativeMove ( null_ptr
|
||||||
, screen_width - 1, yold - 1
|
, screen_width - 1, yold - 1
|
||||||
|
@ -1059,20 +1059,20 @@ void FOptiMove::moveByMethod ( int method
|
||||||
case 2:
|
case 2:
|
||||||
if ( F_carriage_return.cap )
|
if ( F_carriage_return.cap )
|
||||||
{
|
{
|
||||||
std::strncpy (move_ptr, F_carriage_return.cap, sizeof(move_buf) - 1);
|
std::strncpy (move_ptr, F_carriage_return.cap, BUF_SIZE - 1);
|
||||||
move_ptr += F_carriage_return.length;
|
move_ptr += F_carriage_return.length;
|
||||||
relativeMove (move_ptr, 0, yold, xnew, ynew);
|
relativeMove (move_ptr, 0, yold, xnew, ynew);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
std::strncpy (move_ptr, F_cursor_home.cap, sizeof(move_buf) - 1);
|
std::strncpy (move_ptr, F_cursor_home.cap, BUF_SIZE - 1);
|
||||||
move_ptr += F_cursor_home.length;
|
move_ptr += F_cursor_home.length;
|
||||||
relativeMove (move_ptr, 0, 0, xnew, ynew);
|
relativeMove (move_ptr, 0, 0, xnew, ynew);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
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, BUF_SIZE - 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;
|
||||||
|
@ -1083,11 +1083,11 @@ void FOptiMove::moveByMethod ( int method
|
||||||
if ( xold >= 0 )
|
if ( xold >= 0 )
|
||||||
std::strncat ( move_ptr
|
std::strncat ( move_ptr
|
||||||
, F_carriage_return.cap
|
, F_carriage_return.cap
|
||||||
, sizeof(move_buf) - std::strlen(move_ptr) - 1 );
|
, BUF_SIZE - std::strlen(move_ptr) - 1 );
|
||||||
|
|
||||||
std::strncat ( move_ptr
|
std::strncat ( move_ptr
|
||||||
, F_cursor_left.cap
|
, F_cursor_left.cap
|
||||||
, sizeof(move_buf) - std::strlen(move_ptr) - 1 );
|
, BUF_SIZE - 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;
|
||||||
|
|
|
@ -3186,22 +3186,22 @@ inline char* FTerm::secDA_Analysis_24 (char current_termtype[])
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline char* FTerm::secDA_Analysis_32 (char current_termtype[])
|
inline char* FTerm::secDA_Analysis_32 (char[])
|
||||||
{
|
{
|
||||||
// Terminal ID 32 - Tera Term
|
// Terminal ID 32 - Tera Term
|
||||||
|
|
||||||
char* new_termtype = current_termtype;
|
char* new_termtype;
|
||||||
tera_terminal = true;
|
tera_terminal = true;
|
||||||
new_termtype = C_STR("teraterm");
|
new_termtype = C_STR("teraterm");
|
||||||
return new_termtype;
|
return new_termtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline char* FTerm::secDA_Analysis_77 (char current_termtype[])
|
inline char* FTerm::secDA_Analysis_77 (char[])
|
||||||
{
|
{
|
||||||
// Terminal ID 77 - mintty
|
// Terminal ID 77 - mintty
|
||||||
|
|
||||||
char* new_termtype = current_termtype;
|
char* new_termtype;
|
||||||
mintty_terminal = true;
|
mintty_terminal = true;
|
||||||
new_termtype = C_STR("xterm-256color");
|
new_termtype = C_STR("xterm-256color");
|
||||||
// switch to application escape key mode
|
// switch to application escape key mode
|
||||||
|
@ -4804,15 +4804,15 @@ inline int FTerm::getTermcapKey (char buffer[], int buf_size)
|
||||||
// Looking for termcap key strings in the buffer
|
// Looking for termcap key strings in the buffer
|
||||||
assert ( buf_size > 0 );
|
assert ( buf_size > 0 );
|
||||||
|
|
||||||
register int len, n;
|
|
||||||
|
|
||||||
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
|
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
|
||||||
{
|
{
|
||||||
char* k = fc::Fkey[i].string;
|
char* k = fc::Fkey[i].string;
|
||||||
len = ( k ) ? int(std::strlen(k)) : 0;
|
register int len = ( k ) ? int(std::strlen(k)) : 0;
|
||||||
|
|
||||||
if ( k && std::strncmp(k, buffer, uInt(len)) == 0 ) // found
|
if ( k && std::strncmp(k, buffer, uInt(len)) == 0 ) // found
|
||||||
{
|
{
|
||||||
|
register int n;
|
||||||
|
|
||||||
for (n = len; n < buf_size; n++) // Remove founded entry
|
for (n = len; n < buf_size; n++) // Remove founded entry
|
||||||
buffer[n - len] = buffer[n];
|
buffer[n - len] = buffer[n];
|
||||||
|
|
||||||
|
|
204
src/fvterm.cpp
204
src/fvterm.cpp
|
@ -942,11 +942,8 @@ void FVTerm::restoreVTerm (const FRect& box)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FVTerm::restoreVTerm (int x, int y, int w, int h)
|
void FVTerm::restoreVTerm (int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
char_data* tc; // terminal character
|
char_data* tc; // terminal character
|
||||||
char_data* sc; // shown character
|
char_data sc; // shown character
|
||||||
char_data s_ch; // shadow character
|
|
||||||
char_data i_ch; // inherit background character
|
|
||||||
FWidget* widget;
|
|
||||||
|
|
||||||
x--;
|
x--;
|
||||||
y--;
|
y--;
|
||||||
|
@ -972,88 +969,23 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
|
||||||
if ( h < 0 )
|
if ( h < 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
widget = static_cast<FWidget*>(vterm->widget);
|
for (int ty = 0; ty < h; ty++)
|
||||||
|
|
||||||
for (register int ty = 0; ty < h; ty++)
|
|
||||||
{
|
{
|
||||||
for (register int tx = 0; tx < w; tx++)
|
int ypos = y + ty;
|
||||||
|
|
||||||
|
for (int tx = 0; tx < w; tx++)
|
||||||
{
|
{
|
||||||
tc = &vterm->text[(y + ty) * vterm->width + (x + tx)];
|
int xpos = x + tx;
|
||||||
sc = &vdesktop->text[(y + ty) * vdesktop->width + (x + tx)];
|
tc = &vterm->text[ypos * vterm->width + xpos];
|
||||||
|
sc = generateCharacter(xpos, ypos);
|
||||||
if ( widget->window_list && ! widget->window_list->empty() )
|
std::memcpy (tc, &sc, sizeof(char_data));
|
||||||
{
|
|
||||||
FWidget::widgetList::const_iterator iter, end;
|
|
||||||
iter = widget->window_list->begin();
|
|
||||||
end = widget->window_list->end();
|
|
||||||
|
|
||||||
for (; iter != end; ++iter)
|
|
||||||
{
|
|
||||||
term_area* win = (*iter)->getVWin();
|
|
||||||
|
|
||||||
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(tx + x, ty + y) )
|
|
||||||
{
|
|
||||||
char_data* tmp;
|
|
||||||
int line_len = win->width + win->right_shadow;
|
|
||||||
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.trans_shadow ) // transparent shadow
|
|
||||||
{
|
|
||||||
// keep the current vterm character
|
|
||||||
std::memcpy (&s_ch, sc, 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;
|
|
||||||
|
|
||||||
if ( s_ch.code == fc::LowerHalfBlock
|
|
||||||
|| s_ch.code == fc::UpperHalfBlock
|
|
||||||
|| s_ch.code == fc::LeftHalfBlock
|
|
||||||
|| s_ch.code == fc::RightHalfBlock
|
|
||||||
|| s_ch.code == fc::MediumShade
|
|
||||||
|| s_ch.code == fc::FullBlock )
|
|
||||||
s_ch.code = ' ';
|
|
||||||
|
|
||||||
sc = &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 = sc->bg_color; // last background color;
|
|
||||||
sc = &i_ch;
|
|
||||||
}
|
|
||||||
else // default
|
|
||||||
sc = tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::memcpy (tc, sc, sizeof(char_data));
|
|
||||||
|
|
||||||
if ( short(vterm->changes[y + ty].xmin) > x )
|
|
||||||
vterm->changes[y + ty].xmin = uInt(x);
|
|
||||||
|
|
||||||
if ( short(vterm->changes[y + ty].xmax) < x + w - 1 )
|
|
||||||
vterm->changes[y + ty].xmax = uInt(x + w - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( short(vterm->changes[ypos].xmin) > x )
|
||||||
|
vterm->changes[ypos].xmin = uInt(x);
|
||||||
|
|
||||||
|
if ( short(vterm->changes[ypos].xmax) < x + w - 1 )
|
||||||
|
vterm->changes[ypos].xmax = uInt(x + w - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1673,11 +1605,11 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
|
||||||
ax--;
|
ax--;
|
||||||
ay--;
|
ay--;
|
||||||
|
|
||||||
int aw = area->width
|
int aw = area->width
|
||||||
, ah = area->height
|
, ah = area->height
|
||||||
, rsh = area->right_shadow
|
, rsh = area->right_shadow
|
||||||
, bsh = area->bottom_shadow
|
, bsh = area->bottom_shadow
|
||||||
, ol = 0 // outside left
|
, ol = 0 // outside left
|
||||||
, y_end
|
, y_end
|
||||||
, length;
|
, length;
|
||||||
|
|
||||||
|
@ -1986,6 +1918,90 @@ void FVTerm::clearArea (term_area* area, int fillchar)
|
||||||
area->has_changes = true;
|
area->has_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
FVTerm::char_data FVTerm::generateCharacter (const FPoint& pos)
|
||||||
|
{
|
||||||
|
// Generates characters for a given position considering all areas
|
||||||
|
return generateCharacter (pos.getX(), pos.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
FVTerm::char_data FVTerm::generateCharacter (int x, int y)
|
||||||
|
{
|
||||||
|
// Generates characters for a given position considering all areas
|
||||||
|
FWidget::widgetList::const_iterator iter, end;
|
||||||
|
char_data* sc; // shown character
|
||||||
|
char_data s_ch; // shadow character
|
||||||
|
char_data i_ch; // inherit background character
|
||||||
|
FWidget* widget;
|
||||||
|
|
||||||
|
widget = static_cast<FWidget*>(vterm->widget);
|
||||||
|
sc = &vdesktop->text[y * vdesktop->width + x];
|
||||||
|
|
||||||
|
if ( ! widget->window_list || widget->window_list->empty() )
|
||||||
|
return *sc;
|
||||||
|
|
||||||
|
iter = widget->window_list->begin();
|
||||||
|
end = widget->window_list->end();
|
||||||
|
|
||||||
|
for (; iter != end; ++iter)
|
||||||
|
{
|
||||||
|
term_area* win = (*iter)->getVWin();
|
||||||
|
|
||||||
|
if ( ! win || ! 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 is 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)];
|
||||||
|
|
||||||
|
if ( ! tmp->attr.bit.transparent ) // Current character not transparent
|
||||||
|
{
|
||||||
|
if ( tmp->attr.bit.trans_shadow ) // Transparent shadow
|
||||||
|
{
|
||||||
|
// Keep the current vterm character
|
||||||
|
std::memcpy (&s_ch, sc, 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;
|
||||||
|
|
||||||
|
if ( s_ch.code == fc::LowerHalfBlock
|
||||||
|
|| s_ch.code == fc::UpperHalfBlock
|
||||||
|
|| s_ch.code == fc::LeftHalfBlock
|
||||||
|
|| s_ch.code == fc::RightHalfBlock
|
||||||
|
|| s_ch.code == fc::MediumShade
|
||||||
|
|| s_ch.code == fc::FullBlock )
|
||||||
|
s_ch.code = ' ';
|
||||||
|
|
||||||
|
sc = &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 = sc->bg_color; // Last background color
|
||||||
|
sc = &i_ch;
|
||||||
|
}
|
||||||
|
else // Default
|
||||||
|
sc = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *sc;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FVTerm::char_data FVTerm::getCharacter ( character_type type
|
FVTerm::char_data FVTerm::getCharacter ( character_type type
|
||||||
, const FPoint& pos
|
, const FPoint& pos
|
||||||
|
@ -2031,7 +2047,7 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type
|
||||||
if ( w->window_list && ! w->window_list->empty() )
|
if ( w->window_list && ! w->window_list->empty() )
|
||||||
{
|
{
|
||||||
FWidget::widgetList::const_iterator iter, end;
|
FWidget::widgetList::const_iterator iter, end;
|
||||||
// get the window layer of this object
|
// Get the window layer of this object
|
||||||
int layer = FWindow::getWindowLayer(w);
|
int layer = FWindow::getWindowLayer(w);
|
||||||
iter = w->window_list->begin();
|
iter = w->window_list->begin();
|
||||||
end = w->window_list->end();
|
end = w->window_list->end();
|
||||||
|
@ -2064,19 +2080,19 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type
|
||||||
, win->width + win->right_shadow
|
, win->width + win->right_shadow
|
||||||
, 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(x, y) )
|
if ( geometry.contains(x, 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)];
|
||||||
|
|
||||||
// current character not transparent
|
// Current character not transparent
|
||||||
if ( ! tmp->attr.bit.transparent )
|
if ( ! tmp->attr.bit.transparent )
|
||||||
{
|
{
|
||||||
if ( tmp->attr.bit.trans_shadow ) // transparent shadow
|
if ( tmp->attr.bit.trans_shadow ) // transparent shadow
|
||||||
{
|
{
|
||||||
// keep the current vterm character
|
// Keep the current vterm character
|
||||||
std::memcpy (&s_ch, cc, sizeof(char_data));
|
std::memcpy (&s_ch, cc, sizeof(char_data));
|
||||||
s_ch.fg_color = tmp->fg_color;
|
s_ch.fg_color = tmp->fg_color;
|
||||||
s_ch.bg_color = tmp->bg_color;
|
s_ch.bg_color = tmp->bg_color;
|
||||||
|
@ -2086,7 +2102,7 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type
|
||||||
}
|
}
|
||||||
else if ( tmp->attr.bit.inherit_bg )
|
else if ( tmp->attr.bit.inherit_bg )
|
||||||
{
|
{
|
||||||
// add the covered background to this character
|
// Add the covered background to this character
|
||||||
std::memcpy (&i_ch, tmp, sizeof(char_data));
|
std::memcpy (&i_ch, tmp, sizeof(char_data));
|
||||||
i_ch.bg_color = cc->bg_color; // last background color
|
i_ch.bg_color = cc->bg_color; // last background color
|
||||||
cc = &i_ch;
|
cc = &i_ch;
|
||||||
|
|
Loading…
Reference in New Issue