ultimatepp/uppdev/MyEcho_Test/main.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

68 lines
1.3 KiB
C++

#include "MyEcho.h"
String MyDocEdit::tipString(">");
MyApp app;
MyDocEdit::MyDocEdit()
{
ShowTip();
}
static int value = 0;
void MyDocEdit::InsertData()
{
char tmp[32];
sprintf(tmp, "value: %d\n", value++);
Insert(GetCursor(), tmp);
SetCursor(GetCursor()+strlen(tmp)+1);
}
void MyDocEdit::ShowTip()
{
dir = GetCurrentDirectory();
Insert(cursor, dir+tipString);
this->SetCursor(cursor+(dir+tipString).GetLength());
inputString.Clear();
}
char str[32];
bool MyDocEdit::Key(dword key, int count)
{
switch(key & ~(K_CTRL | K_ALT | K_SHIFT)) {
case K_ENTER:
RunCommand(inputString);
inputString.Clear();
if(GetLineCount() > MAX_CACHE_LINE)
Remove(0, GetPos(GetLineCount() - MAX_CACHE_LINE));
ShowTip();
return true;
default:
if(!(key & 0x10000) && !(key & 0x110000)) {
inputString +=(char)key;
}
break;
}
return DocEdit::Key(key, count);
}
int MyDocEdit::RunCommand(String user_input)
{
FindFile ff;
Insert(GetCursor(), "\n");
cursor++;
if(!ff.Search(AppendFileName(dir, "*")))
return false;
do {
Insert(GetCursor(), ff.GetName()+"\n");
SetCursor(GetCursor()+ff.GetName().GetLength()+1);
}
while(ff.Next());
return 0;
}
GUI_APP_MAIN
{
app.Run();
}