111 if(background!=
nullptr)
112 p.setBrush(*background);
113 p.drawRect(0,0,w(),h(),
114 0,0,p.brush().w(),p.brush().h());
118 int y = h() - margins().bottom;
120 for(
size_t i=log.size(); i>0;) {
122 fnt.drawText(p, margins().left, y, log[i]);
124 if(i+1==log.size()) {
125 int x = margins().left + fnt.textSize(log[i].data(),log[i].data()+cursPos).w;
126 float a = float(Application::tickCount()%2000)/2000.f;
127 p.setBrush(Color(1,1,1,a));
128 p.drawRect(x,y,1,fnt.pixelSize());
137 if(Event::K_F1<=e.key && e.key<=Event::K_F12) {
142 if(e.key==Event::K_ESCAPE) {
146 if(e.key==Event::K_Left) {
151 if(e.key==Event::K_Right) {
152 if(cursPos<log.back().size())
156 if(e.key==Event::K_Up) {
158 if(histPos<cmdHist.size()) {
160 currCmd = log.back();
161 log.back() = cmdHist[cmdHist.size()-1-histPos];
162 cursPos = log.back().size();
165 histPos = size_t(cmdHist.size()-1);
169 if(e.key==Event::K_Down) {
170 if(histPos==
size_t(-1))
173 if(histPos<cmdHist.size())
174 log.back() = cmdHist[cmdHist.size()-1-histPos];
176 log.back() = currCmd;
177 cursPos = log.back().size();
181 if(e.key==Event::K_C && (e.modifier&Event::M_Command)==Event::M_Command) {
182 log.emplace_back(
"");
185 histPos = size_t(-1);
189 if(e.key==Event::K_Back) {
190 if(0<cursPos && cursPos<=log.back().size()) {
191 log.back().erase(--cursPos,1);
195 if(e.key==Event::K_Delete) {
196 if(log.back().size()>cursPos) {
197 log.back().erase(cursPos,1);
201 if(e.key==Event::K_Tab) {
202 if(log.back().size()>0 && marvin.
autoComplete(log.back()))
203 cursPos = log.back().size();
206 if(e.key==Event::K_Return) {
207 if(log.back().size()>0) {
208 const auto cmd = log.back();
209 const size_t cmdId = log.size()-1;
210 cmdHist.emplace_back(cmd);
212 if(!marvin.
exec(cmd) && cmdId<log.size()) {
213 log[cmdId] =
"Unknown command : " + cmd;
217 histPos = size_t(-1);
223 if((
'a'<=e.code && e.code<=
'z') || (
'A'<=e.code && e.code<=
'Z') ||
224 (
'0'<=e.code && e.code<=
'9') || e.code==
' ' || e.code==
'.' || e.code==
'_' || e.code==
'-')
228 log.back().insert(cursPos,1,ch);
Main application window handling game rendering and input.
Main application window for OpenGothic.