Fl_Terminal fixes from 1.5.x - smoother scrolling and issue #1328
Build and Test / build-linux (push) Has been cancelled
Build and Test / build-wayland (push) Has been cancelled
Build and Test / build-macos (push) Has been cancelled
Build and Test / build-windows (push) Has been cancelled

This commit is contained in:
Greg Ercolano
2025-11-17 14:04:55 -08:00
parent 1e769f44b4
commit 6a0184262d
+39 -33
View File
@@ -3463,6 +3463,7 @@ void Fl_Terminal::init_(int X,int Y,int W,int H,const char*L,int rows,int cols,i
scrollbar = new Fl_Scrollbar(x(), y(), scrollbar_actual_size(), h()); // tmp xywh (changed later) **
scrollbar->type(FL_VERTICAL);
scrollbar->value(0);
scrollbar->linesize(3); // consistent w/Fl_Text_Display -erco 11/17/25
scrollbar->callback(scrollbar_cb, (void*)this);
hscrollbar = new Fl_Scrollbar(x(), y(), w(), scrollbar_actual_size()); // tmp xywh (changed later) **
@@ -3722,45 +3723,50 @@ void Fl_Terminal::draw_buff(int Y) const {
followed by the terminal's screen contents.
*/
void Fl_Terminal::draw(void) {
// First time shown? Force deferred font size calculations here (issue 837)
if (fontsize_defer_) {
fontsize_defer_ = false; // clear flag
current_style_->update(); // do deferred update here
update_screen(true); // update fonts
}
// Detect if Fl::scrollbar_size() was changed in size, recalc if so
if (scrollbar_size_ == 0 &&
((scrollbar->visible() && scrollbar->w() != Fl::scrollbar_size()) ||
(hscrollbar->visible() && hscrollbar->h() != Fl::scrollbar_size()))) {
update_scrollbar();
}
// Draw group first, terminal last
Fl_Group::draw();
// Draw that little square between the scrollbars:
if (scrollbar->visible() && hscrollbar->visible()) {
fl_color(parent()->color());
fl_rectf(scrollbar->x(), hscrollbar->y(), scrollbar_actual_size(), scrollbar_actual_size());
}
if (is_frame(box())) {
// Is box() a frame? Fill area inside frame with rectf().
// FL_XXX_FRAME types allow Fl_Terminal to have a /flat/ background.
// FL_XXX_BOX types inherit Fl::scheme() which can provide unwanted gradients.
//
fl_color(Fl_Group::color());
// Draw flat field (inside border drawn by Fl_Group::draw() above)
int X = x() + Fl::box_dx(box());
int Y = y() + Fl::box_dy(box());
int W = w() - Fl::box_dw(box());
int H = h() - Fl::box_dh(box());
if (scrollbar->visible()) W -= scrollbar_actual_size();
if (hscrollbar->visible()) H -= scrollbar_actual_size();
fl_rectf(X,Y,W,H);
int cx = x() + Fl::box_dx(box());
int cy = y() + Fl::box_dy(box());
int cw = w() - Fl::box_dw(box());
int ch = h() - Fl::box_dh(box());
fl_push_clip(cx,cy,cw,ch);
{
// First time shown? Force deferred font size calculations here (issue 837)
if (fontsize_defer_) {
fontsize_defer_ = false; // clear flag
current_style_->update(); // do deferred update here
update_screen(true); // update fonts
}
// Detect if Fl::scrollbar_size() was changed in size, recalc if so
if (scrollbar_size_ == 0 &&
((scrollbar->visible() && scrollbar->w() != Fl::scrollbar_size()) ||
(hscrollbar->visible() && hscrollbar->h() != Fl::scrollbar_size()))) {
update_scrollbar();
}
// Draw group first, terminal last
Fl_Group::draw();
// Draw that little square between the scrollbars:
if (scrollbar->visible() && hscrollbar->visible()) {
fl_color(parent()->color());
fl_rectf(scrollbar->x(), hscrollbar->y(), scrollbar_actual_size(), scrollbar_actual_size());
}
if (is_frame(box())) {
// Is box() a frame? Fill area inside frame with rectf().
// FL_XXX_FRAME types allow Fl_Terminal to have a /flat/ background.
// FL_XXX_BOX types inherit Fl::scheme() which can provide unwanted gradients.
//
fl_color(Fl_Group::color());
// Draw flat field (inside border drawn by Fl_Group::draw() above)
fl_rectf(scrn_.x(), scrn_.y(), scrn_.w(), scrn_.h());
}
}
fl_pop_clip();
//DEBUG fl_color(0x80000000); // dark red box inside margins
//DEBUG fl_rect(scrn_);
fl_push_clip(scrn_.x(), scrn_.y(), scrn_.w(), scrn_.h());
{
int Y = scrn_.y();
draw_buff(Y);
}
fl_pop_clip();
}