/usr/share/ecere/extras/gui/controls/LogBox.ec is in ecere-extras 0.44.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | #include <stdarg.h>
public import "ecere"
class LogBox : EditBox
{
bool moved, logging, tell;
void Logt(typed_object object, ...)
{
va_list args;
char buffer[4096];
va_start(args, object);
PrintStdArgsToBuffer(buffer, sizeof(buffer), object, args);
va_end(args);
Log(buffer);
}
void Logf(char * format, ...)
{
va_list args;
char string[MAX_F_STRING*10];
va_start(args, format);
vsprintf(string, format, args);
va_end(args);
Log(string);
}
void LogSprintf(char * entry)
{
char string[MAX_F_STRING];
sprintf(string, entry);
Log(string);
}
void LogRaw(char * entry)
{
Log(entry);
}
void Log(char * string)
{
int x1, y1, x2, y2;
Point scrl;
EditLine line1;
EditLine line2;
logging = true;
if(moved)
{
GetSelPos(&line1, &y1, &x1, &line2, &y2, &x2, false);
scrl = scroll;
}
End();
if(tell)
{
ClearLine();
tell = false;
}
PutS(string);
Update(null);
if(moved)
{
scroll = scrl;
SetSelPos(line1, y1, x1, line2, y2, x2);
}
logging = false;
}
void Tellt(typed_object object, ...)
{
va_list args;
char buffer[4096];
va_start(args, object);
PrintStdArgsToBuffer(buffer, sizeof(buffer), object, args);
va_end(args);
Tell(buffer);
}
void Tellf(char * format, ...)
{
va_list args;
char string[MAX_F_STRING*10];
va_start(args, format);
vsprintf(string, format, args);
va_end(args);
Tell(string);
}
void Tell(char * string)
{
Log(string);
if(!moved)
{
Point caretPos;
GetCaretPosition(caretPos);
SetCaret(0, caretPos.y, GetCaretSize());
}
tell = true;
}
void Clear()
{
EditBox::Clear();
moved = false;
}
void NotifyCaretMove(EditBox editBox, int line, int charPos)
{
LogBox logBox = (LogBox)editBox;
if(!logBox.logging)
{
int y1, y2;
logBox.GetSelPos(null, &y1, null, null, &y2, null, false);
logBox.moved = (y1 == logBox.numLines - 1 && y2 == y1) ? false : true;
}
}
}
|