Example #1
0
void EDirectory::DrawLine(PCell B, int Line, int Col, ChColor color, int Width) {
    char s[1024];

    MoveCh(B, ' ', color, Width);
    if (Files && Line >= 0 && Line < FCount) {
        int Year, Mon, Day, Hour, Min, Sec;
        struct tm *t;
        time_t tim;

        tim = Files[Line]->MTime();
        t = localtime(&tim);

        if (t) {
            Year = t->tm_year + 1900;
            Mon = t->tm_mon + 1;
            Day = t->tm_mday;
            Hour = t->tm_hour;
            Min = t->tm_min;
            Sec = t->tm_sec;
        } else {
            Year = Mon = Day = Hour = Min = Sec = 0;
        }

        sprintf(s, " %04d/%02d/%02d %02d:%02d:%02d %8ld ",
                Year, Mon, Day, Hour, Min, Sec, Files[Line]->Size());

        strcat(s, Files[Line]->Name());
        s[strlen(s) + 1] = '\0';
        s[strlen(s)] = (Files[Line]->Type() == fiDIRECTORY)? SLASH : ' ';

        if (Col < int(strlen(s)))
            MoveStr(B, 0, Width, s + Col, color, Width);
    }
}
Example #2
0
void ExKey::RepaintStatus() {
  TDrawBuffer B;
  int W, H;

  ConQuerySize(&W, &H);

  MoveCh(B, ' ', 0x17, W);
  ConPutBox(0, H - 1, W, 1, B);
}
Example #3
0
void ExComplete::RepaintStatus() {
  TDrawBuffer B;
  int W, H;

  // Currently use this fixed colors - maybe there are some better defines??
#define COM_NORM 0x17
#define COM_ORIG 0x1C
#define COM_HIGH 0x1E
#define COM_MARK 0x2E
#define COM_ERR  0x1C

  ConQuerySize(&W, &H);
  MoveCh(B, ' ', COM_NORM, W);

  if ((WordsLast > 0) && (WordBegin != NULL) && (Words != NULL)
      && ((Words[WordPos]) != NULL)) {
    const char *sc = STRCOMPLETE;
    int p          = sizeof(STRCOMPLETE) - 1;

    if (W < 35) {
      // if the width is quite small
      sc += p - 1; // jump to last character
      p   = 1;
    }
      MoveStr(B, 0, W, sc,        COM_NORM, W);

    // int cur = p;
      MoveStr(B, p, W, WordBegin, COM_ORIG, W);
    p += strlen(WordBegin);
    int l = strlen(Words[WordPos]);

    if (WordFixed > 0) {
      MoveStr(B, p, W, Words[WordPos], COM_MARK, W);
      p += WordFixed;
      l -= WordFixed;
    }
      MoveStr(B, p, W, Words[WordPos] + WordFixed,
            (WordFixedCount == 1) ? COM_ORIG : COM_HIGH, W);
    p += l;
    char s[100];
    sprintf(s, "] (T:%d/%d  S:%d)", WordPos + 1, WordsLast,
            (int)WordFixedCount);
    MoveStr(B, p, W, s, COM_NORM, W);

    // ConSetCursorPos(cur + WordFixed, H - 1);
  } else MoveStr(B, 0, W, STRNOCOMPLETE, COM_ERR, W);
  ConPutBox(0, H - 1, W, 1, B);
  ConShowCursor();
}
Example #4
0
void EListPort::RepaintStatus() {
    TDrawBuffer B;
    char s[80];
    int W, H;
    char SColor;

    if (View == 0 || View->MView == 0 || View->MView->Win == 0)
        return ;

    View->MView->ConQuerySize(&W, &H);

    List->UpdateList();

    List->FixPos();

    if (List->View == View)
        GetPos();

    if (View->MView->Win->GetStatusContext() != View->MView)
        return;

    View->MView->Win->SetSbVPos(TopRow, H, List->Count + (WeirdScroll ? H - 1 : 0));
    View->MView->Win->SetSbHPos(LeftCol, W, 1024 + (WeirdScroll ? W - 1 : 0));

    if (View->MView->IsActive()) // hack
        SColor = hcStatus_Active;
    else
        SColor = hcStatus_Normal;
    MoveCh(B, ' ', SColor, W);
    if (View->CurMsg == 0) {
        if (List->Title)
            MoveStr(B, 0, W, List->Title, SColor, W);
        sprintf(s, "%c%d/%d", ConGetDrawChar(DCH_V), Row + 1, List->Count);
        MoveStr(B, W - strlen(s), W, s, SColor, W);
    } else {
        MoveStr(B, 0, W, View->CurMsg, SColor, W);
    }
    View->MView->ConPutBox(0, H - 1, W, 1, B);

    if (View->MView->Win->GetStatusContext() == View->MView &&
            View->MView->Win->IsActive())
        View->MView->Win->ConSetCursorPos(0, Row - TopRow);
}
Example #5
0
void ExISearch::RepaintStatus() {
    TDrawBuffer B;
    char s[MAXISEARCH + 1];
    const char *p;
    int W, H;
    
    ConQuerySize(&W, &H);
    
    switch (state) {
    case INoMatch: p = " No Match. "; break;
    case INoPrev: p = " No Prev Match. "; break;
    case INoNext: p = " No Next Match. "; break;
    case IOk: default: p = ""; break;
    }
    
    sprintf(s, "ISearch [%s]%s", ISearchStr, p);
    MoveCh(B, ' ', 0x17, W);
    MoveStr(B, 0, W, s, 0x17, W);
    ConPutBox(0, H - 1, W, 1, B);
    ConSetCursorPos(strlen(s) - 1, H - 1);
    ConShowCursor();
}
Example #6
0
void ExASCII::RepaintStatus() {
  TDrawBuffer B;
  int W, H;

  ConQuerySize(&W, &H);

  if (Pos > 255) Pos = 255;

  if (Pos < 0) Pos = 0;

  if (LPos + W < Pos) LPos = Pos - W + 1;

  if (LPos > 255 - W) LPos = 255 - W + 1;

  if (LPos > Pos) LPos = Pos;

  if (LPos < 0) LPos = 0;

  for (int i = 0; i < W; i++) MoveCh(B + i, char(i + LPos), hcAsciiChars, 1);
  ConSetCursorPos(Pos - LPos, H - 1);
  ConShowCursor();
  ConPutBox(0, H - 1, W, 1, B);
}
Example #7
0
int GViewPeer::DrawScrollBar() {
    TDrawBuffer B;
    int NRows, NCols, I;
    int W, H;
    char fore = ConGetDrawChar(DCH_HFORE);
    char back = ConGetDrawChar(DCH_HBACK);

    ConQuerySize(&W, &H);

    if (ShowVScroll) {
        MoveCh(B, ConGetDrawChar(DCH_AUP), hcScrollBar_Arrows, 1);
        ConPutBox(W, 0, 1, 1, B);
        MoveCh(B, ConGetDrawChar(DCH_ADOWN), hcScrollBar_Arrows, 1);
        ConPutBox(W, H - 1, 1, 1, B);

        NRows = H - 2;

        if (sbVtotal <= NRows) {
            SbVBegin = 0;
            SbVEnd = NRows - 1;
        } else {
            SbVBegin = NRows * sbVstart / sbVtotal;
            SbVEnd   = SbVBegin + NRows * sbVamount / sbVtotal;
        }

        for (I = 0; I < NRows; I++) {
            if (I >= SbVBegin && I <= SbVEnd)
                MoveCh(B, fore, hcScrollBar_Fore, 1);
            else
                MoveCh(B, back, hcScrollBar_Back, 1);
            ConPutBox(W, I + 1, 1, 1, B);
        }
    }
    if (ShowHScroll) {
        MoveCh(B, ConGetDrawChar(DCH_ALEFT), hcScrollBar_Arrows, 1);
        ConPutBox(0, H, 1, 1, B);
        MoveCh(B, ConGetDrawChar(DCH_ARIGHT), hcScrollBar_Arrows, 1);
        ConPutBox(W - 1, H, 1, 1, B);

        NCols = W - 2;

        if (sbHtotal <= NCols) {
            SbHBegin = 0;
            SbHEnd = NCols - 1;
        } else {
            SbHBegin = NCols * sbHstart / sbHtotal;
            SbHEnd   = SbHBegin + NCols * sbHamount / sbHtotal;
        }

        // could be made faster
        for (I = 0; I < NCols; I++) {
            if (I >= SbHBegin && I <= SbHEnd)
                MoveCh(B, fore, hcScrollBar_Fore, 1);
            else
                MoveCh(B, back, hcScrollBar_Back, 1);
            ConPutBox(I + 1, H, 1, 1, B);
        }
    }
    if (ShowVScroll && ShowHScroll) {
        MoveCh(B, ' ', hcScrollBar_Arrows, 1);
        ConPutBox(W, H, 1, 1, B);
    }

    return 0;
}