FLTK logo

Re: [fltk/fltk] test/tree: hitting 'select all' hangs the application (Issue #300)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: [fltk/fltk] test/tree: hitting 'select all' hangs the application (Issue #300) wcout Aug 22, 2022  
 

Perhaps changing Fl_Text_Display is not required at all to solve these issues here - thus avoiding incompatibility woes with Fl_Text_Display-derived classes:

I've noted now, that Fl_Text_Display::recalc_display()is a virtual function already.
As the problem lies with the slowness of Fl_Simple_Terminal, which is inherited from Fl_Text_Display it would be possible to overload recalc_display() in Fl_Simple_Terminal and use the defer logic just there!
The resulting change would be much simpler too:

diff --git a/FL/Fl_Simple_Terminal.H b/FL/Fl_Simple_Terminal.H
index 158bf7d48..ac3d9c539 100644
--- a/FL/Fl_Simple_Terminal.H
+++ b/FL/Fl_Simple_Terminal.H
@@ -138,6 +138,7 @@ private:
   int stable_size_;         // active style table size (in bytes)
   int normal_style_index_;  // "normal" style used by "\033[0m" reset sequence
   int current_style_index_; // current style used for drawing text
+  bool recalc_display_needed_; // true if recalc of display is needed
 
 public:
   Fl_Simple_Terminal(int X,int Y,int W,int H,const char *l=0);
@@ -181,6 +182,7 @@ private:
 protected:
   // Fltk
   virtual void draw();
+  virtual void recalc_display();
 
   // Internal methods
   void enforce_stay_at_bottom();
diff --git a/src/Fl_Simple_Terminal.cxx b/src/Fl_Simple_Terminal.cxx
index 3d776f2d8..b3c28042a 100644
--- a/src/Fl_Simple_Terminal.cxx
+++ b/src/Fl_Simple_Terminal.cxx
@@ -110,6 +110,7 @@ Fl_Simple_Terminal::Fl_Simple_Terminal(int X,int Y,int W,int H,const char *l) :
   orig_vscroll_cb = mVScrollBar->callback();
   orig_vscroll_data = mVScrollBar->user_data();
   mVScrollBar->callback(vscroll_cb, (void*)this);
+  recalc_display_needed_ = false;
 }
 
 /**
@@ -732,6 +733,10 @@ void Fl_Simple_Terminal::draw() {
   //
 #define LEFT_MARGIN 3
 #define RIGHT_MARGIN 3
+  if (recalc_display_needed_) {
+    recalc_display_needed_ = false;
+    Fl_Text_Display::recalc_display();
+  }
   int buflen = buf->length();
   // Force cursor to EOF so it doesn't draw at user's last left-click
   insert_position(buflen);
@@ -746,3 +751,8 @@ void Fl_Simple_Terminal::draw() {
   if (position_to_xy(buflen, &X, &Y)) draw_cursor(X, Y);
   fl_pop_clip();
 }
+
+void Fl_Simple_Terminal::recalc_display() {
+  recalc_display_needed_ = true; // set flag only
+  redraw(); // ensure draw() gets called
+}

I don't think many folks have based their classes on Fl_Simple_Terminal, so a change there will be less intrusive.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <fltk/fltk/issues/300/1222317695@github.com>

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.