示例#1
0
void EDirectory::HandleEvent(TEvent &Event) {
    STARTFUNC("EDirectory::HandleEvent");
    int resetSearch = 0;
    EModel::HandleEvent(Event);
    switch (Event.What) {
    case evKeyUp:
        resetSearch = 0;
        break;
    case evKeyDown:
        LOG << "Key Code: " << kbCode(Event.Key.Code) << ENDLINE;
        resetSearch = 1;
        switch (kbCode(Event.Key.Code)) {
        case kbBackSp:
            LOG << "Got backspace" << ENDLINE;
            resetSearch = 0;
            if (SearchLen > 0) {
                SearchName[--SearchLen] = 0;
                Row = SearchPos[SearchLen];
                Msg(S_INFO, "Search: [%s]", SearchName);
            } else
                Msg(S_INFO, "");
            break;
        case kbEsc:
            Msg(S_INFO, "");
            break;
        default:
            resetSearch = 0; // moved here - its better for user
            // otherwice there is no way to find files like i_ascii
            if (isAscii(Event.Key.Code) && (SearchLen < MAXISEARCH)) {
                char Ch = (char) Event.Key.Code;
                int Found;

                LOG << " -> " << BinChar(Ch) << ENDLINE;

                SearchPos[SearchLen] = Row;
                SearchName[SearchLen] = Ch;
                SearchName[++SearchLen] = 0;
                Found = 0;
                LOG << "Comparing " << SearchName << ENDLINE;
                for (int i = Row; i < FCount; i++) {
                    LOG << "  to -> " << Files[i]->Name() << ENDLINE;
                    if (strnicmp(SearchName, Files[i]->Name(), SearchLen) == 0) {
                        Row = i;
                        Found = 1;
                        break;
                    }
                }
                if (Found == 0)
                    SearchName[--SearchLen] = 0;
                Msg(S_INFO, "Search: [%s]", SearchName);
            }
            break;
        }
    }
    if (resetSearch) {
        SearchLen = 0;
    }
    LOG << "SearchLen = " << SearchLen << ENDLINE;
}
示例#2
0
void RoutineView::HandleEvent(TEvent& Event) {
  int resetSearch = 1;

  EModel::HandleEvent(Event);

  switch (Event.What) {
  case evKeyUp:
    resetSearch = 0;
    break;

  case evKeyDown:

    switch (kbCode(Event.Key.Code)) {
    case kbBackSp:
      resetSearch = 0;

      if (SearchLen > 0) {
        SearchString[--SearchLen] = 0;
        Row                       = SearchPos[SearchLen];
        Msg(S_INFO, "Search: [%s]", SearchString);
      } else Msg(S_INFO, "");
      break;

    case kbEsc:
        Msg(S_INFO, "");
      break;

    default:
      resetSearch = 0;

      if (isAscii(Event.Key.Code) && (SearchLen < MAXISEARCH)) {
        char Ch = (char)Event.Key.Code;

        SearchPos[SearchLen]      = Row;
        SearchString[SearchLen]   = Ch;
        SearchString[++SearchLen] = 0;
        int i = GetMatchingLine(Row, 1);

        if (i == -1) SearchString[--SearchLen] = 0;
        else Row = i;
        Msg(S_INFO, "Search: [%s]", SearchString);
      }
      break;
    }
  }

  if (resetSearch) {
    SearchLen = 0;
  }
}
示例#3
0
文件: s_util.cpp 项目: dmcbride/efte
int GetCharFromEvent(TEvent &E, char *Ch) {
    *Ch = 0;
    if (E.Key.Code & kfModifier)
        return 0;
    if (kbCode(E.Key.Code) == kbEsc) {
        *Ch = 27;
        return 1;
    }
    if (kbCode(E.Key.Code) == kbEnter) {
        *Ch = 13;
        return 1;
    }
    if (kbCode(E.Key.Code) == (kbEnter | kfCtrl)) {
        *Ch = 10;
        return 1;
    }
    if (kbCode(E.Key.Code) == kbBackSp) {
        *Ch = 8;
        return 1;
    }
    if (kbCode(E.Key.Code) == (kbBackSp | kfCtrl)) {
        *Ch = 127;
        return 1;
    }
    if (kbCode(E.Key.Code) == kbTab) {
        *Ch = 9;
        return 1;
    }
    if (kbCode(E.Key.Code) == kbDel) {
        *Ch = 127;
        return 1;
    }
    if (keyType(E.Key.Code) == kfCtrl) {
        *Ch = (char)(E.Key.Code & 0x1F);
        return 1;
    }
    if (isAscii(E.Key.Code)) {
        *Ch = (char)E.Key.Code;
        return 1;
    }
    return 0;
}
示例#4
0
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;
    }

}
示例#5
0
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;
        }
    }
}
示例#6
0
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
  }
}