Skipping the print of characters without changes

This commit is contained in:
Markus Gans 2016-12-18 23:34:11 +01:00
parent fedb5f64f3
commit b9f3be782f
42 changed files with 670 additions and 623 deletions

View File

@ -1,3 +1,9 @@
2016-12-18 Markus Gans <guru.mail@muenster.de>
* Only perform VTerm updates on terminal updates
* Skipping the print of characters without changes
* Combined scrollAreaForward and scrollAreaReverse
with terminal scroll sequences
2016-12-15 Markus Gans <guru.mail@muenster.de> 2016-12-15 Markus Gans <guru.mail@muenster.de>
* Reduce the character output by using character erase * Reduce the character output by using character erase
and character repeat and character repeat

View File

@ -526,7 +526,6 @@ void FButton::draw()
is_Flat = isFlat(); is_Flat = isFlat();
is_NonFlatShadow = ((flags & (fc::shadow+fc::flat)) == fc::shadow); is_NonFlatShadow = ((flags & (fc::shadow+fc::flat)) == fc::shadow);
is_NoUnderline = ((flags & fc::no_underline) != 0); is_NoUnderline = ((flags & fc::no_underline) != 0);
updateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -725,7 +724,6 @@ void FButton::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
delete[] ButtonText; delete[] ButtonText;
if ( is_Focus && getStatusBar() ) if ( is_Focus && getStatusBar() )

View File

@ -447,8 +447,6 @@ void FButtonGroup::setHotkeyAccelerator()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::draw() void FButtonGroup::draw()
{ {
updateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -461,8 +459,6 @@ void FButtonGroup::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -40,10 +40,8 @@ void FCheckBox::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FCheckBox::draw() void FCheckBox::draw()
{ {
updateVTerm(false);
drawCheckButton(); drawCheckButton();
drawLabel(); drawLabel();
updateVTerm(true);
FToggleButton::draw(); FToggleButton::draw();
} }

View File

@ -1007,7 +1007,6 @@ void FDialog::draw()
tooltip = 0; tooltip = 0;
} }
updateVTerm(false);
// fill the background // fill the background
setColor(); setColor();
@ -1024,8 +1023,6 @@ void FDialog::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -452,8 +452,6 @@ void FLabel::draw()
if ( text.isNull() || text.isEmpty() ) if ( text.isNull() || text.isEmpty() )
return; return;
updateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
{ {
setReverse(true); setReverse(true);
@ -529,6 +527,4 @@ void FLabel::draw()
if ( hasEmphasis() ) if ( hasEmphasis() )
setBold(false); setBold(false);
} }
updateVTerm(true);
} }

View File

@ -748,8 +748,6 @@ void FLineEdit::drawInputField()
int active_focus = fc::active + fc::focus; int active_focus = fc::active + fc::focus;
isActiveFocus = ((flags & active_focus) == active_focus); isActiveFocus = ((flags & active_focus) == active_focus);
isShadow = ((flags & fc::shadow) != 0 ); isShadow = ((flags & fc::shadow) != 0 );
updateVTerm(false);
setPrintPos (1, 1); setPrintPos (1, 1);
if ( isMonochron() ) if ( isMonochron() )
@ -807,8 +805,6 @@ void FLineEdit::drawInputField()
// set the cursor to the first pos. // set the cursor to the first pos.
setCursorPos (2+cursor_pos-text_offset, 1); setCursorPos (2+cursor_pos-text_offset, 1);
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -1453,7 +1453,6 @@ void FListBox::draw()
if ( current < 1 ) if ( current < 1 )
current = 1; current = 1;
updateVTerm(false);
setColor(); setColor();
if ( isMonochron() ) if ( isMonochron() )
@ -1480,8 +1479,6 @@ void FListBox::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
if ( vbar->isVisible() ) if ( vbar->isVisible() )
vbar->redraw(); vbar->redraw();
@ -1561,8 +1558,6 @@ void FListBox::drawList()
end = std::max(last_pos, current_pos)+1; end = std::max(last_pos, current_pos)+1;
} }
updateVTerm(false);
for (uInt y=start; y < end; y++) for (uInt y=start; y < end; y++)
{ {
setPrintPos (2, 2 + int(y)); setPrintPos (2, 2 + int(y));
@ -1784,7 +1779,6 @@ void FListBox::drawList()
setReverse(false); setReverse(false);
unsetBold(); unsetBold();
updateVTerm(true);
last_yoffset = yoffset; last_yoffset = yoffset;
last_current = current; last_current = current;
} }

View File

@ -1218,7 +1218,6 @@ void FMenu::draw()
{ {
// fill the background // fill the background
setColor (wc.menu_active_fg, wc.menu_active_bg); setColor (wc.menu_active_fg, wc.menu_active_bg);
updateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -1230,8 +1229,6 @@ void FMenu::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -744,7 +744,6 @@ void FMenuBar::drawItems()
if ( item_list.empty() ) if ( item_list.empty() )
return; return;
updateVTerm(false);
setPrintPos (1,1); setPrintPos (1,1);
if ( isMonochron() ) if ( isMonochron() )
@ -826,7 +825,8 @@ void FMenuBar::drawItems()
if ( ! std::iswprint(wint_t(item_text[z])) ) if ( ! std::iswprint(wint_t(item_text[z])) )
{ {
if ( ! isNewFont() && ( int(item_text[z]) < fc::NF_rev_left_arrow2 if ( ! isNewFont()
&& ( int(item_text[z]) < fc::NF_rev_left_arrow2
|| int(item_text[z]) > fc::NF_check_mark ) ) || int(item_text[z]) > fc::NF_check_mark ) )
{ {
item_text[z] = L' '; item_text[z] = L' ';
@ -885,8 +885,6 @@ void FMenuBar::drawItems()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -421,7 +421,6 @@ void FMessageBox::draw()
int head_offset = 0; int head_offset = 0;
int center_x = 0; int center_x = 0;
int msg_x = int((getWidth() - int(max_line_width)) / 2); // center the whole block int msg_x = int((getWidth() - int(max_line_width)) / 2); // center the whole block
updateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -454,8 +453,6 @@ void FMessageBox::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -55,6 +55,9 @@ class FOptiAttr
uChar transparent : 1; // transparent uChar transparent : 1; // transparent
uChar trans_shadow : 1; // transparent shadow uChar trans_shadow : 1; // transparent shadow
uChar inherit_bg : 1; // inherit background uChar inherit_bg : 1; // inherit background
uChar no_changes : 1; // no changes required
uChar restored : 1; // restored VTerm character
uChar : 6; // padding bits
} char_data; } char_data;
// Constructor // Constructor

View File

@ -37,15 +37,12 @@ void FProgressbar::setPercentage (int percentage_value)
else else
percentage = percentage_value; percentage = percentage_value;
updateVTerm(false);
if ( isVisible() ) if ( isVisible() )
{ {
drawPercentage(); drawPercentage();
drawBar(); drawBar();
} }
updateVTerm(true);
updateTerminal(); updateTerminal();
} }
@ -128,7 +125,6 @@ void FProgressbar::hide()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::reset() void FProgressbar::reset()
{ {
updateVTerm(false);
percentage = -1; percentage = -1;
if ( isVisible() ) if ( isVisible() )
@ -137,7 +133,6 @@ void FProgressbar::reset()
drawBar(); drawBar();
} }
updateVTerm(true);
updateTerminal(); updateTerminal();
} }
@ -146,14 +141,12 @@ void FProgressbar::reset()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::draw() void FProgressbar::draw()
{ {
updateVTerm(false);
drawPercentage(); drawPercentage();
drawBar(); drawBar();
if ( (flags & fc::shadow) != 0 ) if ( (flags & fc::shadow) != 0 )
drawShadow (); drawShadow ();
updateVTerm(true);
flush_out(); flush_out();
} }

View File

@ -41,10 +41,8 @@ void FRadioButton::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FRadioButton::draw() void FRadioButton::draw()
{ {
updateVTerm(false);
drawRadioButton(); drawRadioButton();
drawLabel(); drawLabel();
updateVTerm(true);
FToggleButton::draw(); FToggleButton::draw();
} }

View File

@ -289,7 +289,6 @@ void FScrollbar::drawBar()
if ( slider_pos != current_slider_pos ) if ( slider_pos != current_slider_pos )
{ {
int z; int z;
updateVTerm(false);
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
@ -392,8 +391,6 @@ void FScrollbar::drawBar()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
} }
} }
@ -604,11 +601,9 @@ void FScrollbar::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollbar::draw() void FScrollbar::draw()
{ {
updateVTerm(false);
drawButtons(); drawButtons();
current_slider_pos = -1; current_slider_pos = -1;
drawBar(); drawBar();
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -259,7 +259,6 @@ void FStatusBar::drawMessage()
if ( isLastActiveFocus ) if ( isLastActiveFocus )
space_offset = 0; space_offset = 0;
updateVTerm(false);
setColor (wc.statusbar_fg, wc.statusbar_bg); setColor (wc.statusbar_fg, wc.statusbar_bg);
setPrintPos (x, 1); setPrintPos (x, 1);
@ -301,8 +300,6 @@ void FStatusBar::drawMessage()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -604,7 +601,6 @@ void FStatusBar::drawKeys()
return; return;
} }
updateVTerm(false);
setPrintPos (1, 1); setPrintPos (1, 1);
if ( isMonochron() ) if ( isMonochron() )
@ -721,6 +717,5 @@ void FStatusBar::drawKeys()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
x_msg = x; x_msg = x;
} }

View File

@ -97,10 +97,8 @@ void FSwitch::onMouseUp (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FSwitch::draw() void FSwitch::draw()
{ {
updateVTerm(false);
drawLabel(); drawLabel();
drawCheckButton(); drawCheckButton();
updateVTerm(true);
FToggleButton::draw(); FToggleButton::draw();
updateTerminal(); updateTerminal();
flush_out(); flush_out();

View File

@ -430,7 +430,7 @@ int FTerm::parseKeyString ( char buffer[]
{ {
if ( len == 2 && ( buffer[1] == 'O' if ( len == 2 && ( buffer[1] == 'O'
|| buffer[1] == '[' || buffer[1] == '['
|| buffer[1] == ']') ) || buffer[1] == ']' ) )
{ {
if ( ! isKeyTimeout(time_keypressed, key_timeout) ) if ( ! isKeyTimeout(time_keypressed, key_timeout) )
return NEED_MORE_DATA; return NEED_MORE_DATA;
@ -932,7 +932,8 @@ const FString FTerm::getXTermColorName (int color)
void FTerm::setXTermCursorStyle (fc::xtermCursorStyle style) void FTerm::setXTermCursorStyle (fc::xtermCursorStyle style)
{ {
// Set the xterm cursor style // Set the xterm cursor style
if ( (xterm_terminal || mintty_terminal) && ! (gnome_terminal || kde_konsole) ) if ( (xterm_terminal || mintty_terminal)
&& ! (gnome_terminal || kde_konsole) )
{ {
putstringf (CSI "%d q", style); putstringf (CSI "%d q", style);
std::fflush(stdout); std::fflush(stdout);
@ -2712,6 +2713,8 @@ void FTerm::init_termcaps()
const_cast<char*>(CSI "48;5;%p1%dm"); const_cast<char*>(CSI "48;5;%p1%dm");
tcap[fc::t_exit_attribute_mode].string = \ tcap[fc::t_exit_attribute_mode].string = \
const_cast<char*>(CSI "0m" SI); const_cast<char*>(CSI "0m" SI);
tcap[fc::t_orig_pair].string = \
const_cast<char*>(CSI "39;49m");
} }
else if ( putty_terminal ) else if ( putty_terminal )
{ {
@ -2858,7 +2861,7 @@ void FTerm::init_termcaps()
if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0)) if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0))
|| ( tcap[fc::t_cursor_up].string || ( tcap[fc::t_cursor_up].string
&& (std::strcmp(tcap[fc::t_cursor_up].string, CSI "A") == 0)) ) && (std::strcmp(tcap[fc::t_cursor_up].string, CSI "A") == 0) ) )
{ {
for (int i=0; Fkey[i].tname[0] != 0; i++) for (int i=0; Fkey[i].tname[0] != 0; i++)
{ {
@ -2975,7 +2978,8 @@ void FTerm::init_encoding()
{ {
// detect encoding and set the Fputchar function pointer // detect encoding and set the Fputchar function pointer
if ( isatty(stdout_no) && ! std::strcmp(nl_langinfo(CODESET), "UTF-8") ) if ( isatty(stdout_no)
&& ! std::strcmp(nl_langinfo(CODESET), "UTF-8") )
{ {
utf8_console = true; utf8_console = true;
Encoding = fc::UTF8; Encoding = fc::UTF8;

View File

@ -631,7 +631,6 @@ void FTextView::draw()
{ {
FWidget* parent = getParentWidget(); FWidget* parent = getParentWidget();
bool is_text_dialog; bool is_text_dialog;
updateVTerm(false);
setColor(); setColor();
if ( isMonochron() ) if ( isMonochron() )
@ -662,7 +661,6 @@ void FTextView::draw()
if ( hbar->isVisible() ) if ( hbar->isVisible() )
hbar->redraw(); hbar->redraw();
updateVTerm(true);
drawText(); drawText();
if ( hasFocus() && getStatusBar() ) if ( hasFocus() && getStatusBar() )
@ -672,10 +670,8 @@ void FTextView::draw()
if ( curMsg != msg ) if ( curMsg != msg )
{ {
updateVTerm(false);
getStatusBar()->setMessage(msg); getStatusBar()->setMessage(msg);
getStatusBar()->drawMessage(); getStatusBar()->drawMessage();
updateVTerm(true);
} }
} }
@ -698,7 +694,6 @@ void FTextView::drawText()
if ( end > getRows() ) if ( end > getRows() )
end = getRows(); end = getRows();
updateVTerm(false);
setColor(); setColor();
if ( isMonochron() ) if ( isMonochron() )
@ -737,8 +732,6 @@ void FTextView::drawText()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -79,7 +79,6 @@ void FToolTip::setText (const char* txt)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToolTip::draw() void FToolTip::draw()
{ {
updateVTerm(false);
setColor(); setColor();
if ( getMaxColor() < 16 ) if ( getMaxColor() < 16 )
@ -95,7 +94,6 @@ void FToolTip::draw()
} }
unsetBold(); unsetBold();
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -15,13 +15,11 @@ bool FVTerm::terminal_update_complete;
bool FVTerm::terminal_update_pending; bool FVTerm::terminal_update_pending;
bool FVTerm::force_terminal_update; bool FVTerm::force_terminal_update;
bool FVTerm::stop_terminal_updates; bool FVTerm::stop_terminal_updates;
bool FVTerm::vterm_updates;
int FVTerm::skipped_terminal_update = 0; int FVTerm::skipped_terminal_update = 0;
std::queue<int>* FVTerm::output_buffer = 0; std::queue<int>* FVTerm::output_buffer = 0;
FPoint* FVTerm::term_pos = 0; FPoint* FVTerm::term_pos = 0;
FVTerm::term_area* FVTerm::vterm = 0; FVTerm::term_area* FVTerm::vterm = 0;
FVTerm::term_area* FVTerm::vdesktop = 0; FVTerm::term_area* FVTerm::vdesktop = 0;
FVTerm::term_area* FVTerm::last_area = 0;
FVTerm::term_area* FVTerm::active_area = 0; FVTerm::term_area* FVTerm::active_area = 0;
FVTerm::termcap_map* FVTerm::tcap = 0; FVTerm::termcap_map* FVTerm::tcap = 0;
FTermcap::tcap_map* FTermcap::tcap = 0; FTermcap::tcap_map* FTermcap::tcap = 0;
@ -41,7 +39,6 @@ FVTerm::FVTerm (FVTerm* parent)
, vwin(0) , vwin(0)
{ {
terminal_update_complete = false; terminal_update_complete = false;
vterm_updates = true;
if ( ! parent ) if ( ! parent )
{ {
@ -131,7 +128,7 @@ void FVTerm::clearTerm (int fillchar)
vdesktop->changes[i].trans_count = 0; vdesktop->changes[i].trans_count = 0;
} }
updateVTerm (vdesktop); vdesktop->has_changes = true;
setTermXY (0,0); setTermXY (0,0);
} }
else if ( cl ) else if ( cl )
@ -279,6 +276,9 @@ void FVTerm::updateTerminal()
} }
} }
// Update data on VTerm
updateVTerm();
for (register uInt y=0; y < uInt(vterm->height); y++) for (register uInt y=0; y < uInt(vterm->height); y++)
updateTerminalLine (y); updateTerminalLine (y);
@ -318,7 +318,9 @@ void FVTerm::updateTerminalLine (uInt y)
for (uInt x=xmin+1; x < uInt(vt->width); x++) for (uInt x=xmin+1; x < uInt(vt->width); x++)
{ {
if ( *min_char == vt->text[y * uInt(vt->width) + x] ) char_data* ch = &vt->text[y * uInt(vt->width) + x];
if ( *min_char == *ch )
beginning_whitespace++; beginning_whitespace++;
else else
break; break;
@ -340,7 +342,9 @@ void FVTerm::updateTerminalLine (uInt y)
for (uInt x=1; x < uInt(vt->width); x++) for (uInt x=1; x < uInt(vt->width); x++)
{ {
if ( *first_char == vt->text[y * uInt(vt->width) + x] ) char_data* ch = &vt->text[y * uInt(vt->width) + x];
if ( *first_char == *ch )
leading_whitespace++; leading_whitespace++;
else else
break; break;
@ -363,7 +367,9 @@ void FVTerm::updateTerminalLine (uInt y)
for (uInt x=uInt(vt->width)-1; x > 0 ; x--) for (uInt x=uInt(vt->width)-1; x > 0 ; x--)
{ {
if ( *last_char == vt->text[y * uInt(vt->width) + x] ) char_data* ch = &vt->text[y * uInt(vt->width) + x];
if ( *last_char == *ch )
tailing_whitespace++; tailing_whitespace++;
else else
break; break;
@ -399,6 +405,31 @@ void FVTerm::updateTerminalLine (uInt y)
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];
// skip character with no changes
if ( ! terminal_update_pending
&& print_char->no_changes
&& ! print_char->restored )
{
uInt count = 1;
for (uInt i=x+1; i <= xmax; i++)
{
char_data* ch = &vt->text[y * uInt(vt->width) + i];
if ( ch->no_changes && ! ch->restored )
count++;
else
break;
}
if ( count > uInt(cursor_addres_lengths) )
{
setTermXY (int(x + count), int(y));
x = x + count - 1;
continue;
}
}
// Erase a number of characters to draw simple whitespaces // Erase a number of characters to draw simple whitespaces
if ( ec && print_char->code == ' ' ) if ( ec && print_char->code == ' ' )
{ {
@ -407,7 +438,9 @@ void FVTerm::updateTerminalLine (uInt y)
for (uInt i=x+1; i <= xmax; i++) for (uInt i=x+1; i <= xmax; i++)
{ {
if ( *print_char == vt->text[y * uInt(vt->width) + i] ) char_data* ch = &vt->text[y * uInt(vt->width) + i];
if ( *print_char == *ch )
whitespace++; whitespace++;
else else
break; break;
@ -440,7 +473,9 @@ void FVTerm::updateTerminalLine (uInt y)
for (uInt i=x+1; i <= xmax; i++) for (uInt i=x+1; i <= xmax; i++)
{ {
if ( *print_char == vt->text[y * uInt(vt->width) + i] ) char_data* ch = &vt->text[y * uInt(vt->width) + i];
if ( *print_char == *ch )
repetitions++; repetitions++;
else else
break; break;
@ -704,6 +739,9 @@ int FVTerm::print (term_area* area, FString& s)
if ( p ) if ( p )
{ {
if ( *p )
area->has_changes = true;
while ( *p ) while ( *p )
{ {
int width, height, rsh, bsh; int width, height, rsh, bsh;
@ -762,6 +800,8 @@ int FVTerm::print (term_area* area, FString& s)
nc.transparent = next_attribute.transparent; nc.transparent = next_attribute.transparent;
nc.trans_shadow = next_attribute.trans_shadow; nc.trans_shadow = next_attribute.trans_shadow;
nc.inherit_bg = next_attribute.inherit_bg; nc.inherit_bg = next_attribute.inherit_bg;
nc.no_changes = false;
nc.restored = false;
if ( area if ( area
&& area->cursor_x > 0 && area->cursor_x > 0
@ -820,8 +860,6 @@ int FVTerm::print (term_area* area, FString& s)
p++; p++;
len++; len++;
} // end of while } // end of while
updateVTerm (area);
} }
return len; return len;
@ -878,6 +916,8 @@ int FVTerm::print (term_area* area, register int c)
nc.transparent = next_attribute.transparent; nc.transparent = next_attribute.transparent;
nc.trans_shadow = next_attribute.trans_shadow; nc.trans_shadow = next_attribute.trans_shadow;
nc.inherit_bg = next_attribute.inherit_bg; nc.inherit_bg = next_attribute.inherit_bg;
nc.no_changes = false;
nc.restored = false;
if ( area->cursor_x > 0 if ( area->cursor_x > 0
&& area->cursor_y > 0 && area->cursor_y > 0
@ -918,6 +958,7 @@ int FVTerm::print (term_area* area, register int c)
} }
area->cursor_x++; area->cursor_x++;
area->has_changes = true;
if ( area->cursor_x > width + rsh ) if ( area->cursor_x > width + rsh )
{ {
@ -928,11 +969,9 @@ int FVTerm::print (term_area* area, register int c)
if ( area->cursor_y > height + bsh ) if ( area->cursor_y > height + bsh )
{ {
area->cursor_y--; area->cursor_y--;
updateVTerm (area);
return -1; return -1;
} }
updateVTerm (area);
return 1; return 1;
} }
@ -1180,6 +1219,7 @@ void FVTerm::createArea ( int x_offset, int y_offset
area->input_cursor_x = -1; area->input_cursor_x = -1;
area->input_cursor_y = -1; area->input_cursor_y = -1;
area->input_cursor_visible = false; area->input_cursor_visible = false;
area->has_changes = false;
area->changes = 0; area->changes = 0;
area->text = 0; area->text = 0;
area->visible = false; area->visible = false;
@ -1244,6 +1284,7 @@ void FVTerm::resizeArea ( int x_offset, int y_offset
area->height = height; area->height = height;
area->right_shadow = rsw; area->right_shadow = rsw;
area->bottom_shadow = bsh; area->bottom_shadow = bsh;
area->has_changes = false;
default_char.code = ' '; default_char.code = ' ';
default_char.fg_color = fc::Default; default_char.fg_color = fc::Default;
@ -1264,6 +1305,7 @@ void FVTerm::resizeArea ( int x_offset, int y_offset
default_char.transparent = 0; default_char.transparent = 0;
default_char.trans_shadow = 0; default_char.trans_shadow = 0;
default_char.inherit_bg = 0; default_char.inherit_bg = 0;
default_char.no_changes = 0;
std::fill_n (area->text, area_size, default_char); std::fill_n (area->text, area_size, default_char);
@ -1413,6 +1455,7 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
} }
} }
sc->restored = true;
std::memcpy (tc, sc, sizeof(char_data)); std::memcpy (tc, sc, sizeof(char_data));
if ( short(vterm->changes[y+ty].xmin) > x ) if ( short(vterm->changes[y+ty].xmin) > x )
@ -1496,27 +1539,52 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateVTerm (bool on) void FVTerm::updateVTerm()
{ {
vterm_updates = on; // Update data on VTerm
if ( on ) if ( vdesktop && vdesktop->has_changes )
updateVTerm (last_area); {
updateVTerm(vdesktop);
vdesktop->has_changes = false;
}
FWidget* widget = static_cast<FWidget*>(vterm->widget);
if ( ! widget->window_list || widget->window_list->empty() )
return;
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;
if ( win->has_changes )
{
updateVTerm(win);
win->has_changes = false;
}
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateVTerm (term_area* area) void FVTerm::updateVTerm (term_area* area)
{ {
// Update area data on VTerm
int ax, ay, aw, ah, rsh, bsh, y_end, ol; int ax, ay, aw, ah, rsh, bsh, y_end, ol;
char_data* tc; // terminal character char_data* tc; // terminal character
char_data* ac; // area character char_data* ac; // area character
if ( ! vterm_updates )
{
last_area = area;
return;
}
if ( ! area ) if ( ! area )
return; return;
@ -1542,7 +1610,7 @@ void FVTerm::updateVTerm (term_area* area)
else else
y_end = ah + bsh; y_end = ah + bsh;
for (register int y=0; y < y_end; y++) // line loop for (int y=0; y < y_end; y++) // line loop
{ {
int line_xmin = int(area->changes[y].xmin); int line_xmin = int(area->changes[y].xmin);
int line_xmax = int(area->changes[y].xmax); int line_xmax = int(area->changes[y].xmax);
@ -1561,7 +1629,7 @@ void FVTerm::updateVTerm (term_area* area)
if ( ax + line_xmin >= vterm->width ) if ( ax + line_xmin >= vterm->width )
continue; continue;
for (register int x=line_xmin; x <= line_xmax; x++) // column loop for (int x=line_xmin; x <= line_xmax; x++) // column loop
{ {
int gx, gy, line_len; int gx, gy, line_len;
covered_state is_covered; covered_state is_covered;
@ -1599,6 +1667,7 @@ void FVTerm::updateVTerm (term_area* area)
|| ch.code == fc::FullBlock ) || ch.code == fc::FullBlock )
ch.code = ' '; ch.code = ' ';
ch.no_changes = bool(! tc->restored && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data)); std::memcpy (tc, &ch, sizeof(char_data));
} }
else if ( ac->transparent ) // transparent else if ( ac->transparent ) // transparent
@ -1606,6 +1675,7 @@ void FVTerm::updateVTerm (term_area* area)
// restore one character on vterm // restore one character on vterm
char_data ch; char_data ch;
ch = getCoveredCharacter (gx+1 - ol, gy+1, area->widget); ch = getCoveredCharacter (gx+1 - ol, gy+1, area->widget);
ch.no_changes = bool(! tc->restored && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data)); std::memcpy (tc, &ch, sizeof(char_data));
} }
else // not transparent else // not transparent
@ -1628,6 +1698,7 @@ void FVTerm::updateVTerm (term_area* area)
|| ch.code == fc::FullBlock ) || ch.code == fc::FullBlock )
ch.code = ' '; ch.code = ' ';
ch.no_changes = bool(! tc->restored && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data)); std::memcpy (tc, &ch, sizeof(char_data));
} }
else if ( ac->inherit_bg ) else if ( ac->inherit_bg )
@ -1637,16 +1708,30 @@ void FVTerm::updateVTerm (term_area* area)
std::memcpy (&ch, ac, sizeof(char_data)); std::memcpy (&ch, ac, sizeof(char_data));
cc = getCoveredCharacter (gx+1 - ol, gy+1, area->widget); cc = getCoveredCharacter (gx+1 - ol, gy+1, area->widget);
ch.bg_color = cc.bg_color; ch.bg_color = cc.bg_color;
ch.no_changes = bool(*tc == ch);
std::memcpy (tc, &ch, sizeof(char_data)); std::memcpy (tc, &ch, sizeof(char_data));
} }
else // default else // default
{
if ( ! tc->restored && *tc == *ac )
{
std::memcpy (tc, ac, sizeof(char_data)); std::memcpy (tc, ac, sizeof(char_data));
tc->no_changes = true;
}
else
{
std::memcpy (tc, ac, sizeof(char_data));
tc->no_changes = false;
}
}
} }
modified = true; modified = true;
} }
else if ( ! modified ) else if ( ! modified )
line_xmin++; // don't update covered character line_xmin++; // don't update covered character
tc->restored = false;
} }
_xmin = ax + line_xmin - ol; _xmin = ax + line_xmin - ol;
@ -1745,7 +1830,6 @@ void FVTerm::setAreaCursor ( int x, int y
area->input_cursor_x = x - 1; area->input_cursor_x = x - 1;
area->input_cursor_y = y - 1; area->input_cursor_y = y - 1;
area->input_cursor_visible = visible; area->input_cursor_visible = visible;
updateVTerm (area);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2014,6 +2098,24 @@ void FVTerm::scrollAreaForward (term_area* area)
std::fill_n (dc, area->width, nc); std::fill_n (dc, area->width, nc);
area->changes[y_max].xmin = 0; area->changes[y_max].xmin = 0;
area->changes[y_max].xmax = uInt(area->width - 1); area->changes[y_max].xmax = uInt(area->width - 1);
area->has_changes = true;
if ( area == vdesktop )
{
if ( tcap[fc::t_scroll_forward].string )
{
setTermXY (0, vdesktop->height);
scrollTermForward();
putArea (1, 1, vdesktop);
// avoid update lines from 0 to (y_max-1)
for (int y=0; y < y_max; y++)
{
area->changes[y].xmin = uInt(area->width - 1);
area->changes[y].xmax = 0;
}
}
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2022,6 +2124,7 @@ void FVTerm::scrollAreaReverse (term_area* area)
// Scrolls the entire area one line down // Scrolls the entire area one line down
int total_width; int total_width;
int length; int length;
int y_max;
char_data nc; // next character char_data nc; // next character
char_data* lc; // last character char_data* lc; // last character
char_data* sc; // source character char_data* sc; // source character
@ -2035,8 +2138,9 @@ void FVTerm::scrollAreaReverse (term_area* area)
length = area->width; length = area->width;
total_width = area->width + area->right_shadow; total_width = area->width + area->right_shadow;
y_max = area->height - 1;
for (int y=area->height-1; y > 0; y--) for (int y=y_max; y > 0; y--)
{ {
int pos1 = (y-1) * total_width; int pos1 = (y-1) * total_width;
int pos2 = y * total_width; int pos2 = y * total_width;
@ -2055,6 +2159,24 @@ void FVTerm::scrollAreaReverse (term_area* area)
std::fill_n (dc, area->width, nc); std::fill_n (dc, area->width, nc);
area->changes[0].xmin = 0; area->changes[0].xmin = 0;
area->changes[0].xmax = uInt(area->width - 1); area->changes[0].xmax = uInt(area->width - 1);
area->has_changes = true;
if ( area == vdesktop )
{
if ( tcap[fc::t_scroll_reverse].string )
{
setTermXY (0, 0);
scrollTermReverse();
putArea (1, 1, vdesktop);
// avoid update lines from 1 to y_max
for (int y=1; y <= y_max; y++)
{
area->changes[y].xmin = uInt(area->width - 1);
area->changes[y].xmax = 0;
}
}
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2130,7 +2252,7 @@ void FVTerm::clearArea (term_area* area, int fillchar)
area->changes[y].trans_count = w; area->changes[y].trans_count = w;
} }
updateVTerm (area); area->has_changes = true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2334,7 +2456,6 @@ void FVTerm::init()
init_object = this; init_object = this;
vterm = 0; vterm = 0;
vdesktop = 0; vdesktop = 0;
last_area = 0;
term_pos = new FPoint(-1,-1); term_pos = new FPoint(-1,-1);
output_buffer = new std::queue<int>; output_buffer = new std::queue<int>;
@ -2363,7 +2484,9 @@ void FVTerm::init()
term_attribute.pc_charset = \ term_attribute.pc_charset = \
term_attribute.transparent = \ term_attribute.transparent = \
term_attribute.trans_shadow = \ term_attribute.trans_shadow = \
term_attribute.inherit_bg = false; term_attribute.inherit_bg = \
term_attribute.no_changes = \
term_attribute.restored = false;
// next_attribute contains the state of the next printed character // next_attribute contains the state of the next printed character
std::memcpy (&next_attribute, &term_attribute, sizeof(char_data)); std::memcpy (&next_attribute, &term_attribute, sizeof(char_data));

View File

@ -68,6 +68,7 @@ class FVTerm : public FObject, public FTerm
FWidget* widget; FWidget* widget;
line_changes* changes; line_changes* changes;
char_data* text; char_data* text;
bool has_changes;
bool visible; bool visible;
} term_area; } term_area;
@ -263,7 +264,7 @@ class FVTerm : public FObject, public FTerm
static covered_state isCovered ( int, int static covered_state isCovered ( int, int
, term_area* ); , term_area* );
static void updateVTerm (bool); static void updateVTerm();
static void updateVTerm (term_area*); static void updateVTerm (term_area*);
static bool updateVTermCursor (term_area*); static bool updateVTermCursor (term_area*);
static bool isInsideArea (int, int, term_area*); static bool isInsideArea (int, int, term_area*);
@ -302,7 +303,6 @@ class FVTerm : public FObject, public FTerm
// Data Members // Data Members
static term_area* vterm; // virtual terminal static term_area* vterm; // virtual terminal
static term_area* vdesktop; // virtual desktop static term_area* vdesktop; // virtual desktop
static term_area* last_area; // last used area
static term_area* active_area; // active area static term_area* active_area; // active area
term_area* print_area; // print area for this object term_area* print_area; // print area for this object
term_area* vwin; // virtual window term_area* vwin; // virtual window
@ -342,7 +342,6 @@ class FVTerm : public FObject, public FTerm
static bool terminal_update_pending; static bool terminal_update_pending;
static bool force_terminal_update; static bool force_terminal_update;
static bool stop_terminal_updates; static bool stop_terminal_updates;
static bool vterm_updates;
static int skipped_terminal_update; static int skipped_terminal_update;
}; };
@ -404,7 +403,8 @@ inline void FVTerm::setNormal()
next_attribute.pc_charset = \ next_attribute.pc_charset = \
next_attribute.transparent = \ next_attribute.transparent = \
next_attribute.trans_shadow = \ next_attribute.trans_shadow = \
next_attribute.inherit_bg = false; next_attribute.inherit_bg = \
next_attribute.no_changes = false;
next_attribute.fg_color = fc::Default; next_attribute.fg_color = fc::Default;
next_attribute.bg_color = fc::Default; next_attribute.bg_color = fc::Default;

View File

@ -302,7 +302,6 @@ Calc::~Calc()
void Calc::drawDispay() void Calc::drawDispay()
{ {
FString display = input; FString display = input;
updateVTerm(false);
if ( display.isNull() || display.isEmpty() ) if ( display.isNull() || display.isEmpty() )
display = L'0'; display = L'0';
@ -364,8 +363,6 @@ void Calc::drawDispay()
setPrintPos (1,4); setPrintPos (1,4);
print(separator); print(separator);
} }
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -41,15 +41,9 @@ void keyboard::onKeyPress (FKeyEvent* ev)
printf ("Key %s (id %d)\n", getKeyName(key_id).c_str(), key_id); printf ("Key %s (id %d)\n", getKeyName(key_id).c_str(), key_id);
if ( is_last_line ) if ( is_last_line )
{
scrollAreaForward (vdesktop); scrollAreaForward (vdesktop);
if ( ! scrollTermForward() )
putArea (getTermPos(), vdesktop);
}
setAreaCursor (1, getPrintPos().getY(), true, vdesktop); setAreaCursor (1, getPrintPos().getY(), true, vdesktop);
} }

View File

@ -94,8 +94,6 @@ void Mandelbrot::draw()
print(' '); print(' ');
} }
} }
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -261,8 +261,6 @@ void AttribDemo::printAltCharset()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDemo::draw() void AttribDemo::draw()
{ {
updateVTerm(false);
// test alternate character set // test alternate character set
printAltCharset(); printAltCharset();
@ -383,7 +381,6 @@ void AttribDemo::draw()
setPrintPos (16, 17); setPrintPos (16, 17);
print ("Change background color ->"); print ("Change background color ->");
updateVTerm(true);
} }

View File

@ -60,13 +60,8 @@ void timer::onTimer (FTimerEvent* ev)
printf ("timer event, id %d\n", timer_id ); printf ("timer event, id %d\n", timer_id );
if ( is_last_line ) if ( is_last_line )
{
scrollAreaForward (vdesktop); scrollAreaForward (vdesktop);
if ( ! scrollTermForward() )
putArea (getTermPos(), vdesktop);
}
setAreaCursor (1, getPrintPos().getY(), true, vdesktop); setAreaCursor (1, getPrintPos().getY(), true, vdesktop);
} }

View File

@ -67,7 +67,6 @@ Transparent::~Transparent()
void Transparent::draw() void Transparent::draw()
{ {
FDialog::draw(); FDialog::draw();
updateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -106,8 +105,6 @@ void Transparent::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -188,19 +185,16 @@ MainWindow::MainWindow (FWidget* parent)
transpwin->setText("transparent"); transpwin->setText("transparent");
transpwin->setGeometry (6, 3, 29, 12); transpwin->setGeometry (6, 3, 29, 12);
transpwin->unsetTransparentShadow(); transpwin->unsetTransparentShadow();
transpwin->show();
Transparent* shadowwin = new Transparent(this, Transparent::shadow); Transparent* shadowwin = new Transparent(this, Transparent::shadow);
shadowwin->setText("shadow"); shadowwin->setText("shadow");
shadowwin->setGeometry (46, 11, 29, 12); shadowwin->setGeometry (46, 11, 29, 12);
shadowwin->unsetTransparentShadow(); shadowwin->unsetTransparentShadow();
shadowwin->show();
Transparent* ibg = new Transparent(this, Transparent::inherit_background); Transparent* ibg = new Transparent(this, Transparent::inherit_background);
ibg->setText("inherit background"); ibg->setText("inherit background");
ibg->setGeometry (42, 3, 29, 7); ibg->setGeometry (42, 3, 29, 7);
ibg->unsetTransparentShadow(); ibg->unsetTransparentShadow();
ibg->show();
// Statusbar at the bottom // Statusbar at the bottom
FStatusBar* statusbar = new FStatusBar (this); FStatusBar* statusbar = new FStatusBar (this);
@ -219,7 +213,6 @@ MainWindow::~MainWindow()
void MainWindow::draw() void MainWindow::draw()
{ {
FDialog::draw(); FDialog::draw();
updateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -233,7 +226,7 @@ void MainWindow::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
updateVTerm(true); updateTerminal();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------