mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-17 22:03:25 -06:00
74 lines
1.1 KiB
C++
74 lines
1.1 KiB
C++
#include "LogCtrl.h"
|
|
|
|
LoggerCtrl::LoggerCtrl() : maxlines(1000), ignore(false)
|
|
{
|
|
NoInitFocus();
|
|
NoWantFocus();
|
|
SetReadOnly();
|
|
//Reserve(maxlines*64);
|
|
}
|
|
|
|
void LoggerCtrl::Save()
|
|
{
|
|
FileSel fs;
|
|
fs.Type("Text file", "*.txt");
|
|
if(!fs.ExecuteSaveAs("Save Log to file")) return;
|
|
String fn = fs.Get();
|
|
if(fn.IsEmpty()) return;
|
|
FileOut out(fn);
|
|
Flush();
|
|
DocEdit::Save(out);
|
|
}
|
|
|
|
void LoggerCtrl::_Put(int w)
|
|
{
|
|
if(ignore) return;
|
|
String d;
|
|
d.Cat(w);
|
|
//String s = EscapeCh((unsigned)w);
|
|
GuiLock _;
|
|
Insert(GetLength(), d);
|
|
SetCursor(GetLength());
|
|
}
|
|
|
|
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());
|
|
}
|
|
|
|
LogCtrl::LogCtrl() : ps(NULL)
|
|
{
|
|
|
|
}
|
|
|
|
void LogCtrl::Log(bool b)
|
|
{
|
|
if(ps == this) return;
|
|
if(b)
|
|
{
|
|
ps = &VppLog();
|
|
SetVppLog(*this);
|
|
}
|
|
else if(ps)
|
|
{
|
|
SetVppLog(*ps);
|
|
ps = NULL;
|
|
}
|
|
}
|
|
|
|
void LogCtrl::Reset()
|
|
{
|
|
SetVppLog(StdLog());
|
|
ps = NULL;
|
|
}
|
|
|
|
INITBLOCK
|
|
{
|
|
LogLev(LDBG);
|
|
}
|