void ExKey::HandleEvent(TEvent& Event) { switch (Event.What) { case evKeyDown: Key = Event.Key.Code; if (!(Key & kfModifier)) // not ctrl,alt,shift, .... EndExec(1); Event.What = evNone; break; } }
int InstallerWindow::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_CLOSE: if (IsExecuting(1000 * 3)) return -1; EndExec(); InstallerUI::Terminate(); break; } return HtmlWindow::OnMessage(message, wParam, lParam); }
void ExComplete::HandleEvent(TEvent &Event) { unsigned long kb = kbCode(Event.Key.Code); int DoQuit = 0; int i = 0; if (WordsLast < 2) { if ((WordsLast == 1) && (kb != kbEsc)) { DoQuit = 1; } else { EndExec(0); Event.What = evNone; } } else if (Event.What == evKeyDown) { switch (kb) { case kbPgUp: case kbLeft: // if there would not be locale sort, we could check only // the next string, but with `locale sort` this is impossible!! // this loop is little inefficient but it's quite short & nice for (i = WordPos; i-- > 0;) if (strncmp(Words[WordPos], Words[i], WordFixed) == 0) { WordPos = i; break; } Event.What = evNone; break; case kbPgDn: case kbRight: for (i = WordPos; i++ < WordsLast - 1;) if (strncmp(Words[WordPos], Words[i], WordFixed) == 0) { WordPos = i; break; } Event.What = evNone; break; case kbHome: for (i = 0; i < WordPos; i++) if (strncmp(Words[WordPos], Words[i], WordFixed) == 0) WordPos = i; Event.What = evNone; break; case kbEnd: for (i = WordsLast - 1; i > WordPos; i--) if (strncmp(Words[WordPos], Words[i], WordFixed) == 0) WordPos = i; Event.What = evNone; break; case kbTab: while (WordPos < WordsLast - 1) { WordPos++; if (strncmp(Words[WordPos], Words[WordPos - 1], WordFixed + 1)) break; } Event.What = evNone; break; case kbTab | kfShift: while (WordPos > 0) { WordPos--; if (strncmp(Words[WordPos], Words[WordPos + 1], WordFixed + 1)) break; } Event.What = evNone; break; case kbIns: case kbUp: FixedUpdate(1); Event.What = evNone; break; case kbBackSp: case kbDel: case kbDown: FixedUpdate(-1); Event.What = evNone; break; case kbEsc: EndExec(0); Event.What = evNone; break; case kbEnter: case kbSpace: case kbTab | kfCtrl: DoQuit = 1; break; default: if (CheckASCII(Event.Key.Code&~kfShift)) { char *s = new char[WordFixed + 2]; if (s != NULL) { if (WordFixed > 0) strncpy(s, Words[WordPos], WordFixed); s[WordFixed] = (unsigned char)(Event.Key.Code & 0xFF); s[WordFixed + 1] = 0; for (int i = 0; i < WordsLast; i++) if (strncmp(s, Words[i], WordFixed + 1) == 0) { WordPos = i; if (WordFixedCount == 1) DoQuit = 1; else FixedUpdate(1); break; } delete[] s; } Event.What = evNone; } break; } } if (DoQuit) { /* int rc = 0; int l = strlen(Words[WordPos]); if (Buffer->InsText(Buffer->VToR(Orig.Row), Orig.Col, l, Words[WordPos], 1) && Buffer->SetPos(Orig.Col + l, Orig.Row)) { Buffer->Draw(Buffer->VToR(Orig.Row), Buffer->VToR(Orig.Row)); rc = 1; }*/ int rc = DoCompleteWord(); EndExec(rc); Event.What = evNone; } }
void ExISearch::HandleEvent(TEvent &Event) { int Case = BFI(Buffer, BFI_MatchCase) ? 0 : SEARCH_NCASE; ExView::HandleEvent(Event); switch (Event.What) { case evKeyDown: SetState(IOk); switch (kbCode(Event.Key.Code)) { case kbEsc: Buffer->SetPos(Orig.Col, Orig.Row); EndExec(0); break; case kbEnter: EndExec(1); break; case kbBackSp: if (len > 0) { if (stacklen > 0) { stacklen--; if (Buffer->CenterPos(stack[stacklen].Col, stack[stacklen].Row) == 0) return; } len--; ISearchStr[len] = 0; if (len > 0 && Buffer->FindStr(ISearchStr, len, Case | Direction) == 0) { SetState(INoMatch); } } else { if (Buffer->CenterPos(Orig.Col, Orig.Row) == 0) return; } break; case kbUp: Buffer->ScrollDown(1); break; case kbDown: Buffer->ScrollUp(1); break; case kbLeft: Buffer->ScrollRight(8); break; case kbRight: Buffer->ScrollLeft(8); break; case kbPgDn: Buffer->MovePageDown(); break; case kbPgUp: Buffer->MovePageUp(); break; case kbPgUp | kfCtrl: Buffer->MoveFileStart(); break; case kbPgDn | kfCtrl: Buffer->MoveFileEnd(); break; case kbHome: Buffer->MoveLineStart(); break; case kbEnd: Buffer->MoveLineEnd(); break; case kbTab | kfShift: Direction = SEARCH_BACK; if (len == 0) { strcpy(ISearchStr, PrevISearch); len = strlen(ISearchStr); if (len == 0) break; } if (Buffer->FindStr(ISearchStr, len, Case | Direction | SEARCH_NEXT) == 0) { Buffer->FindStr(ISearchStr, len, Case); SetState(INoPrev); } break; case kbTab: Direction = 0; if (len == 0) { strcpy(ISearchStr, PrevISearch); len = strlen(ISearchStr); if (len == 0) break; } if (Buffer->FindStr(ISearchStr, len, Case | Direction | SEARCH_NEXT) == 0) { Buffer->FindStr(ISearchStr, len, Case); SetState(INoNext); } break; case 'Q' | kfCtrl: Event.What = evKeyDown; Event.Key.Code = Win->GetChar(0); default: if (isAscii(Event.Key.Code) && (len < MAXISEARCH)) { char Ch = (char) Event.Key.Code; stack[stacklen++] = Buffer->CP; ISearchStr[len++] = Ch; ISearchStr[len] = 0; if (Buffer->FindStr(ISearchStr, len, Case | Direction) == 0) { SetState(INoMatch); len--; stacklen--; ISearchStr[len] = 0; Buffer->FindStr(ISearchStr, len, Case | Direction); } else { } } break; } } }
void ExASCII::HandleEvent(TEvent& Event) { int W, H; ConQuerySize(&W, &H); switch (Event.What) { case evKeyDown: switch (kbCode(Event.Key.Code)) { case kbLeft: Pos--; Event.What = evNone; break; case kbRight: Pos++; Event.What = evNone; break; case kbHome: Pos = 0; Event.What = evNone; break; case kbEnd: Pos = 255; Event.What = evNone; break; case kbLeft + kfCtrl: Pos -= 16; Event.What = evNone; break; case kbRight + kfCtrl: Pos += 16; Event.What = evNone; break; case kbUp: Pos -= W; LPos -= W; Event.What = evNone; break; case kbDown: Pos += W; LPos += W; Event.What = evNone; break; case kbEsc: EndExec(-1); Event.What = evNone; break; case kbEnter: EndExec(Pos); Event.What = evNone; break; } break; #if 0 case evMouseDown: if ((E.Mouse.X < XPos) || (E.Mouse.X >= XPos + 34) || (E.Mouse.Y < YPos) || (E.Mouse.Y >= YPos + 10)) { abort = 2; break; } do { x = E.Mouse.X - XPos - 1; y = E.Mouse.Y - YPos - 1; if ((x >= 0) && (x < 32) && (y >= 0) && (y < 8)) { X = x; Y = y; if (X >= 32) X = 31; if (Y >= 8) Y = 7; if (X < 0) X = 0; if (Y < 0) Y = 0; frames->ConSetCursorPos(X + XPos + 1, Y + YPos + 1); sprintf(s, "0%03o %03d 0x%02X", X + Y * 32, X + Y * 32, X + Y * 32); MoveStr(B, 0, 13, s, hcAsciiStatus, 13); frames->ConPutBox(XPos + 2, YPos + 9, 13, 1, B); } if (E.Mouse.Count == 2) { abort = 1; break; } gui->ConGetEvent(evMouse, &E, -1, 1); if (E.What == evMouseUp) break; } while (1); break; #endif // if 0 } }