Refactoring FApplication::linuxModifierKeyCorrection and FVTerm::updateVTerm

This commit is contained in:
Markus Gans 2017-12-02 18:52:51 +01:00
parent abf89f1538
commit 1f8894b801
12 changed files with 482 additions and 332 deletions

View File

@ -1,3 +1,8 @@
2017-12-02 Markus Gans <guru.mail@muenster.de>
* Refactoring FApplication::linuxModifierKeyCorrection and
FVTerm::updateVTerm
* Fix getLinuxModifierKey() subcode value as non-const
2017-11-30 Markus Gans <guru.mail@muenster.de> 2017-11-30 Markus Gans <guru.mail@muenster.de>
* Refactoring FVTerm::updateTerminalLine * Refactoring FVTerm::updateTerminalLine

View File

@ -160,7 +160,14 @@ class FApplication : public FWidget
ssize_t readKey(); ssize_t readKey();
void processKeyboardEvent(); void processKeyboardEvent();
#if defined(__linux__) #if defined(__linux__)
int linuxModifierKeyCorrection (const int&); static int linuxShiftKeyCorrection (const int&);
static int linuxCtrlKeyCorrection (const int&);
static int linuxAltKeyCorrection (const int&);
static int linuxShiftCtrlKeyCorrection (const int&);
static int linuxShiftAltKeyCorrection (const int&);
static int linuxCtrlAltKeyCorrection (const int&);
static int linuxShiftCtrlAltKeyCorrection (const int&);
static int linuxModifierKeyCorrection (const int&);
#endif #endif
bool processDialogSwitchAccelerator(); bool processDialogSwitchAccelerator();
bool processAccelerator (const FWidget*&); bool processAccelerator (const FWidget*&);

View File

@ -123,6 +123,7 @@ class FTerm
// Typedefs // Typedefs
typedef FOptiAttr::char_data char_data; typedef FOptiAttr::char_data char_data;
#if defined(__linux__)
static struct modifier_key // bit field static struct modifier_key // bit field
{ {
uChar shift : 1; // 0..1 uChar shift : 1; // 0..1
@ -131,6 +132,7 @@ class FTerm
uChar alt : 1; // 0..1 uChar alt : 1; // 0..1
uChar : 4; // padding bits uChar : 4; // padding bits
} mod_key; } mod_key;
#endif
// Constructor // Constructor
explicit FTerm (bool = false); explicit FTerm (bool = false);

View File

@ -296,6 +296,16 @@ class FVTerm : public FTerm
static covered_state isCovered ( int, int static covered_state isCovered ( int, int
, term_area* ); , term_area* );
static void updateOverlappedColor ( term_area*
, int, int, int, int );
static void updateOverlappedCharacter (term_area*, int, int);
static void updateShadedCharacter ( term_area*
, int, int, int, int );
static void updateInheritBackground ( term_area*
, int, int, int, int );
static void updateCharacter ( term_area*
, int, int, int, int );
static void callPreprocessingHandler (term_area*);
static void updateVTerm(); static void updateVTerm();
static void updateVTerm (term_area*); static void updateVTerm (term_area*);
static bool updateVTermCursor (term_area*); static bool updateVTermCursor (term_area*);

View File

@ -781,10 +781,291 @@ void FApplication::processKeyboardEvent()
} }
#if defined(__linux__) #if defined(__linux__)
//----------------------------------------------------------------------
int FApplication::linuxShiftKeyCorrection (const int& key_id)
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fkey_sr; // Shift+Up
case fc::Fkey_down:
return fc::Fkey_sf; // Shift+Down
case fc::Fkey_left:
return fc::Fkey_sleft; // Shift+Left
case fc::Fkey_right:
return fc::Fkey_sright; // Shift+Right
case fc::Fkey_ic:
return fc::Fkey_sic; // Shift+Ins
case fc::Fkey_dc:
return fc::Fkey_sdc; // Shift+Del
case fc::Fkey_home:
return fc::Fkey_shome; // Shift+Home
case fc::Fkey_end:
return fc::Fkey_send; // Shift+End
case fc::Fkey_ppage:
return fc::Fkey_sprevious; // Shift+PgUp
case fc::Fkey_npage:
return fc::Fkey_snext; // Shift+PgDn
default:
return key_id;
}
}
//----------------------------------------------------------------------
int FApplication::linuxCtrlKeyCorrection (const int& key_id)
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fckey_up; // Ctrl+Up
case fc::Fkey_down:
return fc::Fckey_down; // Ctrl+Down
case fc::Fkey_left:
return fc::Fckey_left; // Ctrl+Left
case fc::Fkey_right:
return fc::Fckey_right; // Ctrl+Right
case fc::Fkey_ic:
return fc::Fckey_ic; // Ctrl+Ins
case fc::Fkey_dc:
return fc::Fckey_dc; // Ctrl+Del
case fc::Fkey_home:
return fc::Fckey_home; // Ctrl+Home
case fc::Fkey_end:
return fc::Fckey_end; // Ctrl+End
case fc::Fkey_ppage:
return fc::Fckey_ppage; // Ctrl+PgUp
case fc::Fkey_npage:
return fc::Fckey_npage; // Ctrl+PgDn
default:
return key_id;
}
}
//----------------------------------------------------------------------
int FApplication::linuxAltKeyCorrection (const int& key_id)
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fmkey_up; // Meta+Up
case fc::Fkey_down:
return fc::Fmkey_down; // Meta+Down
case fc::Fkey_left:
return fc::Fmkey_left; // Meta+Left
case fc::Fkey_right:
return fc::Fmkey_right; // Meta+Right
case fc::Fkey_ic:
return fc::Fmkey_ic; // Meta+Ins
case fc::Fkey_dc:
return fc::Fmkey_dc; // Meta+Del
case fc::Fkey_home:
return fc::Fmkey_home; // Meta+Home
case fc::Fkey_end:
return fc::Fmkey_end; // Meta+End
case fc::Fkey_ppage:
return fc::Fmkey_ppage; // Meta+PgUp
case fc::Fkey_npage:
return fc::Fmkey_npage; // Meta+PgDn
default:
return key_id;
}
}
//----------------------------------------------------------------------
int FApplication::linuxShiftCtrlKeyCorrection (const int& key_id)
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fckey_sup; // Shift+Ctrl+Up
case fc::Fkey_down:
return fc::Fckey_sdown; // Shift+Ctrl+Down
case fc::Fkey_left:
return fc::Fckey_sleft; // Shift+Ctrl+Left
case fc::Fkey_right:
return fc::Fckey_sright; // Shift+Ctrl+Right
case fc::Fkey_ic:
return fc::Fckey_sic; // Shift+Ctrl+Ins
case fc::Fkey_dc:
return fc::Fckey_sdc; // Shift+Ctrl+Del
case fc::Fkey_home:
return fc::Fckey_shome; // Shift+Ctrl+Home
case fc::Fkey_end:
return fc::Fckey_send; // Shift+Ctrl+End
case fc::Fkey_ppage:
return fc::Fckey_sppage; // Shift+Ctrl+PgUp
case fc::Fkey_npage:
return fc::Fckey_snpage; // Shift+Ctrl+PgDn
default:
return key_id;
}
}
//----------------------------------------------------------------------
int FApplication::linuxShiftAltKeyCorrection (const int& key_id)
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fmkey_sup; // Shift+Meta+Up
case fc::Fkey_down:
return fc::Fmkey_sdown; // Shift+Meta+Down
case fc::Fkey_left:
return fc::Fmkey_sright; // Shift+Meta+Left
case fc::Fkey_right:
return fc::Fmkey_sleft; // Shift+Meta+Right
case fc::Fkey_ic:
return fc::Fmkey_sic; // Shift+Meta+Ins
case fc::Fkey_dc:
return fc::Fmkey_sdc; // Shift+Meta+Del
case fc::Fkey_home:
return fc::Fmkey_shome; // Shift+Meta+Home
case fc::Fkey_end:
return fc::Fmkey_send; // Shift+Meta+End
case fc::Fkey_ppage:
return fc::Fmkey_sppage; // Shift+Meta+PgUp
case fc::Fkey_npage:
return fc::Fmkey_snpage; // Shift+Meta+PgDn
default:
return key_id;
}
}
//----------------------------------------------------------------------
int FApplication::linuxCtrlAltKeyCorrection (const int& key_id)
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fcmkey_up; // Ctrl+Meta+Up
case fc::Fkey_down:
return fc::Fcmkey_down; // Ctrl+Meta+Down
case fc::Fkey_left:
return fc::Fcmkey_left; // Ctrl+Meta+Left
case fc::Fkey_right:
return fc::Fcmkey_right; // Ctrl+Meta+Right
case fc::Fkey_ic:
return fc::Fcmkey_ic; // Ctrl+Meta+Ins
case fc::Fkey_dc:
return fc::Fcmkey_dc; // Ctrl+Meta+Del
case fc::Fkey_home:
return fc::Fcmkey_home; // Ctrl+Meta+Home
case fc::Fkey_end:
return fc::Fcmkey_end; // Ctrl+Meta+End
case fc::Fkey_ppage:
return fc::Fcmkey_ppage; // Ctrl+Meta+PgUp
case fc::Fkey_npage:
return fc::Fcmkey_npage; // Ctrl+Meta+PgDn
default:
return key_id;
}
}
//----------------------------------------------------------------------
int FApplication::linuxShiftCtrlAltKeyCorrection (const int& key_id)
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fcmkey_sup; // Shift+Ctrl+Meta+Up
case fc::Fkey_down:
return fc::Fcmkey_sdown; // Shift+Ctrl+Meta+Down
case fc::Fkey_left:
return fc::Fcmkey_sleft; // Shift+Ctrl+Meta+Left
case fc::Fkey_right:
return fc::Fcmkey_sright; // Shift+Ctrl+Meta+Right
case fc::Fkey_ic:
return fc::Fcmkey_sic; // Shift+Ctrl+Meta+Ins
case fc::Fkey_dc:
return fc::Fcmkey_sdc; // Shift+Ctrl+Meta+Del
case fc::Fkey_home:
return fc::Fcmkey_shome; // Shift+Ctrl+Meta+Home
case fc::Fkey_end:
return fc::Fcmkey_send; // Shift+Ctrl+Meta+End
case fc::Fkey_ppage:
return fc::Fcmkey_sppage; // Shift+Ctrl+Meta+PgUp
case fc::Fkey_npage:
return fc::Fcmkey_snpage; // Shift+Ctrl+Meta+PgDn
default:
return key_id;
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FApplication::linuxModifierKeyCorrection (const int& key_id) int FApplication::linuxModifierKeyCorrection (const int& key_id)
{ {
// get the current modifier key state // Get the current modifier key state
FTerm::modifier_key& m = getLinuxModifierKey(); FTerm::modifier_key& m = getLinuxModifierKey();
if ( ! (m.shift || m.ctrl || m.alt) ) if ( ! (m.shift || m.ctrl || m.alt) )
@ -793,269 +1074,31 @@ int FApplication::linuxModifierKeyCorrection (const int& key_id)
} }
else if ( m.shift && ! m.ctrl && ! m.alt ) else if ( m.shift && ! m.ctrl && ! m.alt )
{ {
switch ( key_id ) return linuxShiftKeyCorrection(key_id);
{
case fc::Fkey_up:
return fc::Fkey_sr; // Shift+Up
case fc::Fkey_down:
return fc::Fkey_sf; // Shift+Down
case fc::Fkey_left:
return fc::Fkey_sleft; // Shift+Left
case fc::Fkey_right:
return fc::Fkey_sright; // Shift+Right
case fc::Fkey_ic:
return fc::Fkey_sic; // Shift+Ins
case fc::Fkey_dc:
return fc::Fkey_sdc; // Shift+Del
case fc::Fkey_home:
return fc::Fkey_shome; // Shift+Home
case fc::Fkey_end:
return fc::Fkey_send; // Shift+End
case fc::Fkey_ppage:
return fc::Fkey_sprevious; // Shift+PgUp
case fc::Fkey_npage:
return fc::Fkey_snext; // Shift+PgDn
default:
return key_id;
}
} }
else if ( ! m.shift && m.ctrl && ! m.alt ) else if ( ! m.shift && m.ctrl && ! m.alt )
{ {
switch ( key_id ) return linuxCtrlKeyCorrection(key_id);
{
case fc::Fkey_up:
return fc::Fckey_up; // Ctrl+Up
case fc::Fkey_down:
return fc::Fckey_down; // Ctrl+Down
case fc::Fkey_left:
return fc::Fckey_left; // Ctrl+Left
case fc::Fkey_right:
return fc::Fckey_right; // Ctrl+Right
case fc::Fkey_ic:
return fc::Fckey_ic; // Ctrl+Ins
case fc::Fkey_dc:
return fc::Fckey_dc; // Ctrl+Del
case fc::Fkey_home:
return fc::Fckey_home; // Ctrl+Home
case fc::Fkey_end:
return fc::Fckey_end; // Ctrl+End
case fc::Fkey_ppage:
return fc::Fckey_ppage; // Ctrl+PgUp
case fc::Fkey_npage:
return fc::Fckey_npage; // Ctrl+PgDn
default:
return key_id;
}
} }
else if ( ! m.shift && ! m.ctrl && m.alt ) else if ( ! m.shift && ! m.ctrl && m.alt )
{ {
switch ( key_id ) return linuxAltKeyCorrection(key_id);
{
case fc::Fkey_up:
return fc::Fmkey_up; // Meta+Up
case fc::Fkey_down:
return fc::Fmkey_down; // Meta+Down
case fc::Fkey_left:
return fc::Fmkey_left; // Meta+Left
case fc::Fkey_right:
return fc::Fmkey_right; // Meta+Right
case fc::Fkey_ic:
return fc::Fmkey_ic; // Meta+Ins
case fc::Fkey_dc:
return fc::Fmkey_dc; // Meta+Del
case fc::Fkey_home:
return fc::Fmkey_home; // Meta+Home
case fc::Fkey_end:
return fc::Fmkey_end; // Meta+End
case fc::Fkey_ppage:
return fc::Fmkey_ppage; // Meta+PgUp
case fc::Fkey_npage:
return fc::Fmkey_npage; // Meta+PgDn
default:
return key_id;
}
} }
else if ( m.shift && m.ctrl && ! m.alt ) else if ( m.shift && m.ctrl && ! m.alt )
{ {
switch ( key_id ) return linuxShiftCtrlKeyCorrection(key_id);
{
case fc::Fkey_up:
return fc::Fckey_sup; // Shift+Ctrl+Up
case fc::Fkey_down:
return fc::Fckey_sdown; // Shift+Ctrl+Down
case fc::Fkey_left:
return fc::Fckey_sleft; // Shift+Ctrl+Left
case fc::Fkey_right:
return fc::Fckey_sright; // Shift+Ctrl+Right
case fc::Fkey_ic:
return fc::Fckey_sic; // Shift+Ctrl+Ins
case fc::Fkey_dc:
return fc::Fckey_sdc; // Shift+Ctrl+Del
case fc::Fkey_home:
return fc::Fckey_shome; // Shift+Ctrl+Home
case fc::Fkey_end:
return fc::Fckey_send; // Shift+Ctrl+End
case fc::Fkey_ppage:
return fc::Fckey_sppage; // Shift+Ctrl+PgUp
case fc::Fkey_npage:
return fc::Fckey_snpage; // Shift+Ctrl+PgDn
default:
return key_id;
}
} }
else if ( m.shift && ! m.ctrl && m.alt ) else if ( m.shift && ! m.ctrl && m.alt )
{ {
switch ( key_id ) return linuxShiftAltKeyCorrection(key_id);
{
case fc::Fkey_up:
return fc::Fmkey_sup; // Shift+Meta+Up
case fc::Fkey_down:
return fc::Fmkey_sdown; // Shift+Meta+Down
case fc::Fkey_left:
return fc::Fmkey_sright; // Shift+Meta+Left
case fc::Fkey_right:
return fc::Fmkey_sleft; // Shift+Meta+Right
case fc::Fkey_ic:
return fc::Fmkey_sic; // Shift+Meta+Ins
case fc::Fkey_dc:
return fc::Fmkey_sdc; // Shift+Meta+Del
case fc::Fkey_home:
return fc::Fmkey_shome; // Shift+Meta+Home
case fc::Fkey_end:
return fc::Fmkey_send; // Shift+Meta+End
case fc::Fkey_ppage:
return fc::Fmkey_sppage; // Shift+Meta+PgUp
case fc::Fkey_npage:
return fc::Fmkey_snpage; // Shift+Meta+PgDn
default:
return key_id;
}
} }
else if ( ! m.shift && m.ctrl && m.alt ) else if ( ! m.shift && m.ctrl && m.alt )
{ {
switch ( key_id ) return linuxCtrlAltKeyCorrection(key_id);
{
case fc::Fkey_up:
return fc::Fcmkey_up; // Ctrl+Meta+Up
case fc::Fkey_down:
return fc::Fcmkey_down; // Ctrl+Meta+Down
case fc::Fkey_left:
return fc::Fcmkey_left; // Ctrl+Meta+Left
case fc::Fkey_right:
return fc::Fcmkey_right; // Ctrl+Meta+Right
case fc::Fkey_ic:
return fc::Fcmkey_ic; // Ctrl+Meta+Ins
case fc::Fkey_dc:
return fc::Fcmkey_dc; // Ctrl+Meta+Del
case fc::Fkey_home:
return fc::Fcmkey_home; // Ctrl+Meta+Home
case fc::Fkey_end:
return fc::Fcmkey_end; // Ctrl+Meta+End
case fc::Fkey_ppage:
return fc::Fcmkey_ppage; // Ctrl+Meta+PgUp
case fc::Fkey_npage:
return fc::Fcmkey_npage; // Ctrl+Meta+PgDn
default:
return key_id;
}
} }
else if ( m.shift && m.ctrl && m.alt ) else if ( m.shift && m.ctrl && m.alt )
{ {
switch ( key_id ) return linuxShiftCtrlAltKeyCorrection(key_id);
{
case fc::Fkey_up:
return fc::Fcmkey_sup; // Shift+Ctrl+Meta+Up
case fc::Fkey_down:
return fc::Fcmkey_sdown; // Shift+Ctrl+Meta+Down
case fc::Fkey_left:
return fc::Fcmkey_sleft; // Shift+Ctrl+Meta+Left
case fc::Fkey_right:
return fc::Fcmkey_sright; // Shift+Ctrl+Meta+Right
case fc::Fkey_ic:
return fc::Fcmkey_sic; // Shift+Ctrl+Meta+Ins
case fc::Fkey_dc:
return fc::Fcmkey_sdc; // Shift+Ctrl+Meta+Del
case fc::Fkey_home:
return fc::Fcmkey_shome; // Shift+Ctrl+Meta+Home
case fc::Fkey_end:
return fc::Fcmkey_send; // Shift+Ctrl+Meta+End
case fc::Fkey_ppage:
return fc::Fcmkey_sppage; // Shift+Ctrl+Meta+PgUp
case fc::Fkey_npage:
return fc::Fcmkey_snpage; // Shift+Ctrl+Meta+PgDn
default:
return key_id;
}
} }
return key_id; return key_id;

View File

@ -1715,7 +1715,7 @@ void FListView::drawListLine ( const FListViewItem* item
// Insert text and tailing space // Insert text and tailing space
line += text.left(width); line += text.left(width);
line += FString ( leading_space + width line += FString ( leading_space + width
- int(align_offset + txt_length), L' '); - int(align_offset + txt_length), L' ');
} }
else if ( align == fc::alignRight ) else if ( align == fc::alignRight )
{ {

View File

@ -581,7 +581,7 @@ void FOptiMove::calculateCharDuration()
{ {
static const int baudbyte = 9; // = 7 bit + 1 parity + 1 stop static const int baudbyte = 9; // = 7 bit + 1 parity + 1 stop
char_duration = (baudbyte * 1000 * 10) char_duration = (baudbyte * 1000 * 10)
/ (baudrate > 0 ? baudrate : 9600); // milliseconds / (baudrate > 0 ? baudrate : 9600); // milliseconds
if ( char_duration <= 0 ) if ( char_duration <= 0 )
char_duration = 1; char_duration = 1;

View File

@ -240,7 +240,7 @@ void FScrollbar::calculateSliderValues()
} }
slider_pos = int( round ( double((bar_length - slider_length) * val) slider_pos = int( round ( double((bar_length - slider_length) * val)
/ double(max - min) ) ); / double(max - min) ) );
if ( slider_pos < 0 ) if ( slider_pos < 0 )
slider_pos = 0; slider_pos = 0;

View File

@ -2543,7 +2543,7 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t* s)
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;
@ -2584,7 +2584,7 @@ inline void FString::_remove (uInt pos, uInt len)
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

View File

@ -225,7 +225,9 @@ const FString FTerm::getKeyName (int keynum)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTerm::modifier_key& FTerm::getLinuxModifierKey() FTerm::modifier_key& FTerm::getLinuxModifierKey()
{ {
static const char subcode = 6; // Get Linux console shift state
char subcode = 6; // Shift state command + return value
// fill bit field with 0 // fill bit field with 0
std::memset (&mod_key, 0x00, sizeof(mod_key)); std::memset (&mod_key, 0x00, sizeof(mod_key));

View File

@ -1061,6 +1061,8 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos
, term_area* area ) , term_area* area )
{ {
// Determines the covered state for the given position
return isCovered (pos.getX(), pos.getY(), area); return isCovered (pos.getX(), pos.getY(), area);
} }
@ -1068,6 +1070,8 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos
FVTerm::covered_state FVTerm::isCovered ( int x, int y FVTerm::covered_state FVTerm::isCovered ( int x, int y
, term_area* area ) , term_area* area )
{ {
// Determines the covered state for the given position
bool found; bool found;
covered_state is_covered; covered_state is_covered;
FWidget* w; FWidget* w;
@ -1128,6 +1132,151 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
return is_covered; return is_covered;
} }
//----------------------------------------------------------------------
void FVTerm::updateOverlappedColor ( term_area* area
, int x, int y, int tx, int ty )
{
// Add the overlapping color to this character
int& aw = area->width;
int& rsh = area->right_shadow;
int line_len = aw + rsh;
// Area character
char_data* ac = &area->text[y * line_len + x];
// Terminal character
char_data* tc = &vterm->text[ty * vterm->width + tx];
// New character
char_data nc;
std::memcpy (&nc, ac, sizeof(char_data));
// Overlapped character
char_data oc = getOverlappedCharacter (tx + 1, ty + 1, area->widget);
nc.fg_color = oc.fg_color;
nc.bg_color = oc.bg_color;
nc.attr.bit.reverse = false;
nc.attr.bit.standout = false;
if ( nc.code == fc::LowerHalfBlock
|| nc.code == fc::UpperHalfBlock
|| nc.code == fc::LeftHalfBlock
|| nc.code == fc::RightHalfBlock
|| nc.code == fc::MediumShade
|| nc.code == fc::FullBlock )
nc.code = ' ';
nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc);
std::memcpy (tc, &nc, sizeof(char_data));
}
//----------------------------------------------------------------------
void FVTerm::updateOverlappedCharacter (term_area* area, int tx, int ty)
{
// Restore one character on vterm
// Terminal character
char_data* tc = &vterm->text[ty * vterm->width + tx];
// Overlapped character
char_data oc = getCoveredCharacter (tx + 1, ty + 1, area->widget);
oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc);
std::memcpy (tc, &oc, sizeof(char_data));
}
//----------------------------------------------------------------------
void FVTerm::updateShadedCharacter ( term_area* area
, int x, int y, int tx, int ty )
{
// Get covered character + add the current color
int& aw = area->width;
int& rsh = area->right_shadow;
int line_len = aw + rsh;
// Area character
char_data* ac = &area->text[y * line_len + x];
// Terminal character
char_data* tc = &vterm->text[ty * vterm->width + tx];
// Overlapped character
char_data oc = getCoveredCharacter (tx + 1, ty + 1, area->widget);
oc.fg_color = ac->fg_color;
oc.bg_color = ac->bg_color;
oc.attr.bit.reverse = false;
oc.attr.bit.standout = false;
if ( oc.code == fc::LowerHalfBlock
|| oc.code == fc::UpperHalfBlock
|| oc.code == fc::LeftHalfBlock
|| oc.code == fc::RightHalfBlock
|| oc.code == fc::MediumShade
|| oc.code == fc::FullBlock )
oc.code = ' ';
oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc);
std::memcpy (tc, &oc, sizeof(char_data));
}
//----------------------------------------------------------------------
void FVTerm::updateInheritBackground ( term_area* area
, int x, int y, int tx, int ty )
{
// Add the covered background to this character
int& aw = area->width;
int& rsh = area->right_shadow;
int line_len = aw + rsh;
// Area character
char_data* ac = &area->text[y * line_len + x];
// Terminal character
char_data* tc = &vterm->text[ty * vterm->width + tx];
// New character
char_data nc;
std::memcpy (&nc, ac, sizeof(char_data));
// Covered character
char_data cc = getCoveredCharacter (tx + 1, ty + 1, area->widget);
nc.bg_color = cc.bg_color;
nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc);
std::memcpy (tc, &nc, sizeof(char_data));
}
//----------------------------------------------------------------------
void FVTerm::updateCharacter ( term_area* area
, int x, int y, int tx, int ty )
{
// Copy a area character to the virtual terminal
int& aw = area->width;
int& rsh = area->right_shadow;
int line_len = aw + rsh;
// Area character
char_data* ac = &area->text[y * line_len + x];
// Terminal character
char_data* tc = &vterm->text[ty * vterm->width + tx];
std::memcpy (tc, ac, sizeof(char_data));
if ( tc->attr.bit.printed && *tc == *ac )
tc->attr.bit.no_changes = true;
else
tc->attr.bit.no_changes = false;
}
//----------------------------------------------------------------------
void FVTerm::callPreprocessingHandler (term_area* area)
{
// Call preprocessing handler
if ( ! area->preprocessing_call.empty() )
{
FPreprocessing::const_iterator iter, end;
iter = area->preprocessing_call.begin();
end = area->preprocessing_call.end();
while ( iter != end )
{
FPreprocessingHandler handler = iter->handler;
// call the preprocessing handler
(iter->instance->*handler)();
++iter;
}
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateVTerm() void FVTerm::updateVTerm()
{ {
@ -1190,7 +1339,6 @@ void FVTerm::updateVTerm (term_area* area)
{ {
// Update area data on VTerm // Update area data on VTerm
char_data* tc; // terminal character
char_data* ac; // area character char_data* ac; // area character
if ( ! area ) if ( ! area )
@ -1199,21 +1347,8 @@ void FVTerm::updateVTerm (term_area* area)
if ( ! area->visible ) if ( ! area->visible )
return; return;
// Call preprocessing handler // Call the processing handler methods
if ( ! area->preprocessing_call.empty() ) callPreprocessingHandler(area);
{
FPreprocessing::const_iterator iter, end;
iter = area->preprocessing_call.begin();
end = area->preprocessing_call.end();
while ( iter != end )
{
FPreprocessingHandler handler = iter->handler;
// call the preprocessing handler
(iter->instance->*handler)();
++iter;
}
}
int ax = area->offset_left int ax = area->offset_left
, ay = area->offset_top , ay = area->offset_top
@ -1266,87 +1401,33 @@ void FVTerm::updateVTerm (term_area* area)
int line_len = aw + rsh; int line_len = aw + rsh;
ac = &area->text[y * line_len + x]; ac = &area->text[y * line_len + x];
tc = &vterm->text[gy * vterm->width + gx - ol]; gx -= ol;
is_covered = isCovered(gx - ol, gy, area); // get covered state is_covered = isCovered(gx, gy, area); // get covered state
if ( is_covered != fully_covered ) if ( is_covered != fully_covered )
{ {
if ( is_covered == half_covered ) if ( is_covered == half_covered )
{ {
// add the overlapping color to this character updateOverlappedColor(area, x, y, gx, gy);
char_data ch, oc;
std::memcpy (&ch, ac, sizeof(char_data));
oc = getOverlappedCharacter (gx + 1 - ol, gy + 1, area->widget);
ch.fg_color = oc.fg_color;
ch.bg_color = oc.bg_color;
ch.attr.bit.reverse = false;
ch.attr.bit.standout = false;
if ( ch.code == fc::LowerHalfBlock
|| ch.code == fc::UpperHalfBlock
|| ch.code == fc::LeftHalfBlock
|| ch.code == fc::RightHalfBlock
|| ch.code == fc::MediumShade
|| ch.code == fc::FullBlock )
ch.code = ' ';
ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data));
} }
else if ( ac->attr.bit.transparent ) // transparent else if ( ac->attr.bit.transparent ) // transparent
{ {
// restore one character on vterm updateOverlappedCharacter(area, gx, gy);
char_data ch;
ch = getCoveredCharacter (gx + 1 - ol, gy + 1, area->widget);
ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data));
} }
else // not transparent else // not transparent
{ {
if ( ac->attr.bit.trans_shadow ) // transparent shadow if ( ac->attr.bit.trans_shadow ) // transparent shadow
{ {
// get covered character + add the current color updateShadedCharacter (area, x, y, gx, gy);
char_data ch;
ch = getCoveredCharacter (gx + 1 - ol, gy + 1, area->widget);
ch.fg_color = ac->fg_color;
ch.bg_color = ac->bg_color;
ch.attr.bit.reverse = false;
ch.attr.bit.standout = false;
if ( ch.code == fc::LowerHalfBlock
|| ch.code == fc::UpperHalfBlock
|| ch.code == fc::LeftHalfBlock
|| ch.code == fc::RightHalfBlock
|| ch.code == fc::MediumShade
|| ch.code == fc::FullBlock )
ch.code = ' ';
ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data));
} }
else if ( ac->attr.bit.inherit_bg ) else if ( ac->attr.bit.inherit_bg )
{ {
// add the covered background to this character updateInheritBackground (area, x, y, gx, gy);
char_data ch, cc;
std::memcpy (&ch, ac, sizeof(char_data));
cc = getCoveredCharacter (gx + 1 - ol, gy + 1, area->widget);
ch.bg_color = cc.bg_color;
ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data));
} }
else // default else // default
{ {
if ( tc->attr.bit.printed && *tc == *ac ) updateCharacter (area, x, y, gx, gy);
{
std::memcpy (tc, ac, sizeof(char_data));
tc->attr.bit.no_changes = true;
}
else
{
std::memcpy (tc, ac, sizeof(char_data));
tc->attr.bit.no_changes = false;
}
} }
} }

View File

@ -664,7 +664,7 @@ void FWidget::setTermOffsetWithPadding()
offset.setCoordinates ( r->getLeftPadding() offset.setCoordinates ( r->getLeftPadding()
, r->getTopPadding() , r->getTopPadding()
, r->getWidth() - 1 - r->getRightPadding() , r->getWidth() - 1 - r->getRightPadding()
, r->getHeight() - 1 - r->getBottomPadding() ); , r->getHeight() - 1 - r->getBottomPadding() );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------