Re: Monitoring IO



I'll be adding text to a text widget based on received messages, and my
plan for limiting the scrollback was to keep a total of the number of
bytes read.  So (snipping from a previous email to the list by Julien
Schmitt):

      gtk_text_freeze(GTK_TEXT(text));
      gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, c, bytes_read);
      num_bytes += bytes_read;
      if(num_bytes > BYTES_HIGH_WATER)
        { do
          {
          num_bytes -= my_text_remove_first_line(GTK_TEXT(text));
          } while (num_bytes >= BYTES_LOW_WATER);
        }
      gtk_text_thaw(GTK_TEXT(text));

where my_text_remove_first_line() returns the number of bytes removed,
and is built with seeking for "\n" and then removing from the front,
both of which I think are available text operations.  

As a first pass that may well be good enough, the remove_first_line
function could just always remove the first N characters, and live with
displaying a partial line at the start of the text.

Note that there are subtleties that are involved in nice
scrolling-text-window behavior.  For example, the Hypertext behavior of
not losing visible text if the operator has scrolled the visible away
from the bottom (newest) is very nice.  Not quite sure how I'd implement
that, if anyone figures that out, please let me know.

Eric




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]