StyledTextCtrl remove leading text

Hi all,

I have a stc.StyledTextCtrl that I’m using as a log in an application.

This log is continuously updated with appended text. However, because this text will never stop, I’m concerned about memory use so I would like to put a line limit on the display if possible. I’m not sure if there’s a way to set this, or if I have to manually issue commands to remove text from the beginning. I either case I can’t really seem to get anywhere at the moment. How would you go about this?

NB: I also posted about this here: http://forums.wxwidgets.org/viewtopic.php?f=27&t=37748

···

Luke

Also, I’ve tried to use the DeleteRange method as documented here:

http://wxpython.org/Phoenix/docs/html/stc.StyledTextCtrl.html#stc.StyledTextCtrl.DeleteRange

But an exception is thrown saying there is no such member function for StyledTextCtrl :confused:

Hi,
you may try the Remove(...) method:
http://wxpython.org/Phoenix/docs/html/stc.StyledTextCtrl.html#stc.StyledTextCtrl.Remove
the mentioned documentation refers to the development version of
wxpython (Phoenix) and there might be some mismatches between the
versions.

Remove() does exist in wxpython 2.9.4 (end presumably in older
versions as well) and seems to do, what you are asking.

What is the size of the log data, you are collecting? In my limited
experience stc can cope with larger texts rather well (e.g. comparing
to wx.TextCtrl), but of course, there will be some practical limits as
well.

hth,
  vbr

···

2013/7/24 Luke Whitehorn <luke.whitehorn@gmail.com>:

Also, I've tried to use the DeleteRange method as documented here:

http://wxpython.org/Phoenix/docs/html/stc.StyledTextCtrl.html#stc.StyledTextCtrl.DeleteRange
But an exception is thrown saying there is no such member function for
StyledTextCtrl :confused:

--

Hello,

···

On Wed, Jul 24, 2013 at 4:09 AM, Luke Whitehorn luke.whitehorn@yahoo.co.uk wrote:

Hi all,

I have a stc.StyledTextCtrl that I’m using as a log in an application.

This log is continuously updated with appended text. However, because this text will never stop, I’m concerned about memory use so I would like to put a line limit on the display if possible. I’m not sure if there’s a way to set this, or if I have to manually issue commands to remove text from the beginning. I either case I can’t really seem to get anywhere at the moment. How would you go about this?

NB: I also posted about this here: http://forums.wxwidgets.org/viewtopic.php?f=27&t=37748

You need to manually remove lines from the beginning of the document to keep it within your ranges. I wrote a re-usable class for this in Editra several years ago for just this purpose. You can take a look at it in the wx svn (http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/Editra/src/eclib/outbuff.py?view=markup). There are several example usages of this class in Editra and its related plugins. (i.e. Editra Log Window: http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/Editra/src/ed_log.py?view=markup).

Cody