From b9f3be782ff5bd7d551f3631b9789768e02e82a4 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 18 Dec 2016 23:34:11 +0100 Subject: [PATCH] Skipping the print of characters without changes --- ChangeLog | 6 + src/fapp.cpp | 124 ++++++++--------- src/fbutton.cpp | 12 +- src/fbuttongroup.cpp | 10 +- src/fcheckbox.cpp | 2 - src/fconfig.h | 4 +- src/fdialog.cpp | 67 +++++---- src/ffiledialog.cpp | 18 +-- src/flabel.cpp | 14 +- src/flineedit.cpp | 20 ++- src/flistbox.cpp | 66 ++++----- src/fmenu.cpp | 57 ++++---- src/fmenubar.cpp | 24 ++-- src/fmenuitem.cpp | 6 +- src/fmessagebox.cpp | 3 - src/foptiattr.cpp | 10 +- src/foptiattr.h | 3 + src/foptimove.cpp | 40 +++--- src/fprogressbar.cpp | 19 +-- src/fradiobutton.cpp | 2 - src/frect.cpp | 4 +- src/fscrollbar.cpp | 35 ++--- src/fstatusbar.cpp | 27 ++-- src/fstring.cpp | 8 +- src/fswitch.cpp | 2 - src/fterm.cpp | 164 +++++++++++----------- src/ftextview.cpp | 55 ++++---- src/ftogglebutton.cpp | 8 +- src/ftooltip.cpp | 2 - src/fvterm.cpp | 289 ++++++++++++++++++++++++++++----------- src/fvterm.h | 8 +- src/fwidget.cpp | 92 ++++++------- src/fwindow.cpp | 12 +- test/calculator.cpp | 9 +- test/keyboard.cpp | 6 - test/mandelbrot.cpp | 2 - test/menu.cpp | 16 +-- test/term-attributes.cpp | 3 - test/timer.cpp | 5 - test/transparent.cpp | 13 +- test/ui.cpp | 4 +- test/windows.cpp | 22 +-- 42 files changed, 670 insertions(+), 623 deletions(-) diff --git a/ChangeLog b/ChangeLog index d09089dc..2c55867a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-12-18 Markus Gans + * 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 * Reduce the character output by using character erase and character repeat diff --git a/src/fapp.cpp b/src/fapp.cpp index 385a7c52..f6664c1f 100644 --- a/src/fapp.cpp +++ b/src/fapp.cpp @@ -53,7 +53,7 @@ FApplication::FApplication (int& _argc, char* _argv[]) , new_mouse_position() { assert ( ! rootObj - && "FApplication: There should be only one application object" ); + && "FApplication: There should be only one application object" ); rootObj = this; if ( ! (_argc && _argv) ) @@ -177,8 +177,8 @@ bool FApplication::sendEvent(FObject* receiver, FEvent* event) // block events for widgets in non modal windows if ( window - && (window->getFlags() & fc::modal) == 0 - && ! window->isMenuWidget() ) + && (window->getFlags() & fc::modal) == 0 + && ! window->isMenuWidget() ) { switch ( event->type() ) { @@ -202,9 +202,9 @@ bool FApplication::sendEvent(FObject* receiver, FEvent* event) } // throw away mouse events to disabled widgets - if ( event->type() >= fc::MouseDown_Event - && event->type() <= fc::MouseMove_Event - && ! widget->isEnabled() ) + if ( event->type() >= fc::MouseDown_Event + && event->type() <= fc::MouseMove_Event + && ! widget->isEnabled() ) return false; // sends event event directly to receiver @@ -540,9 +540,9 @@ void FApplication::processKeyboardEvent() } // read the rest from the fifo buffer - while ( ! widget->isKeyTimeout(&time_keypressed, key_timeout) - && fifo_offset > 0 - && key != NEED_MORE_DATA ) + while ( ! widget->isKeyTimeout(&time_keypressed, key_timeout) + && fifo_offset > 0 + && key != NEED_MORE_DATA ) { key = FTerm::parseKeyString(fifo_buf, fifo_buf_size, &time_keypressed); @@ -649,8 +649,8 @@ void FApplication::processKeyboardEvent() sendEvent (widget, &k_press_ev); if ( ! open_menu - && ! k_press_ev.isAccepted() - && ! k_down_ev.isAccepted() ) + && ! k_press_ev.isAccepted() + && ! k_down_ev.isAccepted() ) { // switch to a specific dialog with Meta + 1..9 bool accpt = processDialogSwitchAccelerator(); @@ -692,11 +692,11 @@ void FApplication::processKeyboardEvent() } // special case: Esc key - if ( fifo_in_use - && fifo_offset == 1 - && fifo_buf[0] == 0x1b - && fifo_buf[1] == 0x00 - && isKeyTimeout(&time_keypressed, key_timeout) ) + if ( fifo_in_use + && fifo_offset == 1 + && fifo_buf[0] == 0x1b + && fifo_buf[1] == 0x00 + && isKeyTimeout(&time_keypressed, key_timeout) ) { FKeyEvent k_press_ev (fc::KeyPress_Event, fc::Fkey_escape); sendEvent (widget, &k_press_ev); @@ -1017,8 +1017,8 @@ bool FApplication::processAccelerator (FWidget*& widget) bool accpt = false; if ( widget - && widget->accelerator_list - && ! widget->accelerator_list->empty() ) + && widget->accelerator_list + && ! widget->accelerator_list->empty() ) { FWidget::Accelerators::const_iterator iter, end; iter = widget->accelerator_list->begin(); @@ -1083,8 +1083,8 @@ void FApplication::getX11ButtonState (int button) case button1_pressed: case button1_pressed_move: if ( mouse_position == new_mouse_position - && x11_button_state == all_buttons_released - && ! isKeyTimeout(&time_mousepressed, dblclick_interval) ) + && x11_button_state == all_buttons_released + && ! isKeyTimeout(&time_mousepressed, dblclick_interval) ) { time_mousepressed.tv_sec = 0; time_mousepressed.tv_usec = 0; @@ -1190,20 +1190,20 @@ bool FApplication::parseX11Mouse() if ( (x11_mouse[0] & key_ctrl) == key_ctrl ) b_state.control_button = Pressed; - if ( (x11_mouse[0] & button_mask) >= button1_pressed_move - && (x11_mouse[0] & button_mask) <= button3_pressed_move - && mouse_position != *zero_point ) + if ( (x11_mouse[0] & button_mask) >= button1_pressed_move + && (x11_mouse[0] & button_mask) <= button3_pressed_move + && mouse_position != *zero_point ) { b_state.mouse_moved = true; } getX11ButtonState (x11_mouse[0] & button_mask); - if ( uChar(x11_mouse[1]) == mouse_position.getX() + 0x20 - && uChar(x11_mouse[2]) == mouse_position.getY() + 0x20 - && b_state.wheel_up != Pressed - && b_state.wheel_down != Pressed - && uChar(x11_mouse[0]) == x11_button_state ) + if ( uChar(x11_mouse[1]) == mouse_position.getX() + 0x20 + && uChar(x11_mouse[2]) == mouse_position.getY() + 0x20 + && b_state.wheel_up != Pressed + && b_state.wheel_down != Pressed + && uChar(x11_mouse[0]) == x11_button_state ) { return false; } @@ -1285,9 +1285,9 @@ bool FApplication::parseSGRMouse() if ( (button & key_ctrl) == key_ctrl ) b_state.control_button = Pressed; - if ( (button & button_mask) >= button1_move - && (button & button_mask) <= button3_move - && mouse_position != *zero_point ) + if ( (button & button_mask) >= button1_move + && (button & button_mask) <= button3_move + && mouse_position != *zero_point ) { b_state.mouse_moved = true; } @@ -1299,8 +1299,8 @@ bool FApplication::parseSGRMouse() case button1: case button1_move: if ( mouse_position == new_mouse_position - && (((x11_button_state & 0x80) >> 2) + 'M') == released - && ! isKeyTimeout(&time_mousepressed, dblclick_interval) ) + && (((x11_button_state & 0x80) >> 2) + 'M') == released + && ! isKeyTimeout(&time_mousepressed, dblclick_interval) ) { time_mousepressed.tv_sec = 0; time_mousepressed.tv_usec = 0; @@ -1483,9 +1483,9 @@ bool FApplication::parseUrxvtMouse() if ( (button & key_ctrl) == key_ctrl ) b_state.control_button = Pressed; - if ( (button & button_mask) >= button1_pressed_move - && (button & button_mask) <= button3_pressed_move - && mouse_position != *zero_point ) + if ( (button & button_mask) >= button1_pressed_move + && (button & button_mask) <= button3_pressed_move + && mouse_position != *zero_point ) { b_state.mouse_moved = true; } @@ -1599,17 +1599,17 @@ void FApplication::processMouseEvent() bool Event = false; #ifdef F_HAVE_LIBGPM - if ( ! gpmMouseEvent - && x11_mouse[0] == '\0' - && sgr_mouse[0] == '\0' - && urxvt_mouse[0] == '\0' ) + if ( ! gpmMouseEvent + && x11_mouse[0] == '\0' + && sgr_mouse[0] == '\0' + && urxvt_mouse[0] == '\0' ) { return; } #else - if ( x11_mouse[0] == '\0' - && sgr_mouse[0] == '\0' - && urxvt_mouse[0] == '\0' ) + if ( x11_mouse[0] == '\0' + && sgr_mouse[0] == '\0' + && urxvt_mouse[0] == '\0' ) { return; } @@ -1634,13 +1634,13 @@ void FApplication::processMouseEvent() const FPoint& mouse_position = getMousePos(); - if ( ! clicked_widget - && ( b_state.left_button == Pressed - || b_state.left_button == DoubleClick - || b_state.right_button == Pressed - || b_state.middle_button == Pressed - || b_state.wheel_up == Pressed - || b_state.wheel_down == Pressed ) ) + if ( ! clicked_widget + && ( b_state.left_button == Pressed + || b_state.left_button == DoubleClick + || b_state.right_button == Pressed + || b_state.middle_button == Pressed + || b_state.wheel_up == Pressed + || b_state.wheel_down == Pressed ) ) { // determine the window object on the current click position FWidget* window = FWindow::getWindowWidgetAt (mouse_position); @@ -1694,9 +1694,9 @@ void FApplication::processMouseEvent() } // unselected menu bar item - if ( ! open_menu && getMenuBar() - && getMenuBar()->hasSelectedItem() - && ! b_state.mouse_moved ) + if ( ! open_menu && getMenuBar() + && getMenuBar()->hasSelectedItem() + && ! b_state.mouse_moved ) { if ( ! getMenuBar()->getTermGeometry().contains(mouse_position) ) { @@ -1789,8 +1789,8 @@ void FApplication::processMouseEvent() , fc::LeftButton | key_state ); FWidget* released_widget = clicked_widget; - if ( b_state.right_button != Pressed - && b_state.middle_button != Pressed ) + if ( b_state.right_button != Pressed + && b_state.middle_button != Pressed ) clicked_widget = 0; sendEvent (released_widget, &m_up_ev); @@ -1812,8 +1812,8 @@ void FApplication::processMouseEvent() , fc::RightButton | key_state ); FWidget* released_widget = clicked_widget; - if ( b_state.left_button != Pressed - && b_state.middle_button != Pressed ) + if ( b_state.left_button != Pressed + && b_state.middle_button != Pressed ) clicked_widget = 0; sendEvent (released_widget, &m_up_ev); @@ -1839,8 +1839,8 @@ void FApplication::processMouseEvent() , fc::MiddleButton | key_state ); FWidget* released_widget = clicked_widget; - if ( b_state.right_button != Pressed - && b_state.left_button != Pressed ) + if ( b_state.right_button != Pressed + && b_state.left_button != Pressed ) { clicked_widget = 0; } @@ -1915,9 +1915,9 @@ int FApplication::processTimerEvent() while ( iter != end ) { - if ( ! (*iter).id - || ! (*iter).object - || currentTime < (*iter).timeout ) // no timer expired + if ( ! (*iter).id + || ! (*iter).object + || currentTime < (*iter).timeout ) // no timer expired break; (*iter).timeout += (*iter).interval; diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 168fa9b7..355d47ce 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -197,8 +197,8 @@ bool FButton::setFlat (bool on) bool FButton::setShadow (bool on) { if ( on - && (Encoding != fc::VT100 || isTeraTerm() ) - && Encoding != fc::ASCII ) + && (Encoding != fc::VT100 || isTeraTerm() ) + && Encoding != fc::ASCII ) flags |= fc::shadow; else flags &= ~fc::shadow; @@ -526,7 +526,6 @@ void FButton::draw() is_Flat = isFlat(); is_NonFlatShadow = ((flags & (fc::shadow+fc::flat)) == fc::shadow); is_NoUnderline = ((flags & fc::no_underline) != 0); - updateVTerm(false); if ( isMonochron() ) setReverse(true); @@ -610,9 +609,9 @@ void FButton::draw() if ( is_Flat && ! button_down ) drawFlatBorder(); - if ( ! button_down - && ! isNewFont() - && (is_Flat || ! hasShadow() || isMonochron()) ) + if ( ! button_down + && ! isNewFont() + && (is_Flat || ! hasShadow() || isMonochron()) ) { // clear the right █ from button down if ( parent_widget ) @@ -725,7 +724,6 @@ void FButton::draw() if ( isMonochron() ) setReverse(false); - updateVTerm(true); delete[] ButtonText; if ( is_Focus && getStatusBar() ) diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index a0d9525d..a344d7ed 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -382,9 +382,9 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, void*) while ( iter != end ) { - if ( (*iter) != button - && (*iter)->isChecked() - && isRadioButton(*iter) ) + if ( (*iter) != button + && (*iter)->isChecked() + && isRadioButton(*iter) ) { (*iter)->unsetChecked(); @@ -447,8 +447,6 @@ void FButtonGroup::setHotkeyAccelerator() //---------------------------------------------------------------------- void FButtonGroup::draw() { - updateVTerm(false); - if ( isMonochron() ) setReverse(true); @@ -461,8 +459,6 @@ void FButtonGroup::draw() if ( isMonochron() ) setReverse(false); - - updateVTerm(true); } //---------------------------------------------------------------------- diff --git a/src/fcheckbox.cpp b/src/fcheckbox.cpp index 03c2d1d0..2ce6aabf 100644 --- a/src/fcheckbox.cpp +++ b/src/fcheckbox.cpp @@ -40,10 +40,8 @@ void FCheckBox::init() //---------------------------------------------------------------------- void FCheckBox::draw() { - updateVTerm(false); drawCheckButton(); drawLabel(); - updateVTerm(true); FToggleButton::draw(); } diff --git a/src/fconfig.h b/src/fconfig.h index a37b0fa6..f8da80c5 100644 --- a/src/fconfig.h +++ b/src/fconfig.h @@ -1,6 +1,6 @@ #ifndef _SRC_FCONFIG_H #define _SRC_FCONFIG_H 1 - + /* src/fconfig.h. Generated automatically at end of configure. */ /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ @@ -171,6 +171,6 @@ #ifndef F_VERSION #define F_VERSION "0.3.0" #endif - + /* once: _SRC_FCONFIG_H */ #endif diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 5bfe5b25..1259b2fe 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -279,9 +279,9 @@ void FDialog::setPos (int x, int y, bool) // set the cursor to the focus widget FWidget* focus_widget = FWidget::getFocusWidget(); - if ( focus_widget - && focus_widget->isVisible() - && focus_widget->hasVisibleCursor() ) + if ( focus_widget + && focus_widget->isVisible() + && focus_widget->hasVisibleCursor() ) { FPoint cursor_pos = focus_widget->getCursorPos(); focus_widget->setCursorPos(cursor_pos); @@ -361,9 +361,9 @@ void FDialog::setSize (int w, int h, bool adjust) // set the cursor to the focus widget FWidget* focus_widget = FWidget::getFocusWidget(); - if ( focus_widget - && focus_widget->isVisible() - && focus_widget->hasVisibleCursor() ) + if ( focus_widget + && focus_widget->isVisible() + && focus_widget->hasVisibleCursor() ) { FPoint cursor_pos = focus_widget->getCursorPos(); focus_widget->setCursorPos(cursor_pos); @@ -522,8 +522,8 @@ void FDialog::onKeyPress (FKeyEvent* ev) if ( this == getMainWidget() ) return; - if ( ev->key() == fc::Fkey_escape - || ev->key() == fc::Fkey_escape_mintty ) + if ( ev->key() == fc::Fkey_escape + || ev->key() == fc::Fkey_escape_mintty ) { ev->accept(); @@ -574,7 +574,7 @@ void FDialog::onMouseDown (FMouseEvent* ev) redraw(); // click on titlebar menu button - if ( mouse_x < 4 && mouse_y == 1 ) + if ( mouse_x < 4 && mouse_y == 1 ) openMenu(); else if ( mouse_x > getWidth()-zoom_btn && mouse_y == 1 ) { @@ -585,9 +585,9 @@ void FDialog::onMouseDown (FMouseEvent* ev) // click on the lower right resize corner if ( isResizeable() - && ( (mouse_x == getWidth() && mouse_y == getHeight()) - || (mouse_x == getWidth()-1 && mouse_y == getHeight()) - || (mouse_x == getWidth() && mouse_y == getHeight()-1) ) ) + && ( (mouse_x == getWidth() && mouse_y == getHeight()) + || (mouse_x == getWidth()-1 && mouse_y == getHeight()) + || (mouse_x == getWidth() && mouse_y == getHeight()-1) ) ) { resize_click_pos = ev->getTermPos(); FPoint lower_right_pos = getTermGeometry().getLowerRightPos(); @@ -608,7 +608,7 @@ void FDialog::onMouseDown (FMouseEvent* ev) else // ev->getButton() != fc::LeftButton { // click on titlebar menu button - if ( mouse_x < 4 && mouse_y == 1 && dialog_menu->isVisible() ) + if ( mouse_x < 4 && mouse_y == 1 && dialog_menu->isVisible() ) leaveMenu(); // close menu // cancel resize @@ -664,10 +664,10 @@ void FDialog::onMouseUp (FMouseEvent* ev) int titlebar_x = titlebar_click_pos.getX(); int titlebar_y = titlebar_click_pos.getY(); - if ( ! titlebar_click_pos.isNull() - && titlebar_x > getTermX() + 3 - && titlebar_x < getTermX() + getWidth() - && titlebar_y == getTermY() ) + if ( ! titlebar_click_pos.isNull() + && titlebar_x > getTermX() + 3 + && titlebar_x < getTermX() + getWidth() + && titlebar_y == getTermY() ) { FPoint deltaPos = ev->getTermPos() - titlebar_click_pos; move (deltaPos); @@ -675,17 +675,17 @@ void FDialog::onMouseUp (FMouseEvent* ev) } // click on titlebar menu button - if ( mouse_x < 4 - && mouse_y == 1 - && dialog_menu->isVisible() - && ! dialog_menu->hasSelectedItem() ) + if ( mouse_x < 4 + && mouse_y == 1 + && dialog_menu->isVisible() + && ! dialog_menu->hasSelectedItem() ) { // Sets focus to the first item selectFirstMenuItem(); } else if ( mouse_x > getWidth() - zoom_btn - && mouse_y == 1 - && zoom_button_pressed ) + && mouse_y == 1 + && zoom_button_pressed ) { // zoom to maximum or restore the window size zoomWindow(); @@ -772,8 +772,8 @@ void FDialog::onMouseMove (FMouseEvent* ev) // Mouse event handover to the menu const FRect& menu_geometry = dialog_menu->getTermGeometry(); - if ( dialog_menu->getCount() > 0 - && menu_geometry.contains(ev->getTermPos()) ) + if ( dialog_menu->getCount() > 0 + && menu_geometry.contains(ev->getTermPos()) ) { const FPoint& g = ev->getTermPos(); const FPoint& p = dialog_menu->termToWidgetPos(g); @@ -795,7 +795,7 @@ void FDialog::onMouseMove (FMouseEvent* ev) // resize the dialog if ( isResizeable() && ! resize_click_pos.isNull() - && ev->getTermPos() != getTermGeometry().getLowerRightPos() ) + && ev->getTermPos() != getTermGeometry().getLowerRightPos() ) { FWidget* r = getRootWidget(); resize_click_pos = ev->getTermPos(); @@ -872,9 +872,9 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev) close(); } else if ( isResizeable() - && mouse_x >= 4 - && mouse_x <= getWidth() - zoom_btn - && mouse_y == 1 ) + && mouse_x >= 4 + && mouse_x <= getWidth() - zoom_btn + && mouse_y == 1 ) { // double click on titlebar zoomWindow(); // window zoom/unzoom @@ -908,8 +908,8 @@ void FDialog::onWindowActive (FEvent*) FWidget* win_focus = getWindowFocusWidget(); if ( win_focus - && win_focus->isVisible() - && win_focus->isShown() ) + && win_focus->isVisible() + && win_focus->isShown() ) { win_focus->setFocus(); win_focus->redraw(); @@ -1007,7 +1007,6 @@ void FDialog::draw() tooltip = 0; } - updateVTerm(false); // fill the background setColor(); @@ -1024,8 +1023,6 @@ void FDialog::draw() if ( isMonochron() ) setReverse(false); - - updateVTerm(true); } //---------------------------------------------------------------------- @@ -1138,7 +1135,7 @@ void FDialog::drawBorder() int y2 = 1 + getHeight() - 1; if ( (getMoveSizeWidget() == this || ! resize_click_pos.isNull()) - && ! isZoomed() ) + && ! isZoomed() ) setColor (wc.dialog_resize_fg, getBackgroundColor()); else setColor(); diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index 134536cc..a23565ea 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -260,10 +260,10 @@ int FFileDialog::readDir() if ( next->d_name[0] == '.' && next->d_name[1] == '\0' ) continue; - if ( ! show_hidden - && next->d_name[0] == '.' - && next->d_name[1] != '\0' - && next->d_name[1] != '.' ) + if ( ! show_hidden + && next->d_name[0] == '.' + && next->d_name[1] != '\0' + && next->d_name[1] != '.' ) { continue; } @@ -721,8 +721,8 @@ void FFileDialog::printPath (const FString& txt) //---------------------------------------------------------------------- void FFileDialog::cb_processActivate (FWidget*, void*) { - if ( filename->getText().includes('*') - || filename->getText().includes('?') ) + if ( filename->getText().includes('*') + || filename->getText().includes('?') ) { setFilter(filename->getText()); readDir(); @@ -734,9 +734,9 @@ void FFileDialog::cb_processActivate (FWidget*, void*) readDir(); filebrowser->redraw(); } - else if ( filename->getText().trim() == FString("..") - || filename->getText().includes('/') - || filename->getText().includes('~') ) + else if ( filename->getText().trim() == FString("..") + || filename->getText().includes('/') + || filename->getText().includes('~') ) { changeDir(filename->getText().trim()); } diff --git a/src/flabel.cpp b/src/flabel.cpp index ae54186e..20fc371d 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -68,9 +68,9 @@ void FLabel::setAccelWidget (FWidget* widget) //---------------------------------------------------------------------- void FLabel::setAlignment (uInt align) { - if ( align != fc::alignLeft - && align != fc::alignCenter - && align != fc::alignRight ) + if ( align != fc::alignLeft + && align != fc::alignCenter + && align != fc::alignRight ) alignment = fc::alignLeft; else alignment = align; @@ -397,8 +397,8 @@ void FLabel::printLine ( wchar_t*& line { if ( ! std::iswprint(wint_t(line[z])) ) { - if ( ! isNewFont() && ( int(line[z]) < fc::NF_rev_left_arrow2 - || int(line[z]) > fc::NF_check_mark ) ) + if ( ! isNewFont() && ( int(line[z]) < fc::NF_rev_left_arrow2 + || int(line[z]) > fc::NF_check_mark ) ) { line[z] = L' '; } @@ -452,8 +452,6 @@ void FLabel::draw() if ( text.isNull() || text.isEmpty() ) return; - updateVTerm(false); - if ( isMonochron() ) { setReverse(true); @@ -529,6 +527,4 @@ void FLabel::draw() if ( hasEmphasis() ) setBold(false); } - - updateVTerm(true); } diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 2da94386..250bb81d 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -136,9 +136,9 @@ bool FLineEdit::setFocus (bool on) //---------------------------------------------------------------------- bool FLineEdit::setShadow (bool on) { - if ( on - && (Encoding != fc::VT100 || isTeraTerm() ) - && Encoding != fc::ASCII ) + if ( on + && (Encoding != fc::VT100 || isTeraTerm() ) + && Encoding != fc::ASCII ) flags |= fc::shadow; else flags &= ~fc::shadow; @@ -373,9 +373,9 @@ void FLineEdit::onKeyPress (FKeyEvent* ev) } // end of switch - if ( ev->isAccepted() - && key != fc::Fkey_return - && key != fc::Fkey_enter ) + if ( ev->isAccepted() + && key != fc::Fkey_return + && key != fc::Fkey_enter ) { drawInputField(); updateTerminal(); @@ -654,8 +654,8 @@ void FLineEdit::adjustLabel() if ( hasHotkey() ) label_length--; - assert ( label_orientation == label_above - || label_orientation == label_left ); + assert ( label_orientation == label_above + || label_orientation == label_left ); switch ( label_orientation ) { @@ -748,8 +748,6 @@ void FLineEdit::drawInputField() int active_focus = fc::active + fc::focus; isActiveFocus = ((flags & active_focus) == active_focus); isShadow = ((flags & fc::shadow) != 0 ); - - updateVTerm(false); setPrintPos (1, 1); if ( isMonochron() ) @@ -807,8 +805,6 @@ void FLineEdit::drawInputField() // set the cursor to the first pos. setCursorPos (2+cursor_pos-text_offset, 1); - - updateVTerm(true); } //---------------------------------------------------------------------- diff --git a/src/flistbox.cpp b/src/flistbox.cpp index dfe9efe6..faa4c091 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -537,9 +537,9 @@ void FListBox::onKeyPress (FKeyEvent* ev) for (uInt i=0; i < end; i++) { - if ( ! inc_found - && inc_search.toLower() - == data[i].getText().left(inc_len+1).toLower() ) + if ( ! inc_found + && inc_search.toLower() + == data[i].getText().left(inc_len+1).toLower() ) { setCurrentItem(int(i+1)); inc_found = true; @@ -624,9 +624,9 @@ void FListBox::onKeyPress (FKeyEvent* ev) for (uInt i=0; i < end; i++) { - if ( ! inc_found - && inc_search.toLower() - == data[i].getText().left(inc_len).toLower() ) + if ( ! inc_found + && inc_search.toLower() + == data[i].getText().left(inc_len).toLower() ) { setCurrentItem(int(i+1)); inc_found = true; @@ -683,8 +683,8 @@ void FListBox::onMouseDown (FMouseEvent* ev) { int yoffset_before, mouse_x, mouse_y; - if ( ev->getButton() != fc::LeftButton - && ev->getButton() != fc::RightButton ) + if ( ev->getButton() != fc::LeftButton + && ev->getButton() != fc::RightButton ) { return; } @@ -710,8 +710,8 @@ void FListBox::onMouseDown (FMouseEvent* ev) mouse_x = ev->getX(); mouse_y = ev->getY(); - if ( mouse_x > 1 && mouse_x < getWidth() - && mouse_y > 1 && mouse_y < getHeight() ) + if ( mouse_x > 1 && mouse_x < getWidth() + && mouse_y > 1 && mouse_y < getHeight() ) { current = yoffset + mouse_y - 1; @@ -768,8 +768,8 @@ void FListBox::onMouseUp (FMouseEvent* ev) int mouse_x = ev->getX(); int mouse_y = ev->getY(); - if ( mouse_x > 1 && mouse_x < getWidth() - && mouse_y > 1 && mouse_y < getHeight() ) + if ( mouse_x > 1 && mouse_x < getWidth() + && mouse_y > 1 && mouse_y < getHeight() ) { processChanged(); @@ -784,8 +784,8 @@ void FListBox::onMouseMove (FMouseEvent* ev) { int current_before, yoffset_before, mouse_x, mouse_y; - if ( ev->getButton() != fc::LeftButton - && ev->getButton() != fc::RightButton ) + if ( ev->getButton() != fc::LeftButton + && ev->getButton() != fc::RightButton ) { return; } @@ -798,8 +798,8 @@ void FListBox::onMouseMove (FMouseEvent* ev) mouse_x = ev->getX(); mouse_y = ev->getY(); - if ( mouse_x > 1 && mouse_x < getWidth() - && mouse_y > 1 && mouse_y < getHeight() ) + if ( mouse_x > 1 && mouse_x < getWidth() + && mouse_y > 1 && mouse_y < getHeight() ) { current = yoffset + mouse_y - 1; @@ -809,9 +809,9 @@ void FListBox::onMouseMove (FMouseEvent* ev) inc_search.clear(); // handle multiple selections - if ( ev->getButton() == fc::RightButton - && isMultiSelection() - && current_before != current ) + if ( ev->getButton() == fc::RightButton + && isMultiSelection() + && current_before != current ) { int from, to; @@ -859,7 +859,7 @@ void FListBox::onMouseMove (FMouseEvent* ev) { // drag up if ( drag_scroll != FListBox::noScroll - && scroll_distance < getHeight()-2 ) + && scroll_distance < getHeight()-2 ) scroll_distance++; if ( ! scroll_timer && current > 1 ) @@ -883,7 +883,7 @@ void FListBox::onMouseMove (FMouseEvent* ev) { // drag down if ( drag_scroll != FListBox::noScroll - && scroll_distance < getHeight()-2 ) + && scroll_distance < getHeight()-2 ) scroll_distance++; if ( ! scroll_timer && current < int(getCount()) ) @@ -924,8 +924,8 @@ void FListBox::onMouseDoubleClick (FMouseEvent* ev) mouse_x = ev->getX(); mouse_y = ev->getY(); - if ( mouse_x > 1 && mouse_x < getWidth() - && mouse_y > 1 && mouse_y < getHeight() ) + if ( mouse_x > 1 && mouse_x < getWidth() + && mouse_y > 1 && mouse_y < getHeight() ) { if ( yoffset + mouse_y - 1 > int(getCount()) ) return; @@ -1242,8 +1242,8 @@ void FListBox::cb_VBarChange (FWidget*, void*) if ( isVisible() ) drawList(); - if ( scrollType >= FScrollbar::scrollStepBackward - && scrollType <= FScrollbar::scrollPageForward ) + if ( scrollType >= FScrollbar::scrollStepBackward + && scrollType <= FScrollbar::scrollPageForward ) { vbar->setValue (yoffset); @@ -1340,8 +1340,8 @@ void FListBox::cb_HBarChange (FWidget*, void*) flush_out(); } - if ( scrollType >= FScrollbar::scrollStepBackward - && scrollType <= FScrollbar::scrollWheelDown ) + if ( scrollType >= FScrollbar::scrollStepBackward + && scrollType <= FScrollbar::scrollWheelDown ) { hbar->setValue (xoffset); @@ -1453,7 +1453,6 @@ void FListBox::draw() if ( current < 1 ) current = 1; - updateVTerm(false); setColor(); if ( isMonochron() ) @@ -1480,8 +1479,6 @@ void FListBox::draw() if ( isMonochron() ) setReverse(false); - updateVTerm(true); - if ( vbar->isVisible() ) vbar->redraw(); @@ -1550,9 +1547,9 @@ void FListBox::drawList() if ( end > getCount() ) end = getCount(); - if ( last_yoffset >= 0 - && last_yoffset == yoffset - && last_current != current ) + if ( last_yoffset >= 0 + && last_yoffset == yoffset + && last_current != current ) { // speed up: redraw only the changed rows uInt last_pos = uInt(current - yoffset) - 1; @@ -1561,8 +1558,6 @@ void FListBox::drawList() end = std::max(last_pos, current_pos)+1; } - updateVTerm(false); - for (uInt y=start; y < end; y++) { setPrintPos (2, 2 + int(y)); @@ -1784,7 +1779,6 @@ void FListBox::drawList() setReverse(false); unsetBold(); - updateVTerm(true); last_yoffset = yoffset; last_current = current; } diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 2804986f..5f75e924 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -329,17 +329,17 @@ void FMenu::onMouseDown (FMouseEvent* ev) mouse_x = mouse_pos.getX(); mouse_y = mouse_pos.getY(); - if ( mouse_x >= x1 - && mouse_x < x2 - && mouse_y == y ) + if ( mouse_x >= x1 + && mouse_x < x2 + && mouse_y == y ) { // Mouse pointer over item if ( hasSelectedItem() ) { FMenuItem* sel_item = getSelectedItem(); - if ( sel_item - && sel_item->hasMenu() - && sel_item->getMenu() == open_sub_menu ) + if ( sel_item + && sel_item->hasMenu() + && sel_item->getMenu() == open_sub_menu ) { if ( sel_item != *iter ) hideSubMenus(); @@ -437,9 +437,9 @@ void FMenu::onMouseUp (FMouseEvent* ev) int mouse_x = mouse_pos.getX(); int mouse_y = mouse_pos.getY(); - if ( mouse_x >= x1 - && mouse_x < x2 - && mouse_y == y ) + if ( mouse_x >= x1 + && mouse_x < x2 + && mouse_y == y ) { // Mouse pointer over item if ( (*iter)->hasMenu() ) @@ -531,9 +531,9 @@ void FMenu::onMouseMove (FMouseEvent* ev) mouse_over_supermenu = true; } - if ( getMenuBar() - && isMenuBar(getMenuBar()) - && getMenuBar()->getTermGeometry().contains(ev->getTermPos()) ) + if ( getMenuBar() + && isMenuBar(getMenuBar()) + && getMenuBar()->getTermGeometry().contains(ev->getTermPos()) ) { mouse_over_menubar = true; } @@ -547,13 +547,13 @@ void FMenu::onMouseMove (FMouseEvent* ev) mouse_x = mouse_pos.getX(); mouse_y = mouse_pos.getY(); - if ( mouse_x >= x1 - && mouse_x < x2 - && mouse_y == y ) + if ( mouse_x >= x1 + && mouse_x < x2 + && mouse_y == y ) { - if ( (*iter)->isEnabled() - && ! (*iter)->isSelected() - && ! (*iter)->isSeparator() ) + if ( (*iter)->isEnabled() + && ! (*iter)->isSelected() + && ! (*iter)->isSeparator() ) { // Mouse pointer over item FWidget* focused_widget = getFocusWidget(); @@ -586,9 +586,9 @@ void FMenu::onMouseMove (FMouseEvent* ev) else { if ( mouse_over_menu - && (*iter)->isEnabled() - && (*iter)->isSelected() - && ! mouse_over_submenu ) + && (*iter)->isEnabled() + && (*iter)->isSelected() + && ! mouse_over_submenu ) { // Unselect selected item without mouse focus (*iter)->unsetSelected(); @@ -717,9 +717,9 @@ void FMenu::cb_menuitem_toggled (FWidget* widget, void*) while ( iter != end ) { - if ( (*iter) != menuitem - && (*iter)->isChecked() - && isRadioMenuItem(*iter) ) + if ( (*iter) != menuitem + && (*iter)->isChecked() + && isRadioMenuItem(*iter) ) { (*iter)->unsetChecked(); } @@ -1218,7 +1218,6 @@ void FMenu::draw() { // fill the background setColor (wc.menu_active_fg, wc.menu_active_bg); - updateVTerm(false); if ( isMonochron() ) setReverse(true); @@ -1230,8 +1229,6 @@ void FMenu::draw() if ( isMonochron() ) setReverse(false); - - updateVTerm(true); } //---------------------------------------------------------------------- @@ -1381,9 +1378,9 @@ void FMenu::drawItems() if ( ! std::iswprint(wint_t(item_text[z])) ) { if ( ! isNewFont() - && ( int(item_text[z]) < fc::NF_rev_left_arrow2 - || int(item_text[z]) > fc::NF_check_mark ) - && ! charEncodable(uInt(item_text[z])) ) + && ( int(item_text[z]) < fc::NF_rev_left_arrow2 + || int(item_text[z]) > fc::NF_check_mark ) + && ! charEncodable(uInt(item_text[z])) ) { item_text[z] = L' '; } diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index ef9dade8..bc7c02a9 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -532,10 +532,10 @@ bool FMenuBar::selectNextItem() next_element = item_list.begin(); next = static_cast(*next_element); - } while ( ! next->isEnabled() - || ! next->acceptFocus() - || ! next->isVisible() - || next->isSeparator() ); + } while ( ! next->isEnabled() + || ! next->acceptFocus() + || ! next->isVisible() + || next->isSeparator() ); if ( next == *iter ) return false; @@ -599,10 +599,10 @@ bool FMenuBar::selectPrevItem() --prev_element; prev = static_cast(*prev_element); } - while ( ! prev->isEnabled() - || ! prev->acceptFocus() - || ! prev->isVisible() - || prev->isSeparator() ); + while ( ! prev->isEnabled() + || ! prev->acceptFocus() + || ! prev->isVisible() + || prev->isSeparator() ); if ( prev == *iter ) return false; @@ -744,7 +744,6 @@ void FMenuBar::drawItems() if ( item_list.empty() ) return; - updateVTerm(false); setPrintPos (1,1); if ( isMonochron() ) @@ -826,8 +825,9 @@ void FMenuBar::drawItems() if ( ! std::iswprint(wint_t(item_text[z])) ) { - if ( ! isNewFont() && ( int(item_text[z]) < fc::NF_rev_left_arrow2 - || int(item_text[z]) > fc::NF_check_mark ) ) + if ( ! isNewFont() + && ( int(item_text[z]) < fc::NF_rev_left_arrow2 + || int(item_text[z]) > fc::NF_check_mark ) ) { item_text[z] = L' '; } @@ -885,8 +885,6 @@ void FMenuBar::drawItems() if ( isMonochron() ) setReverse(false); - - updateVTerm(true); } //---------------------------------------------------------------------- diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 707fb575..92a7dce4 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -328,9 +328,9 @@ void FMenuItem::delAccelerator (FWidget* obj) { FWidget* root = getRootWidget(); - if ( root - && root->accelerator_list - && ! root->accelerator_list->empty() ) + if ( root + && root->accelerator_list + && ! root->accelerator_list->empty() ) { FWidget::Accelerators::iterator iter; iter = root->accelerator_list->begin(); diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index ac8477b8..244a8614 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -421,7 +421,6 @@ void FMessageBox::draw() int head_offset = 0; int center_x = 0; int msg_x = int((getWidth() - int(max_line_width)) / 2); // center the whole block - updateVTerm(false); if ( isMonochron() ) setReverse(true); @@ -454,8 +453,6 @@ void FMessageBox::draw() if ( isMonochron() ) setReverse(false); - - updateVTerm(true); } //---------------------------------------------------------------------- diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index 3761086d..d4d6acb2 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -1179,9 +1179,9 @@ inline bool FOptiAttr::colorChange (char_data*& term, char_data*& next) { if ( term && next ) { - return bool ( fake_reverse - || term->fg_color != next->fg_color - || term->bg_color != next->bg_color ); + return bool ( fake_reverse + || term->fg_color != next->fg_color + || term->bg_color != next->bg_color ); } return false; @@ -1315,8 +1315,8 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next) { if ( ansi_default_color ) { - if ( fg == Default && term->fg_color != Default - && bg == Default && term->bg_color != Default ) + if ( fg == Default && term->fg_color != Default + && bg == Default && term->bg_color != Default ) { setTermDefaultColor(term); } diff --git a/src/foptiattr.h b/src/foptiattr.h index a1d05183..f7f2f689 100644 --- a/src/foptiattr.h +++ b/src/foptiattr.h @@ -55,6 +55,9 @@ class FOptiAttr uChar transparent : 1; // transparent uChar trans_shadow : 1; // transparent shadow 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; // Constructor diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 3bfb722f..352d4b7f 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -404,9 +404,9 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew) std::strncpy (move_ptr, move_xy, sizeof(move_buf) - 1); move_time = F_cursor_address.duration; - if ( xold < 0 - || yold < 0 - || isWideMove (xold, yold, xnew, ynew) ) + if ( xold < 0 + || yold < 0 + || isWideMove (xold, yold, xnew, ynew) ) { return ( move_time < LONG_DURATION ) ? move_buf : 0; } @@ -429,8 +429,8 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew) { new_time = relativeMove (null_ptr, 0, yold, xnew, ynew); - if ( new_time < LONG_DURATION - && F_carriage_return.duration + new_time < move_time ) + if ( new_time < LONG_DURATION + && F_carriage_return.duration + new_time < move_time ) { method = 2; move_time = F_carriage_return.duration + new_time; @@ -442,8 +442,8 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew) { new_time = relativeMove (null_ptr, 0, 0, xnew, ynew); - if ( new_time < LONG_DURATION - && F_cursor_home.duration + new_time < move_time ) + if ( new_time < LONG_DURATION + && F_cursor_home.duration + new_time < move_time ) { method = 3; move_time = F_cursor_home.duration + new_time; @@ -455,8 +455,8 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew) { new_time = relativeMove (null_ptr, 0, screen_height-1, xnew, ynew); - if ( new_time < LONG_DURATION - && F_cursor_to_ll.duration + new_time < move_time ) + if ( new_time < LONG_DURATION + && F_cursor_to_ll.duration + new_time < move_time ) { method = 4; move_time = F_cursor_to_ll.duration + new_time; @@ -464,17 +464,17 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew) } // Method 5: left margin for wrap to right-hand side - if ( automatic_left_margin - && ! eat_nl_glitch - && yold > 0 - && F_cursor_left.cap ) + if ( automatic_left_margin + && ! eat_nl_glitch + && yold > 0 + && F_cursor_left.cap ) { new_time = relativeMove (null_ptr, screen_width-1, yold-1, xnew, ynew); - if ( new_time < LONG_DURATION - && F_carriage_return.cap - && F_carriage_return.duration - + F_cursor_left.duration + new_time < move_time ) + if ( new_time < LONG_DURATION + && F_carriage_return.cap + && F_carriage_return.duration + + F_cursor_left.duration + new_time < move_time ) { method = 5; move_time = F_carriage_return.duration @@ -861,7 +861,7 @@ int FOptiMove::relativeMove ( char*& move inline bool FOptiMove::isWideMove ( int xold, int yold , int xnew, int ynew ) { - return bool ( (xnew > MOVE_LIMIT) - && (xnew < screen_width - 1 - MOVE_LIMIT) - && (std::abs(xnew-xold) + std::abs(ynew-yold) > MOVE_LIMIT) ); + return bool ( (xnew > MOVE_LIMIT) + && (xnew < screen_width - 1 - MOVE_LIMIT) + && (std::abs(xnew-xold) + std::abs(ynew-yold) > MOVE_LIMIT) ); } diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index 1a001195..2c09ca9e 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -37,15 +37,12 @@ void FProgressbar::setPercentage (int percentage_value) else percentage = percentage_value; - updateVTerm(false); - if ( isVisible() ) { drawPercentage(); drawBar(); } - updateVTerm(true); updateTerminal(); } @@ -72,9 +69,9 @@ bool FProgressbar::setEnable (bool on) //---------------------------------------------------------------------- bool FProgressbar::setShadow (bool on) { - if ( on - && (Encoding != fc::VT100 || isTeraTerm() ) - && Encoding != fc::ASCII ) + if ( on + && (Encoding != fc::VT100 || isTeraTerm() ) + && Encoding != fc::ASCII ) flags |= fc::shadow; else flags &= ~fc::shadow; @@ -128,7 +125,6 @@ void FProgressbar::hide() //---------------------------------------------------------------------- void FProgressbar::reset() { - updateVTerm(false); percentage = -1; if ( isVisible() ) @@ -137,7 +133,6 @@ void FProgressbar::reset() drawBar(); } - updateVTerm(true); updateTerminal(); } @@ -146,14 +141,12 @@ void FProgressbar::reset() //---------------------------------------------------------------------- void FProgressbar::draw() { - updateVTerm(false); drawPercentage(); drawBar(); if ( (flags & fc::shadow) != 0 ) drawShadow (); - updateVTerm(true); flush_out(); } @@ -202,9 +195,9 @@ void FProgressbar::drawBar() if ( percentage > 0.0f && trunc(length) < bar_length ) { - if ( round(length) > trunc(length) - || isCygwinTerminal() - || getMaxColor() < 16 ) + if ( round(length) > trunc(length) + || isCygwinTerminal() + || getMaxColor() < 16 ) { if ( isMonochron() ) { diff --git a/src/fradiobutton.cpp b/src/fradiobutton.cpp index 6f79494b..1ec31e75 100644 --- a/src/fradiobutton.cpp +++ b/src/fradiobutton.cpp @@ -41,10 +41,8 @@ void FRadioButton::init() //---------------------------------------------------------------------- void FRadioButton::draw() { - updateVTerm(false); drawRadioButton(); drawLabel(); - updateVTerm(true); FToggleButton::draw(); } diff --git a/src/frect.cpp b/src/frect.cpp index ba219c88..a34a9e9e 100644 --- a/src/frect.cpp +++ b/src/frect.cpp @@ -180,8 +180,8 @@ bool FRect::contains (const FRect& r) const //---------------------------------------------------------------------- bool FRect::overlap (const FRect &r) const { - return ( std::max(X1, r.X1) <= std::min(X2, r.X2) - && std::max(Y1, r.Y1) <= std::min(Y2, r.Y2) ); + return ( std::max(X1, r.X1) <= std::min(X2, r.X2) + && std::max(Y1, r.Y1) <= std::min(Y2, r.Y2) ); } //---------------------------------------------------------------------- diff --git a/src/fscrollbar.cpp b/src/fscrollbar.cpp index 193b28af..d90333a0 100644 --- a/src/fscrollbar.cpp +++ b/src/fscrollbar.cpp @@ -289,7 +289,6 @@ void FScrollbar::drawBar() if ( slider_pos != current_slider_pos ) { int z; - updateVTerm(false); if ( bar_orientation == fc::vertical ) { @@ -392,8 +391,6 @@ void FScrollbar::drawBar() if ( isMonochron() ) setReverse(false); - - updateVTerm(true); } } @@ -402,8 +399,8 @@ void FScrollbar::onMouseDown (FMouseEvent* ev) { int mouse_x, mouse_y; - if ( ev->getButton() != fc::LeftButton - && ev->getButton() != fc::MiddleButton ) + if ( ev->getButton() != fc::LeftButton + && ev->getButton() != fc::MiddleButton ) return; if ( min == max ) @@ -443,8 +440,8 @@ void FScrollbar::onMouseDown (FMouseEvent* ev) if ( slider_click_pos > 0 ) scroll_type = FScrollbar::scrollJump; - if ( scroll_type == FScrollbar::scrollPageBackward - || scroll_type == FScrollbar::scrollPageForward ) + if ( scroll_type == FScrollbar::scrollPageBackward + || scroll_type == FScrollbar::scrollPageForward ) { if ( bar_orientation == fc::vertical ) slider_click_stop_pos = mouse_y - 2; @@ -457,8 +454,8 @@ void FScrollbar::onMouseDown (FMouseEvent* ev) else slider_click_stop_pos = -1; - if ( scroll_type >= FScrollbar::scrollStepBackward - && scroll_type <= FScrollbar::scrollPageForward ) + if ( scroll_type >= FScrollbar::scrollStepBackward + && scroll_type <= FScrollbar::scrollPageForward ) { processScroll(); threshold_reached = false; @@ -469,8 +466,8 @@ void FScrollbar::onMouseDown (FMouseEvent* ev) //---------------------------------------------------------------------- void FScrollbar::onMouseUp (FMouseEvent* ev) { - if ( ev->getButton() != fc::LeftButton - && ev->getButton() != fc::MiddleButton ) + if ( ev->getButton() != fc::LeftButton + && ev->getButton() != fc::MiddleButton ) return; slider_click_pos = -1; @@ -487,8 +484,8 @@ void FScrollbar::onMouseMove (FMouseEvent* ev) { int mouse_x, mouse_y, new_scroll_type; - if ( ev->getButton() != fc::LeftButton - && ev->getButton() != fc::MiddleButton ) + if ( ev->getButton() != fc::LeftButton + && ev->getButton() != fc::MiddleButton ) return; mouse_x = ev->getX(); @@ -531,8 +528,8 @@ void FScrollbar::onMouseMove (FMouseEvent* ev) } } - if ( mouse_x < 1 || mouse_x > getWidth() - || mouse_y < 1 || mouse_y > getHeight() ) + if ( mouse_x < 1 || mouse_x > getWidth() + || mouse_y < 1 || mouse_y > getHeight() ) { delOwnTimer(); } @@ -579,10 +576,10 @@ void FScrollbar::onTimer (FTimerEvent*) addTimer(repeat_time); } - if ( ( scroll_type == FScrollbar::scrollPageBackward + if ( ( scroll_type == FScrollbar::scrollPageBackward && slider_pos < slider_click_stop_pos ) - || ( scroll_type == FScrollbar::scrollPageForward - && slider_pos+slider_length > slider_click_stop_pos ) ) + || ( scroll_type == FScrollbar::scrollPageForward + && slider_pos+slider_length > slider_click_stop_pos ) ) { delOwnTimer(); return; @@ -604,11 +601,9 @@ void FScrollbar::init() //---------------------------------------------------------------------- void FScrollbar::draw() { - updateVTerm(false); drawButtons(); current_slider_pos = -1; drawBar(); - updateVTerm(true); } //---------------------------------------------------------------------- diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 95cd69a8..e196299a 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -259,7 +259,6 @@ void FStatusBar::drawMessage() if ( isLastActiveFocus ) space_offset = 0; - updateVTerm(false); setColor (wc.statusbar_fg, wc.statusbar_bg); setPrintPos (x, 1); @@ -301,8 +300,6 @@ void FStatusBar::drawMessage() if ( isMonochron() ) setReverse(false); - - updateVTerm(true); } //---------------------------------------------------------------------- @@ -416,10 +413,10 @@ void FStatusBar::onMouseDown (FMouseEvent* ev) mouse_x = ev->getX(); mouse_y = ev->getY(); - if ( mouse_x >= x1 - && mouse_x <= x2 - && mouse_y == 1 - && ! (*iter)->hasMouseFocus() ) + if ( mouse_x >= x1 + && mouse_x <= x2 + && mouse_y == 1 + && ! (*iter)->hasMouseFocus() ) { (*iter)->setMouseFocus(); redraw(); @@ -508,9 +505,9 @@ void FStatusBar::onMouseMove (FMouseEvent* ev) mouse_x = ev->getX(); mouse_y = ev->getY(); - if ( mouse_x >= x1 - && mouse_x <= x2 - && mouse_y == 1 ) + if ( mouse_x >= x1 + && mouse_x <= x2 + && mouse_y == 1 ) { if ( ! (*iter)->hasMouseFocus() ) { @@ -604,7 +601,6 @@ void FStatusBar::drawKeys() return; } - updateVTerm(false); setPrintPos (1, 1); if ( isMonochron() ) @@ -678,10 +674,10 @@ void FStatusBar::drawKeys() print (".."); } - if ( iter+1 != key_list.end() - && ( (*(iter+1))->isActivated() || (*(iter+1))->hasMouseFocus() ) - && x + int(getKeyName((*(iter+1))->getKey()).getLength()) + 3 - < screenWidth ) + if ( iter+1 != key_list.end() + && ( (*(iter+1))->isActivated() || (*(iter+1))->hasMouseFocus() ) + && x + int(getKeyName((*(iter+1))->getKey()).getLength()) + 3 + < screenWidth ) { // next element is active if ( isMonochron() ) @@ -721,6 +717,5 @@ void FStatusBar::drawKeys() if ( isMonochron() ) setReverse(false); - updateVTerm(true); x_msg = x; } diff --git a/src/fstring.cpp b/src/fstring.cpp index 1abdacc1..abc0a990 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -694,8 +694,8 @@ long FString::toLong() const { register uChar d = uChar((*p) - L'0'); - if ( num > tenth_limit - || (num == tenth_limit && d > tenth_limit_digit) ) + if ( num > tenth_limit + || (num == tenth_limit && d > tenth_limit_digit) ) { throw std::overflow_error ("overflow"); } @@ -740,8 +740,8 @@ uLong FString::toULong() const { register uChar d = uChar((*p) - L'0'); - if ( num > tenth_limit - || (num == tenth_limit && d > tenth_limit_digit) ) + if ( num > tenth_limit + || (num == tenth_limit && d > tenth_limit_digit) ) { throw std::overflow_error ("overflow"); } diff --git a/src/fswitch.cpp b/src/fswitch.cpp index da54750b..cbabad0c 100644 --- a/src/fswitch.cpp +++ b/src/fswitch.cpp @@ -97,10 +97,8 @@ void FSwitch::onMouseUp (FMouseEvent* ev) //---------------------------------------------------------------------- void FSwitch::draw() { - updateVTerm(false); drawLabel(); drawCheckButton(); - updateVTerm(true); FToggleButton::draw(); updateTerminal(); flush_out(); diff --git a/src/fterm.cpp b/src/fterm.cpp index be7876c8..25fc0138 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -389,14 +389,14 @@ int FTerm::parseKeyString ( char buffer[] return fc::Fkey_mouse; // SGR mouse tracking - if ( buffer[1] == '[' && buffer[2] == '<' && buf_len >= 9 - && (buffer[buf_len-1] == 'M' || buffer[buf_len-1] == 'm') ) + if ( buffer[1] == '[' && buffer[2] == '<' && buf_len >= 9 + && (buffer[buf_len-1] == 'M' || buffer[buf_len-1] == 'm') ) return fc::Fkey_extended_mouse; // urxvt mouse tracking - if ( buffer[1] == '[' && buffer[2] >= '1' && buffer[2] <= '9' - && buffer[3] >= '0' && buffer[3] <= '9' && buf_len >= 9 - && buffer[buf_len-1] == 'M' ) + if ( buffer[1] == '[' && buffer[2] >= '1' && buffer[2] <= '9' + && buffer[3] >= '0' && buffer[3] <= '9' && buf_len >= 9 + && buffer[buf_len-1] == 'M' ) return fc::Fkey_urxvt_mouse; // look for termcap keys @@ -428,9 +428,9 @@ int FTerm::parseKeyString ( char buffer[] if ( std::strncmp(kmeta, buffer, uInt(len)) == 0 ) // found { - if ( len == 2 && ( buffer[1] == 'O' - || buffer[1] == '[' - || buffer[1] == ']') ) + if ( len == 2 && ( buffer[1] == 'O' + || buffer[1] == '[' + || buffer[1] == ']' ) ) { if ( ! isKeyTimeout(time_keypressed, key_timeout) ) return NEED_MORE_DATA; @@ -504,11 +504,11 @@ bool FTerm::setVGAFont() return VGAFont; if ( gnome_terminal - || kde_konsole - || putty_terminal - || tera_terminal - || cygwin_terminal - || mintty_terminal ) + || kde_konsole + || putty_terminal + || tera_terminal + || cygwin_terminal + || mintty_terminal ) return false; VGAFont = true; @@ -574,15 +574,15 @@ bool FTerm::setNewFont() return true; if ( gnome_terminal - || kde_konsole - || putty_terminal - || tera_terminal - || cygwin_terminal - || mintty_terminal ) + || kde_konsole + || putty_terminal + || tera_terminal + || cygwin_terminal + || mintty_terminal ) return false; if ( xterm_terminal || screen_terminal - || urxvt_terminal || FTermcap::osc_support ) + || urxvt_terminal || FTermcap::osc_support ) { NewFont = true; // Set font in xterm to 8x16graph @@ -649,7 +649,7 @@ bool FTerm::setOldFont() VGAFont = false; if ( xterm_terminal || screen_terminal - || urxvt_terminal || FTermcap::osc_support ) + || urxvt_terminal || FTermcap::osc_support ) { if ( xterm_font && xterm_font->getLength() > 2 ) { @@ -932,7 +932,8 @@ const FString FTerm::getXTermColorName (int color) void FTerm::setXTermCursorStyle (fc::xtermCursorStyle 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); std::fflush(stdout); @@ -944,8 +945,8 @@ void FTerm::setXTermTitle (const FString& title) { // Set the xterm title if ( xterm_terminal || screen_terminal - || mintty_terminal || putty_terminal - || FTermcap::osc_support ) + || mintty_terminal || putty_terminal + || FTermcap::osc_support ) { oscPrefix(); putstringf (OSC "0;%s" BEL, title.c_str()); @@ -959,8 +960,8 @@ void FTerm::setXTermForeground (const FString& fg) { // Set the VT100 text foreground color if ( xterm_terminal || screen_terminal - || mintty_terminal || mlterm_terminal - || FTermcap::osc_support ) + || mintty_terminal || mlterm_terminal + || FTermcap::osc_support ) { oscPrefix(); putstringf (OSC "10;%s" BEL, fg.c_str()); @@ -974,8 +975,8 @@ void FTerm::setXTermBackground (const FString& bg) { // Set the VT100 text background color if ( xterm_terminal || screen_terminal - || mintty_terminal || mlterm_terminal - || FTermcap::osc_support ) + || mintty_terminal || mlterm_terminal + || FTermcap::osc_support ) { oscPrefix(); putstringf (OSC "11;%s" BEL, bg.c_str()); @@ -989,8 +990,8 @@ void FTerm::setXTermCursorColor (const FString& cc) { // Set the text cursor color if ( xterm_terminal || screen_terminal - || mintty_terminal || urxvt_terminal - || FTermcap::osc_support ) + || mintty_terminal || urxvt_terminal + || FTermcap::osc_support ) { oscPrefix(); putstringf (OSC "12;%s" BEL, cc.c_str()); @@ -1004,7 +1005,7 @@ void FTerm::setXTermMouseForeground (const FString& mfg) { // Set the mouse foreground color if ( xterm_terminal || screen_terminal - || urxvt_terminal || FTermcap::osc_support ) + || urxvt_terminal || FTermcap::osc_support ) { oscPrefix(); putstringf (OSC "13;%s" BEL, mfg.c_str()); @@ -1031,7 +1032,7 @@ void FTerm::setXTermHighlightBackground (const FString& hbg) { // Set the highlight background color if ( xterm_terminal || screen_terminal - || urxvt_terminal || FTermcap::osc_support ) + || urxvt_terminal || FTermcap::osc_support ) { oscPrefix(); putstringf (OSC "17;%s" BEL, hbg.c_str()); @@ -1050,7 +1051,7 @@ void FTerm::setXTermDefaults() setXTermCursorColor("rgb:ffff/ffff/ffff"); if ( xterm_default_colors - && ! (mintty_terminal || rxvt_terminal || screen_terminal) ) + && ! (mintty_terminal || rxvt_terminal || screen_terminal) ) { // mintty and rxvt can't reset these settings setXTermBackground("rgb:8080/a4a4/ecec"); @@ -1142,7 +1143,7 @@ void FTerm::resetXTermHighlightBackground() { // Reset the highlight background color if ( xterm_terminal || screen_terminal - || urxvt_terminal || FTermcap::osc_support ) + || urxvt_terminal || FTermcap::osc_support ) { oscPrefix(); putstringf (OSC "117" BEL); @@ -1305,10 +1306,10 @@ void FTerm::setEncoding (std::string enc) Encoding = it->second; - assert ( Encoding == fc::UTF8 - || Encoding == fc::VT100 - || Encoding == fc::PC - || Encoding == fc::ASCII ); + assert ( Encoding == fc::UTF8 + || Encoding == fc::VT100 + || Encoding == fc::PC + || Encoding == fc::ASCII ); // set the new Fputchar function pointer switch ( int(Encoding) ) @@ -1564,9 +1565,9 @@ void FTerm::init_consoleCharMap() c2 = fc::LowerHalfBlock; c3 = fc::FullBlock; - if ( charEncode(c1, fc::PC) == charEncode(c1, fc::ASCII) - || charEncode(c2, fc::PC) == charEncode(c2, fc::ASCII) - || charEncode(c3, fc::PC) == charEncode(c3, fc::ASCII) ) + if ( charEncode(c1, fc::PC) == charEncode(c1, fc::ASCII) + || charEncode(c2, fc::PC) == charEncode(c2, fc::ASCII) + || charEncode(c3, fc::PC) == charEncode(c3, fc::ASCII) ) { no_shadow_character = true; } @@ -1574,8 +1575,8 @@ void FTerm::init_consoleCharMap() c4 = fc::RightHalfBlock; c5 = fc::LeftHalfBlock; - if ( charEncode(c4, fc::PC) == charEncode(c4, fc::ASCII) - || charEncode(c5, fc::PC) == charEncode(c5, fc::ASCII) ) + if ( charEncode(c4, fc::PC) == charEncode(c4, fc::ASCII) + || charEncode(c5, fc::PC) == charEncode(c5, fc::ASCII) ) { no_half_block_character = true; } @@ -1694,9 +1695,9 @@ int FTerm::isConsole() { char arg = 0; // get keyboard type an compare - return ( isatty (fd_tty) - && ioctl(fd_tty, KDGKBTYPE, &arg) == 0 - && ((arg == KB_101) || (arg == KB_84)) ); + return ( isatty (fd_tty) + && ioctl(fd_tty, KDGKBTYPE, &arg) == 0 + && ((arg == KB_101) || (arg == KB_84)) ); } //---------------------------------------------------------------------- @@ -1813,8 +1814,8 @@ int FTerm::getFramebuffer_bpp () if (fd >= 0) { - if ( ! ioctl(fd, FBIOGET_VSCREENINFO, &fb_var) - && ! ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix) ) + if ( ! ioctl(fd, FBIOGET_VSCREENINFO, &fb_var) + && ! ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix) ) { ::close(fd); return int(fb_var.bits_per_pixel); @@ -1884,8 +1885,8 @@ void FTerm::identifyTermType() std::FILE *fp; - if ( (fp = std::fopen("/etc/ttytype", "r")) != 0 - || (fp = std::fopen("/etc/ttys", "r")) != 0 ) + if ( (fp = std::fopen("/etc/ttytype", "r")) != 0 + || (fp = std::fopen("/etc/ttys", "r")) != 0 ) { char* p; char* type; @@ -2241,8 +2242,8 @@ char* FTerm::init_256colorTerminal() } if ( std::strncmp(termtype, "rxvt", 4) != 0 - && s1 - && std::strncmp(s1, "rxvt-xpm", 8) == 0 ) + && s1 + && std::strncmp(s1, "rxvt-xpm", 8) == 0 ) { new_termtype = const_cast("rxvt-256color"); rxvt_terminal = true; @@ -2411,8 +2412,8 @@ char* FTerm::parseSecDA (char*& current_termtype) rxvt_terminal = true; force_vt100 = true; // this rxvt terminal support on utf-8 - if ( std::strncmp(termtype, "rxvt-", 5) != 0 - || std::strncmp(termtype, "rxvt-cygwin-native", 5) == 0 ) + if ( std::strncmp(termtype, "rxvt-", 5) != 0 + || std::strncmp(termtype, "rxvt-cygwin-native", 5) == 0 ) new_termtype = const_cast("rxvt-16color"); break; @@ -2712,6 +2713,8 @@ void FTerm::init_termcaps() const_cast(CSI "48;5;%p1%dm"); tcap[fc::t_exit_attribute_mode].string = \ const_cast(CSI "0m" SI); + tcap[fc::t_orig_pair].string = \ + const_cast(CSI "39;49m"); } else if ( putty_terminal ) { @@ -2788,7 +2791,7 @@ void FTerm::init_termcaps() // test for standard ECMA-48 (ANSI X3.64) terminal if ( tcap[fc::t_exit_underline_mode].string - && std::strncmp(tcap[fc::t_exit_underline_mode].string, CSI "24m", 5) == 0 ) + && std::strncmp(tcap[fc::t_exit_underline_mode].string, CSI "24m", 5) == 0 ) { // seems to be a ECMA-48 (ANSI X3.64) compatible terminal tcap[fc::t_enter_dbl_underline_mode].string = \ @@ -2856,9 +2859,9 @@ void FTerm::init_termcaps() // ..110380-using-arrow-keys-shell-scripts.html key_up_string = tgetstr(const_cast("ku"), &buffer); - if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0)) - || ( tcap[fc::t_cursor_up].string - && (std::strcmp(tcap[fc::t_cursor_up].string, CSI "A") == 0)) ) + if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0)) + || ( tcap[fc::t_cursor_up].string + && (std::strcmp(tcap[fc::t_cursor_up].string, CSI "A") == 0) ) ) { 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 - 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; Encoding = fc::UTF8; @@ -2984,9 +2988,9 @@ void FTerm::init_encoding() utf8_input = true; setUTF8(true); } - else if ( isatty(stdout_no) - && (std::strlen(termtype) > 0) - && (tcap[fc::t_exit_alt_charset_mode].string != 0) ) + else if ( isatty(stdout_no) + && (std::strlen(termtype) > 0) + && (tcap[fc::t_exit_alt_charset_mode].string != 0) ) { vt100_console = true; Encoding = fc::VT100; @@ -3001,10 +3005,10 @@ void FTerm::init_encoding() init_pc_charset(); - if ( linux_terminal - || cygwin_terminal - || NewFont - || (putty_terminal && ! utf8_state) ) + if ( linux_terminal + || cygwin_terminal + || NewFont + || (putty_terminal && ! utf8_state) ) { pc_charset_console = true; Encoding = fc::PC; @@ -3129,8 +3133,8 @@ void FTerm::init() } // Test for Linux console - if ( std::strncmp(termtype, const_cast("linux"), 5) == 0 - || std::strncmp(termtype, const_cast("con"), 3) == 0 ) + if ( std::strncmp(termtype, const_cast("linux"), 5) == 0 + || std::strncmp(termtype, const_cast("con"), 3) == 0 ) linux_terminal = true; else linux_terminal = false; @@ -3156,10 +3160,10 @@ void FTerm::init() // Determine xterm maximum number of colors via OSC 4 if ( ! color256 - && ! cygwin_terminal - && ! tera_terminal - && ! linux_terminal - && getXTermColorName(0) != "" ) + && ! cygwin_terminal + && ! tera_terminal + && ! linux_terminal + && getXTermColorName(0) != "" ) { if ( getXTermColorName(256) != "" ) { @@ -3175,10 +3179,10 @@ void FTerm::init() } } - if ( cygwin_terminal - || putty_terminal - || tera_terminal - || rxvt_terminal ) + if ( cygwin_terminal + || putty_terminal + || tera_terminal + || rxvt_terminal ) { FTermcap::max_color = 16; } @@ -3205,8 +3209,8 @@ void FTerm::init() } // Test if the terminal is a xterm - if ( std::strncmp(termtype, const_cast("xterm"), 5) == 0 - || std::strncmp(termtype, const_cast("Eterm"), 4) == 0 ) + if ( std::strncmp(termtype, const_cast("xterm"), 5) == 0 + || std::strncmp(termtype, const_cast("Eterm"), 4) == 0 ) { xterm_terminal = true; @@ -3326,9 +3330,9 @@ void FTerm::init() setKDECursor(fc::UnderlineCursor); if ( FTermcap::max_color >= 16 - && ! cygwin_terminal - && ! kde_konsole - && ! tera_terminal ) + && ! cygwin_terminal + && ! kde_konsole + && ! tera_terminal ) { resetColorMap(); saveColorMap(); diff --git a/src/ftextview.cpp b/src/ftextview.cpp index f3f7ed35..6623ee1e 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -408,10 +408,10 @@ void FTextView::onMouseDown (FMouseEvent* ev) parent = getParentWidget(); if ( parent - && parent->isDialogWidget() - && (dialog = static_cast(parent)) != 0 - && dialog->isResizeable() - && ! dialog->isZoomed() ) + && parent->isDialogWidget() + && (dialog = static_cast(parent)) != 0 + && dialog->isResizeable() + && ! dialog->isZoomed() ) { int b = ev->getButton(); const FPoint& tp = ev->getTermPos(); @@ -430,10 +430,10 @@ void FTextView::onMouseUp (FMouseEvent* ev) FDialog* dialog; if ( parent - && parent->isDialogWidget() - && (dialog = static_cast(parent)) != 0 - && dialog->isResizeable() - && ! dialog->isZoomed() ) + && parent->isDialogWidget() + && (dialog = static_cast(parent)) != 0 + && dialog->isResizeable() + && ! dialog->isZoomed() ) { int b = ev->getButton(); const FPoint& tp = ev->getTermPos(); @@ -458,10 +458,10 @@ void FTextView::onMouseMove (FMouseEvent* ev) FDialog* dialog; if ( parent - && parent->isDialogWidget() - && (dialog = static_cast(parent)) != 0 - && dialog->isResizeable() - && ! dialog->isZoomed() ) + && parent->isDialogWidget() + && (dialog = static_cast(parent)) != 0 + && dialog->isResizeable() + && ! dialog->isZoomed() ) { int b = ev->getButton(); const FPoint& tp = ev->getTermPos(); @@ -631,19 +631,18 @@ void FTextView::draw() { FWidget* parent = getParentWidget(); bool is_text_dialog; - updateVTerm(false); setColor(); if ( isMonochron() ) setReverse(true); if ( parent - && parent->isDialogWidget() - && isPaddingIgnored() - && getGeometry() == FRect ( 1 - , 2 - , parent->getWidth() - , parent->getHeight() - 1) ) + && parent->isDialogWidget() + && isPaddingIgnored() + && getGeometry() == FRect ( 1 + , 2 + , parent->getWidth() + , parent->getHeight() - 1) ) { is_text_dialog = true; } @@ -662,7 +661,6 @@ void FTextView::draw() if ( hbar->isVisible() ) hbar->redraw(); - updateVTerm(true); drawText(); if ( hasFocus() && getStatusBar() ) @@ -672,10 +670,8 @@ void FTextView::draw() if ( curMsg != msg ) { - updateVTerm(false); getStatusBar()->setMessage(msg); getStatusBar()->drawMessage(); - updateVTerm(true); } } @@ -698,7 +694,6 @@ void FTextView::drawText() if ( end > getRows() ) end = getRows(); - updateVTerm(false); setColor(); if ( isMonochron() ) @@ -721,9 +716,9 @@ void FTextView::drawText() bool utf8 = (Encoding == fc::UTF8) ? true : false; // only printable and 1 column per character - if ( ( (utf8 && std::iswprint(wint_t(ch))) + if ( ( (utf8 && std::iswprint(wint_t(ch))) || (!utf8 && ch < 256 && std::isprint(ch)) ) - && wcwidth(ch) == 1 ) + && wcwidth(ch) == 1 ) { print (ch); } @@ -737,8 +732,6 @@ void FTextView::drawText() if ( isMonochron() ) setReverse(false); - - updateVTerm(true); } //---------------------------------------------------------------------- @@ -822,8 +815,8 @@ void FTextView::cb_VBarChange (FWidget*, void*) updateTerminal(); } - if ( scrollType >= FScrollbar::scrollStepBackward - && scrollType <= FScrollbar::scrollPageForward ) + if ( scrollType >= FScrollbar::scrollStepBackward + && scrollType <= FScrollbar::scrollPageForward ) { vbar->setValue (yoffset); @@ -919,8 +912,8 @@ void FTextView::cb_HBarChange (FWidget*, void*) updateTerminal(); } - if ( scrollType >= FScrollbar::scrollStepBackward - && scrollType <= FScrollbar::scrollWheelDown ) + if ( scrollType >= FScrollbar::scrollStepBackward + && scrollType <= FScrollbar::scrollWheelDown ) { hbar->setValue (xoffset); diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index f33b95ab..30fea73a 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -356,15 +356,15 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev) redraw(); } - else if ( this == getGroup()->getLastButton() - && out_ev->getFocusType() == fc::FocusNextWidget ) + else if ( this == getGroup()->getLastButton() + && out_ev->getFocusType() == fc::FocusNextWidget ) { out_ev->ignore(); getGroup()->focusNextChild(); redraw(); } - else if ( this == getGroup()->getFirstButton() - && out_ev->getFocusType() == fc::FocusPreviousWidget ) + else if ( this == getGroup()->getFirstButton() + && out_ev->getFocusType() == fc::FocusPreviousWidget ) { out_ev->ignore(); getGroup()->focusPrevChild(); diff --git a/src/ftooltip.cpp b/src/ftooltip.cpp index 5cc20f36..48eb9072 100644 --- a/src/ftooltip.cpp +++ b/src/ftooltip.cpp @@ -79,7 +79,6 @@ void FToolTip::setText (const char* txt) //---------------------------------------------------------------------- void FToolTip::draw() { - updateVTerm(false); setColor(); if ( getMaxColor() < 16 ) @@ -95,7 +94,6 @@ void FToolTip::draw() } unsetBold(); - updateVTerm(true); } //---------------------------------------------------------------------- diff --git a/src/fvterm.cpp b/src/fvterm.cpp index cfffe1d0..bc274380 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -15,13 +15,11 @@ bool FVTerm::terminal_update_complete; bool FVTerm::terminal_update_pending; bool FVTerm::force_terminal_update; bool FVTerm::stop_terminal_updates; -bool FVTerm::vterm_updates; int FVTerm::skipped_terminal_update = 0; std::queue* FVTerm::output_buffer = 0; FPoint* FVTerm::term_pos = 0; FVTerm::term_area* FVTerm::vterm = 0; FVTerm::term_area* FVTerm::vdesktop = 0; -FVTerm::term_area* FVTerm::last_area = 0; FVTerm::term_area* FVTerm::active_area = 0; FVTerm::termcap_map* FVTerm::tcap = 0; FTermcap::tcap_map* FTermcap::tcap = 0; @@ -41,7 +39,6 @@ FVTerm::FVTerm (FVTerm* parent) , vwin(0) { terminal_update_complete = false; - vterm_updates = true; if ( ! parent ) { @@ -131,7 +128,7 @@ void FVTerm::clearTerm (int fillchar) vdesktop->changes[i].trans_count = 0; } - updateVTerm (vdesktop); + vdesktop->has_changes = true; setTermXY (0,0); } else if ( cl ) @@ -264,7 +261,7 @@ void FVTerm::updateTerminal() // Updates pending changes to the terminal if ( stop_terminal_updates - || static_cast(init_object)->isQuit() ) + || static_cast(init_object)->isQuit() ) return; if ( ! force_terminal_update ) @@ -279,6 +276,9 @@ void FVTerm::updateTerminal() } } + // Update data on VTerm + updateVTerm(); + for (register uInt y=0; y < uInt(vterm->height); y++) updateTerminalLine (y); @@ -318,7 +318,9 @@ void FVTerm::updateTerminalLine (uInt y) 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++; else break; @@ -340,7 +342,9 @@ void FVTerm::updateTerminalLine (uInt y) 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++; else break; @@ -363,7 +367,9 @@ void FVTerm::updateTerminalLine (uInt y) 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++; else break; @@ -399,6 +405,31 @@ void FVTerm::updateTerminalLine (uInt y) char_data* print_char; 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 if ( ec && print_char->code == ' ' ) { @@ -407,7 +438,9 @@ void FVTerm::updateTerminalLine (uInt y) 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++; else break; @@ -440,7 +473,9 @@ void FVTerm::updateTerminalLine (uInt y) 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++; else break; @@ -704,6 +739,9 @@ int FVTerm::print (term_area* area, FString& s) if ( p ) { + if ( *p ) + area->has_changes = true; + while ( *p ) { int width, height, rsh, bsh; @@ -762,12 +800,14 @@ int FVTerm::print (term_area* area, FString& s) nc.transparent = next_attribute.transparent; nc.trans_shadow = next_attribute.trans_shadow; nc.inherit_bg = next_attribute.inherit_bg; + nc.no_changes = false; + nc.restored = false; - if ( area - && area->cursor_x > 0 - && area->cursor_y > 0 - && ax < area->width + area->right_shadow - && ay < area->height + area->bottom_shadow ) + if ( area + && area->cursor_x > 0 + && area->cursor_y > 0 + && ax < area->width + area->right_shadow + && ay < area->height + area->bottom_shadow ) { char_data* ac; // area character int line_len = area->width + area->right_shadow; @@ -775,16 +815,16 @@ int FVTerm::print (term_area* area, FString& s) if ( *ac != nc ) // compare with an overloaded operator { - if ( ( ! ac->transparent && nc.transparent ) - || ( ! ac->trans_shadow && nc.trans_shadow ) - || ( ! ac->inherit_bg && nc.inherit_bg ) ) + if ( ( ! ac->transparent && nc.transparent ) + || ( ! ac->trans_shadow && nc.trans_shadow ) + || ( ! ac->inherit_bg && nc.inherit_bg ) ) { // add one transparent character form line area->changes[ay].trans_count++; } - else if ( ( ac->transparent && ! nc.transparent ) - || ( ac->trans_shadow && ! nc.trans_shadow ) - || ( ac->inherit_bg && ! nc.inherit_bg ) ) + else if ( ( ac->transparent && ! nc.transparent ) + || ( ac->trans_shadow && ! nc.trans_shadow ) + || ( ac->inherit_bg && ! nc.inherit_bg ) ) { // remove one transparent character from line area->changes[ay].trans_count--; @@ -820,8 +860,6 @@ int FVTerm::print (term_area* area, FString& s) p++; len++; } // end of while - - updateVTerm (area); } return len; @@ -878,11 +916,13 @@ int FVTerm::print (term_area* area, register int c) nc.transparent = next_attribute.transparent; nc.trans_shadow = next_attribute.trans_shadow; nc.inherit_bg = next_attribute.inherit_bg; + nc.no_changes = false; + nc.restored = false; - if ( area->cursor_x > 0 - && area->cursor_y > 0 - && ax < area->width + area->right_shadow - && ay < area->height + area->bottom_shadow ) + if ( area->cursor_x > 0 + && area->cursor_y > 0 + && ax < area->width + area->right_shadow + && ay < area->height + area->bottom_shadow ) { char_data* ac; // area character int line_len = area->width + area->right_shadow; @@ -890,17 +930,17 @@ int FVTerm::print (term_area* area, register int c) if ( *ac != nc ) // compare with an overloaded operator { - if ( ( ! ac->transparent && nc.transparent ) - || ( ! ac->trans_shadow && nc.trans_shadow ) - || ( ! ac->inherit_bg && nc.inherit_bg ) ) + if ( ( ! ac->transparent && nc.transparent ) + || ( ! ac->trans_shadow && nc.trans_shadow ) + || ( ! ac->inherit_bg && nc.inherit_bg ) ) { // add one transparent character form line area->changes[ay].trans_count++; } - if ( ( ac->transparent && ! nc.transparent ) - || ( ac->trans_shadow && ! nc.trans_shadow ) - || ( ac->inherit_bg && ! nc.inherit_bg ) ) + if ( ( ac->transparent && ! nc.transparent ) + || ( ac->trans_shadow && ! nc.trans_shadow ) + || ( ac->inherit_bg && ! nc.inherit_bg ) ) { // remove one transparent character from line area->changes[ay].trans_count--; @@ -918,6 +958,7 @@ int FVTerm::print (term_area* area, register int c) } area->cursor_x++; + area->has_changes = true; 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 ) { area->cursor_y--; - updateVTerm (area); return -1; } - updateVTerm (area); return 1; } @@ -1180,6 +1219,7 @@ void FVTerm::createArea ( int x_offset, int y_offset area->input_cursor_x = -1; area->input_cursor_y = -1; area->input_cursor_visible = false; + area->has_changes = false; area->changes = 0; area->text = 0; area->visible = false; @@ -1244,6 +1284,7 @@ void FVTerm::resizeArea ( int x_offset, int y_offset area->height = height; area->right_shadow = rsw; area->bottom_shadow = bsh; + area->has_changes = false; default_char.code = ' '; 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.trans_shadow = 0; default_char.inherit_bg = 0; + default_char.no_changes = 0; std::fill_n (area->text, area_size, default_char); @@ -1389,12 +1431,12 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h) s_ch.reverse = false; s_ch.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 ) + 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; @@ -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)); 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 ) - updateVTerm (last_area); + if ( vdesktop && vdesktop->has_changes ) + { + updateVTerm(vdesktop); + vdesktop->has_changes = false; + } + + FWidget* widget = static_cast(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) { + // Update area data on VTerm + int ax, ay, aw, ah, rsh, bsh, y_end, ol; char_data* tc; // terminal character char_data* ac; // area character - if ( ! vterm_updates ) - { - last_area = area; - return; - } - if ( ! area ) return; @@ -1542,7 +1610,7 @@ void FVTerm::updateVTerm (term_area* area) else 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_xmax = int(area->changes[y].xmax); @@ -1561,7 +1629,7 @@ void FVTerm::updateVTerm (term_area* area) if ( ax + line_xmin >= vterm->width ) 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; covered_state is_covered; @@ -1591,14 +1659,15 @@ void FVTerm::updateVTerm (term_area* area) ch.reverse = false; ch.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 ) + 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.no_changes = bool(! tc->restored && *tc == ch); std::memcpy (tc, &ch, sizeof(char_data)); } else if ( ac->transparent ) // transparent @@ -1606,9 +1675,10 @@ void FVTerm::updateVTerm (term_area* area) // restore one character on vterm char_data ch; ch = getCoveredCharacter (gx+1 - ol, gy+1, area->widget); + ch.no_changes = bool(! tc->restored && *tc == ch); std::memcpy (tc, &ch, sizeof(char_data)); } - else // not transparent + else // not transparent { if ( ac->trans_shadow ) // transparent shadow { @@ -1620,14 +1690,15 @@ void FVTerm::updateVTerm (term_area* area) ch.reverse = false; ch.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 ) + 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.no_changes = bool(! tc->restored && *tc == ch); std::memcpy (tc, &ch, sizeof(char_data)); } else if ( ac->inherit_bg ) @@ -1637,16 +1708,30 @@ void FVTerm::updateVTerm (term_area* area) std::memcpy (&ch, ac, sizeof(char_data)); cc = getCoveredCharacter (gx+1 - ol, gy+1, area->widget); ch.bg_color = cc.bg_color; + ch.no_changes = bool(*tc == ch); std::memcpy (tc, &ch, sizeof(char_data)); } else // default - std::memcpy (tc, ac, sizeof(char_data)); + { + if ( ! tc->restored && *tc == *ac ) + { + 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; } else if ( ! modified ) line_xmin++; // don't update covered character + + tc->restored = false; } _xmin = ax + line_xmin - ol; @@ -1695,8 +1780,8 @@ bool FVTerm::updateVTermCursor (term_area* area) y = ay + cy; if ( isInsideArea(cx, cy, area) - && isInsideTerminal(x, y) - && isCovered(x, y, area) == non_covered ) + && isInsideTerminal(x, y) + && isCovered(x, y, area) == non_covered ) { vterm->input_cursor_x = x; vterm->input_cursor_y = y; @@ -1745,7 +1830,6 @@ void FVTerm::setAreaCursor ( int x, int y area->input_cursor_x = x - 1; area->input_cursor_y = y - 1; area->input_cursor_visible = visible; - updateVTerm (area); } //---------------------------------------------------------------------- @@ -1940,12 +2024,12 @@ void FVTerm::putArea (int ax, int ay, term_area* area) ch.reverse = false; ch.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 ) + 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 = ' '; std::memcpy (tc, &ch, sizeof(char_data)); @@ -2014,6 +2098,24 @@ void FVTerm::scrollAreaForward (term_area* area) std::fill_n (dc, area->width, nc); area->changes[y_max].xmin = 0; 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 int total_width; int length; + int y_max; char_data nc; // next character char_data* lc; // last character char_data* sc; // source character @@ -2035,8 +2138,9 @@ void FVTerm::scrollAreaReverse (term_area* area) length = area->width; 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 pos2 = y * total_width; @@ -2055,6 +2159,24 @@ void FVTerm::scrollAreaReverse (term_area* area) std::fill_n (dc, area->width, nc); area->changes[0].xmin = 0; 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; + } + } + } } //---------------------------------------------------------------------- @@ -2112,9 +2234,9 @@ void FVTerm::clearArea (term_area* area, int fillchar) area->changes[i].xmin = 0; area->changes[i].xmax = w - 1; - if ( nc.transparent - || nc.trans_shadow - || nc.inherit_bg ) + if ( nc.transparent + || nc.trans_shadow + || nc.inherit_bg ) area->changes[i].trans_count = w; else if ( area->right_shadow != 0 ) area->changes[i].trans_count = uInt(area->right_shadow); @@ -2130,7 +2252,7 @@ void FVTerm::clearArea (term_area* area, int fillchar) area->changes[y].trans_count = w; } - updateVTerm (area); + area->has_changes = true; } //---------------------------------------------------------------------- @@ -2334,7 +2456,6 @@ void FVTerm::init() init_object = this; vterm = 0; vdesktop = 0; - last_area = 0; term_pos = new FPoint(-1,-1); output_buffer = new std::queue; @@ -2363,7 +2484,9 @@ void FVTerm::init() term_attribute.pc_charset = \ term_attribute.transparent = \ 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 std::memcpy (&next_attribute, &term_attribute, sizeof(char_data)); diff --git a/src/fvterm.h b/src/fvterm.h index c1441738..c422d15f 100644 --- a/src/fvterm.h +++ b/src/fvterm.h @@ -68,6 +68,7 @@ class FVTerm : public FObject, public FTerm FWidget* widget; line_changes* changes; char_data* text; + bool has_changes; bool visible; } term_area; @@ -263,7 +264,7 @@ class FVTerm : public FObject, public FTerm static covered_state isCovered ( int, int , term_area* ); - static void updateVTerm (bool); + static void updateVTerm(); static void updateVTerm (term_area*); static bool updateVTermCursor (term_area*); static bool isInsideArea (int, int, term_area*); @@ -302,7 +303,6 @@ class FVTerm : public FObject, public FTerm // Data Members static term_area* vterm; // virtual terminal static term_area* vdesktop; // virtual desktop - static term_area* last_area; // last used area static term_area* active_area; // active area term_area* print_area; // print area for this object term_area* vwin; // virtual window @@ -342,7 +342,6 @@ class FVTerm : public FObject, public FTerm static bool terminal_update_pending; static bool force_terminal_update; static bool stop_terminal_updates; - static bool vterm_updates; static int skipped_terminal_update; }; @@ -404,7 +403,8 @@ inline void FVTerm::setNormal() next_attribute.pc_charset = \ next_attribute.transparent = \ 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.bg_color = fc::Default; diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 648d6b0c..2d15554d 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -64,7 +64,7 @@ FWidget::FWidget (FWidget* parent) if ( ! parent ) { assert ( ! rootObject - && "FTerm: There should be only one root object" ); + && "FTerm: There should be only one root object" ); rootObject = this; show_root_widget = 0; @@ -200,10 +200,10 @@ FPoint FWidget::getPrintPos() //---------------------------------------------------------------------- std::vector& FWidget::doubleFlatLine_ref (fc::sides side) { - assert ( side == fc::top - || side == fc::right - || side == fc::bottom - || side == fc::left ); + assert ( side == fc::top + || side == fc::right + || side == fc::bottom + || side == fc::left ); switch ( side ) { @@ -280,7 +280,7 @@ bool FWidget::setFocus (bool on) FWidget::getFocusWidget()->unsetFocus(); if ( (!isDialogWidget() && focusable_children == 0) - || (isDialogWidget() && focusable_children == 1) ) + || (isDialogWidget() && focusable_children == 1) ) { FWidget::setFocusWidget(this); } @@ -347,8 +347,8 @@ void FWidget::setY (int y, bool adjust) //---------------------------------------------------------------------- void FWidget::setPos (int x, int y, bool adjust) { - if ( getX() == x && wsize.getX() == x - && getY() == y && wsize.getY() == y ) + if ( getX() == x && wsize.getX() == x + && getY() == y && wsize.getY() == y ) { return; } @@ -422,7 +422,7 @@ void FWidget::setSize (int width, int height, bool adjust) height = std::max (height, size_hints.min_height); if ( getWidth() == width && wsize.getWidth() == width - && getHeight() == height && wsize.getHeight() == height ) + && getHeight() == height && wsize.getHeight() == height ) return; if ( width < 1 ) @@ -653,10 +653,10 @@ void FWidget::setDoubleFlatLine (fc::sides side, bool bit) { uLong length; - assert ( side == fc::top - || side == fc::right - || side == fc::bottom - || side == fc::left ); + assert ( side == fc::top + || side == fc::right + || side == fc::bottom + || side == fc::left ); switch ( side ) { @@ -687,10 +687,10 @@ void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit) { uLong length, index; - assert ( side == fc::top - || side == fc::right - || side == fc::bottom - || side == fc::left ); + assert ( side == fc::top + || side == fc::right + || side == fc::bottom + || side == fc::left ); assert ( pos >= 1 ); @@ -748,10 +748,10 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y) { FWidget* widget = static_cast(*iter); - if ( widget->isEnabled() - && widget->isVisible() - && ! widget->isWindowWidget() - && widget->getTermGeometry().contains(x,y) ) + if ( widget->isEnabled() + && widget->isVisible() + && ! widget->isWindowWidget() + && widget->getTermGeometry().contains(x,y) ) { FWidget* child = childWidgetAt(widget, x, y); return (child != 0) ? child : widget; @@ -948,9 +948,9 @@ void FWidget::delAccelerator (FWidget* obj) if ( ! widget || widget == statusbar || widget == menubar ) widget = getRootWidget(); - if ( widget - && widget->accelerator_list - && ! widget->accelerator_list->empty() ) + if ( widget + && widget->accelerator_list + && ! widget->accelerator_list->empty() ) { FWidget::Accelerators::iterator iter; iter = widget->accelerator_list->begin(); @@ -1159,8 +1159,8 @@ void FWidget::hide() shown = false; if ( ! isDialogWidget() - && FWidget::getFocusWidget() == this - && ! focusPrevChild() ) + && FWidget::getFocusWidget() == this + && ! focusPrevChild() ) { if ( FWidget::getFocusWidget() ) FWidget::getFocusWidget()->unsetFocus(); @@ -1190,9 +1190,9 @@ bool FWidget::focusFirstChild() { FWidget* widget = static_cast(*iter); - if ( widget->isEnabled() - && widget->acceptFocus() - && ! widget->isMenuWidget() ) + if ( widget->isEnabled() + && widget->acceptFocus() + && ! widget->isMenuWidget() ) { widget->setFocus(); @@ -1233,9 +1233,9 @@ bool FWidget::focusLastChild() --iter; FWidget* widget = static_cast(*iter); - if ( widget->isEnabled() - && widget->acceptFocus() - && ! widget->isMenuWidget() ) + if ( widget->isEnabled() + && widget->acceptFocus() + && ! widget->isMenuWidget() ) { widget->setFocus(); @@ -1285,8 +1285,8 @@ void FWidget::drawShadow() if ( isMonochron() && ! trans_shadow ) return; - if ( (Encoding == fc::VT100 && ! (trans_shadow || isTeraTerm()) ) - || (Encoding == fc::ASCII && ! trans_shadow) ) + if ( (Encoding == fc::VT100 && ! (trans_shadow || isTeraTerm()) ) + || (Encoding == fc::ASCII && ! trans_shadow) ) { clearShadow(); return; @@ -1828,10 +1828,10 @@ bool FWidget::focusNextChild() next_element = children.begin(); next = static_cast(*next_element); - } while ( ! next->isEnabled() - || ! next->acceptFocus() - || ! next->isVisible() - || next->isWindowWidget() ); + } while ( ! next->isEnabled() + || ! next->acceptFocus() + || ! next->isVisible() + || next->isWindowWidget() ); FFocusEvent out (fc::FocusOut_Event); out.setFocusType(fc::FocusNextWidget); @@ -1901,10 +1901,10 @@ bool FWidget::focusPrevChild() --prev_element; prev = static_cast(*prev_element); - } while ( ! prev->isEnabled() - || ! prev->acceptFocus() - || ! prev->isVisible() - || prev->isWindowWidget() ); + } while ( ! prev->isEnabled() + || ! prev->acceptFocus() + || ! prev->isVisible() + || prev->isWindowWidget() ); FFocusEvent out (fc::FocusOut_Event); out.setFocusType(fc::FocusPreviousWidget); @@ -1965,11 +1965,11 @@ bool FWidget::event (FEvent* ev) if ( ! kev->isAccepted() ) { - if ( kev->key() == fc::Fkey_right - || kev->key() == fc::Fkey_down ) + if ( kev->key() == fc::Fkey_right + || kev->key() == fc::Fkey_down ) accpt_focus = focusNextChild(); - else if ( kev->key() == fc::Fkey_left - || kev->key() == fc::Fkey_up ) + else if ( kev->key() == fc::Fkey_left + || kev->key() == fc::Fkey_up ) accpt_focus = focusPrevChild(); if ( accpt_focus ) diff --git a/src/fwindow.cpp b/src/fwindow.cpp index 830ed82d..85b602bd 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -442,7 +442,7 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y) FWindow* w = static_cast(*iter); if ( ! w->isWindowHidden() - && w->getTermGeometry().contains(x,y) ) + && w->getTermGeometry().contains(x,y) ) return w; } } @@ -594,7 +594,7 @@ bool FWindow::raiseWindow (FWidget* obj) return false; if ( (window_list->back()->getFlags() & fc::modal) != 0 - && ! obj->isMenuWidget() ) + && ! obj->isMenuWidget() ) return false; iter = window_list->begin(); @@ -704,10 +704,10 @@ void FWindow::switchToPrevWindow() FWindow* w = static_cast(*iter); if ( w - && w != active_window - && ! (w->isWindowHidden() || w->isWindowActive()) - && w != static_cast(getStatusBar()) - && w != static_cast(getMenuBar()) ) + && w != active_window + && ! (w->isWindowHidden() || w->isWindowActive()) + && w != static_cast(getStatusBar()) + && w != static_cast(getMenuBar()) ) { setActiveWindow(w); break; diff --git a/test/calculator.cpp b/test/calculator.cpp index 981e300f..65476830 100644 --- a/test/calculator.cpp +++ b/test/calculator.cpp @@ -302,7 +302,6 @@ Calc::~Calc() void Calc::drawDispay() { FString display = input; - updateVTerm(false); if ( display.isNull() || display.isEmpty() ) display = L'0'; @@ -364,8 +363,6 @@ void Calc::drawDispay() setPrintPos (1,4); print(separator); } - - updateVTerm(true); } //---------------------------------------------------------------------- @@ -684,7 +681,7 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr) else // Test if (x/180) != 0 and x/90 == 0 if ( std::fabs(std::fmod(*x,180.0L)) > LDBL_EPSILON - && std::fabs(std::fmod(*x,90.0L)) < LDBL_EPSILON ) + && std::fabs(std::fmod(*x,90.0L)) < LDBL_EPSILON ) error = true; else if ( std::fabs(std::fmod(*x,180.0L)) < LDBL_EPSILON ) // x/180 == 0 *x = 0.0L; @@ -984,8 +981,8 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr) { // remove trailing zeros while ( ! input.includes(L'e') - && input.includes(L'.') - && input.back() == L'0' ) + && input.includes(L'.') + && input.back() == L'0' ) input = input.left(input.getLength()-1); } } diff --git a/test/keyboard.cpp b/test/keyboard.cpp index 920836ee..d4dc3f83 100644 --- a/test/keyboard.cpp +++ b/test/keyboard.cpp @@ -41,15 +41,9 @@ void keyboard::onKeyPress (FKeyEvent* ev) printf ("Key %s (id %d)\n", getKeyName(key_id).c_str(), key_id); - if ( is_last_line ) - { scrollAreaForward (vdesktop); - if ( ! scrollTermForward() ) - putArea (getTermPos(), vdesktop); - } - setAreaCursor (1, getPrintPos().getY(), true, vdesktop); } diff --git a/test/mandelbrot.cpp b/test/mandelbrot.cpp index be87e247..0e34ff65 100644 --- a/test/mandelbrot.cpp +++ b/test/mandelbrot.cpp @@ -94,8 +94,6 @@ void Mandelbrot::draw() print(' '); } } - - updateVTerm(true); } //---------------------------------------------------------------------- diff --git a/test/menu.cpp b/test/menu.cpp index cbba9a6a..2fe99cf8 100644 --- a/test/menu.cpp +++ b/test/menu.cpp @@ -210,12 +210,12 @@ void Menu::defaultCallback (FMenuList* mb) { FMenuItem* item = mb->getItem(int(i)); - if ( item - && item->isEnabled() - && item->acceptFocus() - && item->isVisible() - && ! item->isSeparator() - && item->getText() != "&Quit" ) + if ( item + && item->isEnabled() + && item->acceptFocus() + && item->isVisible() + && ! item->isSeparator() + && item->getText() != "&Quit" ) { // Add the callback function item->addCallback @@ -278,8 +278,8 @@ void Menu::cb_exitApp (FWidget*, void*) int main (int argc, char* argv[]) { - if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 - || std::strcmp(argv[1], "-h") == 0 ) ) + if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 + || std::strcmp(argv[1], "-h") == 0 ) ) { std::cout << "Generic options:" << std::endl << " -h, --help " diff --git a/test/term-attributes.cpp b/test/term-attributes.cpp index 7a91293f..45b211de 100644 --- a/test/term-attributes.cpp +++ b/test/term-attributes.cpp @@ -261,8 +261,6 @@ void AttribDemo::printAltCharset() //---------------------------------------------------------------------- void AttribDemo::draw() { - updateVTerm(false); - // test alternate character set printAltCharset(); @@ -383,7 +381,6 @@ void AttribDemo::draw() setPrintPos (16, 17); print ("Change background color ->"); - updateVTerm(true); } diff --git a/test/timer.cpp b/test/timer.cpp index 22bd9d04..064411f3 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -60,13 +60,8 @@ void timer::onTimer (FTimerEvent* ev) printf ("timer event, id %d\n", timer_id ); if ( is_last_line ) - { scrollAreaForward (vdesktop); - if ( ! scrollTermForward() ) - putArea (getTermPos(), vdesktop); - } - setAreaCursor (1, getPrintPos().getY(), true, vdesktop); } diff --git a/test/transparent.cpp b/test/transparent.cpp index c6383750..a4b1087f 100644 --- a/test/transparent.cpp +++ b/test/transparent.cpp @@ -67,7 +67,6 @@ Transparent::~Transparent() void Transparent::draw() { FDialog::draw(); - updateVTerm(false); if ( isMonochron() ) setReverse(true); @@ -106,8 +105,6 @@ void Transparent::draw() if ( isMonochron() ) setReverse(false); - - updateVTerm(true); } //---------------------------------------------------------------------- @@ -188,19 +185,16 @@ MainWindow::MainWindow (FWidget* parent) transpwin->setText("transparent"); transpwin->setGeometry (6, 3, 29, 12); transpwin->unsetTransparentShadow(); - transpwin->show(); Transparent* shadowwin = new Transparent(this, Transparent::shadow); shadowwin->setText("shadow"); shadowwin->setGeometry (46, 11, 29, 12); shadowwin->unsetTransparentShadow(); - shadowwin->show(); Transparent* ibg = new Transparent(this, Transparent::inherit_background); ibg->setText("inherit background"); ibg->setGeometry (42, 3, 29, 7); ibg->unsetTransparentShadow(); - ibg->show(); // Statusbar at the bottom FStatusBar* statusbar = new FStatusBar (this); @@ -219,7 +213,6 @@ MainWindow::~MainWindow() void MainWindow::draw() { FDialog::draw(); - updateVTerm(false); if ( isMonochron() ) setReverse(true); @@ -233,7 +226,7 @@ void MainWindow::draw() if ( isMonochron() ) setReverse(false); - updateVTerm(true); + updateTerminal(); } //---------------------------------------------------------------------- @@ -275,8 +268,8 @@ void MainWindow::onTimer (FTimerEvent*) int main (int argc, char* argv[]) { - if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 - || std::strcmp(argv[1], "-h") == 0 ) ) + if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 + || std::strcmp(argv[1], "-h") == 0 ) ) { std::cout << "Generic options:" << std::endl << " -h, --help " diff --git a/test/ui.cpp b/test/ui.cpp index cf7922b2..37ab9528 100644 --- a/test/ui.cpp +++ b/test/ui.cpp @@ -895,8 +895,8 @@ int main (int argc, char* argv[]) FString ver = F_VERSION; // library version FString title = "The FINAL CUT " + ver + " (C) 2016 by Markus Gans"; - if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 - || std::strcmp(argv[1], "-h") == 0 ) ) + if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 + || std::strcmp(argv[1], "-h") == 0 ) ) { std::cout << "Generic options:" << std::endl << " -h, --help " diff --git a/test/windows.cpp b/test/windows.cpp index 8c4f44b2..506cb919 100644 --- a/test/windows.cpp +++ b/test/windows.cpp @@ -502,10 +502,10 @@ void Window::cb_next (FWidget*, void*) next_element = dialog_list->begin(); next = static_cast(*next_element); - } while ( ! next->isEnabled() - || ! next->acceptFocus() - || ! next->isVisible() - || ! next->isWindowWidget() ); + } while ( ! next->isEnabled() + || ! next->acceptFocus() + || ! next->isVisible() + || ! next->isWindowWidget() ); activateWindow(next); break; @@ -529,7 +529,7 @@ void Window::cb_previous (FWidget*, void*) --iter; if ( (*iter)->isDialogWidget() - && static_cast(*iter)->isWindowActive() ) + && static_cast(*iter)->isWindowActive() ) { FDialog* prev; widgetList::const_iterator prev_element; @@ -542,10 +542,10 @@ void Window::cb_previous (FWidget*, void*) --prev_element; prev = static_cast(*prev_element); - } while ( ! prev->isEnabled() - || ! prev->acceptFocus() - || ! prev->isVisible() - || ! prev->isWindowWidget() ); + } while ( ! prev->isEnabled() + || ! prev->acceptFocus() + || ! prev->isVisible() + || ! prev->isWindowWidget() ); activateWindow(prev); break; @@ -576,8 +576,8 @@ void Window::cb_destroyWindow (FWidget*, void* data_ptr) int main (int argc, char* argv[]) { - if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 - || std::strcmp(argv[1], "-h") == 0 ) ) + if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 + || std::strcmp(argv[1], "-h") == 0 ) ) { std::cout << "Generic options:" << std::endl << " -h, --help "