bazaar: LogCtrl is buffered now for performance reasons and threading

git-svn-id: svn://ultimatepp.org/upp/trunk@5406 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
kohait 2012-10-03 21:34:27 +00:00
parent 527c96bc22
commit 870d64c46e
3 changed files with 18 additions and 16 deletions

View file

@ -5,7 +5,9 @@ LoggerCtrl::LoggerCtrl() : maxlines(1000), ignore(false)
NoInitFocus();
NoWantFocus();
SetReadOnly();
//Reserve(maxlines*64);
Reserve(512);
SetTimeCallback(-200, THISBACK(Flush));
}
void LoggerCtrl::Save()
@ -32,23 +34,24 @@ void LoggerCtrl::Updated()
void LoggerCtrl::_Put(int w)
{
if(ignore) return;
String d;
d.Cat(w);
//String s = EscapeCh((unsigned)w);
GuiLock _;
Insert(GetLength(), d);
SetCursor(GetLength());
StringStream::_Put(w);
}
void LoggerCtrl::_Put(const void *data, dword size)
{
if(ignore) return;
String d;
d.Cat((const char*)data, size);
//String s = EscapeCh(d);
GuiLock _;
Insert(GetLength(), d);
SetCursor(GetLength());
StringStream::_Put(data, size);
}
void LoggerCtrl::Flush()
{
if(StringStream::GetSize() > 0)
{
Insert(GetLength(), GetResult());
SetCursor(GetLength());
StringStream::Create(); //empty
Reserve(512);
}
}
LogCtrl::LogCtrl() : ps(NULL)

View file

@ -44,7 +44,7 @@ inline void LogLev(int l) { Single<LOGLEV>() = (LOGLEV)l;}
///
class LoggerCtrl : public DocEdit, public Stream
class LoggerCtrl : public DocEdit, public StringStream
{
public:
typedef LoggerCtrl CLASSNAME;
@ -58,7 +58,7 @@ public:
int GetMaxLines() const { return maxlines; }
virtual void Updated();
virtual bool IsOpen() const { return true; }
virtual void Flush();
protected:
virtual void _Put(int w);

View file

@ -1,5 +1,4 @@
#ifndef _LogCtrl_icpp_init_stub
#define _LogCtrl_icpp_init_stub
#include "CtrlLib/init"
#include "EscapeCh/init"
#endif