ultimatepp/uppdev/E011/console.cpp
cxl 351994a6cc Adding uppdev....
git-svn-id: svn://ultimatepp.org/upp/trunk@328 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2008-08-15 08:36:24 +00:00

57 lines
1.2 KiB
C++

#include "e011.h"
Console::Console() {
wrap_text = true;
SetReadOnly();
NoHorzScrollbar();
SetColor(PAPER_READONLY, SColorPaper);
SetFont(Font(Font::COURIER, 12));
//TabSize(0);
}
void Console::LeftDouble(Point p, dword) {
WhenSelect();
}
void Console::RightDown(Point p, dword)
{
MenuBar::Execute(WhenBar);
}
static int sAppf(int c) {
return c >= ' ' || c == '\n' ? c : c == '\t' ? ' ' : 0;
}
void Console::Append(const String& s) {
if(s.IsEmpty()) return;
int l, h;
GetSelection(l, h);
if(GetCursor() == GetLength()) l = -1;
EditPos p = GetEditPos();
SetEditable();
MoveTextEnd();
String t = Filter(s, sAppf);
if(wrap_text) {
int mg = sb.GetReducedViewSize().cx / ScreenInfo().GetFontInfo(GetFont()).GetAveWidth();
for(const char *q = t; *q; q++) {
if(mg > 2 && GetColumnLine(GetCursor()).x >= mg - 1)
Paste(ToUnicode("\n", CHARSET_WIN1252));
Paste(String(*q, 1).ToWString());
}
}
else
Paste(t.ToWString());
SetReadOnly();
if(l >= 0) {
SetEditPos(p);
SetSelection(l, h);
}
}
bool Console::Key(dword key, int count) {
if(key == K_ENTER) {
WhenSelect();
return true;
}
return LineEdit::Key(key, count);
}