Exemple #1
0
void EDirectory::RescanList() {
    char Dir[256];
    char Name[256];
    int DirCount = 0;
    unsigned long SizeCount = 0;
    FileFind *ff;
    FileInfo *fi;
    int rc;

    if (Files)
        FreeList();

    Count = 0;
    FCount = 0;
    if (JustDirectory(Path, Dir, sizeof(Dir)) != 0) return;
    JustFileName(Path, Name, sizeof(Name));

    // we don't want any special information about symbolic links, just to browse files
    ff = new FileFind(Dir, "*", ffDIRECTORY | ffHIDDEN | ffLINK);
    if (ff == 0)
        return ;

    rc = ff->FindFirst(&fi);
    while (rc == 0) {
        assert(fi != 0);
        if (strcmp(fi->Name(), ".") != 0) {
            Files = (FileInfo **)realloc((void *)Files, ((FCount | 255) + 1) * sizeof(FileInfo *));
            if (Files == 0)
            {
                delete fi;
                delete ff;
                return;
            }

            Files[FCount] = fi;

            SizeCount += Files[FCount]->Size();
            if (fi->Type() == fiDIRECTORY && (strcmp(fi->Name(), "..") != 0))
                DirCount++;
            Count++;
            FCount++;
        } else
            delete fi;
        rc = ff->FindNext(&fi);
    }
    delete ff;

    {
        char CTitle[256];

        sprintf(CTitle, "%d files%c%d dirs%c%lu bytes%c%-200.200s",
                FCount, ConGetDrawChar(DCH_V),
                DirCount, ConGetDrawChar(DCH_V),
                SizeCount, ConGetDrawChar(DCH_V),
                Dir);
        SetTitle(CTitle);
    }
    qsort(Files, FCount, sizeof(FileInfo *), FileNameCmp);
    NeedsRedraw = 1;
}
Exemple #2
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);
}
Exemple #3
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;
}
Exemple #4
0
void EBuffer::DrawLine(TDrawBuffer B, int VRow, int C, int W, int& HilitX) {
  hlState State;
  int     StartPos, EndPos;

  HilitX = 0;
               MoveChar(B, 0, W, ' ', hcPlain_Background, W);

  //    if ((VRow == VCount - 1) && !BFI(this, BFI_ForceNewLine)) {
  // if (BFI(this, BFI_ShowMarkers))
  //     MoveChar(B, 0, W, EOF_MARKER, hcPlain_Markers, W);
  //    }
  if (VRow < VCount) {
    int Row     = VToR(VRow);
    PELine L    = RLine(Row);
    int    ECol = 0;

    if (Row > 0) State = RLine(Row - 1)->StateE;
    else State = 0;

    if ((BFI(this, BFI_HilitOn) == 1) && (HilitProc != 0)) HilitProc(this,
                                                                     Row,
                                                                     B,
                                                                     C,
                                                                     W,
                                                                     L,
                                                                     State,
                                                                     0,
                                                                     &ECol);
    else Hilit_Plain(this, Row, B, C, W, L, State, 0, &ECol);

    if (L->StateE != State) {
      HilitX    = 1;
      L->StateE = State;
    }

    if (BFI(this, BFI_ShowMarkers)) {
               MoveChar(B, ECol - C, W,
               ConGetDrawChar(
                 (Row == RCount - 1) ? DCH_EOF : DCH_EOL), hcPlain_Markers, 1);
      ECol += 1;
    }

    if (Row < RCount) {
      int f;
      int Folded = 0;
      static char fold[20];
      int l;

      f = FindFold(Row);

      if (f != -1) {
        int foldColor;

        if (FF[f].level < 5) foldColor = hcPlain_Folds[FF[f].level];
        else foldColor = hcPlain_Folds[4];

        if (FF[f].open == 1) {
          l = sprintf(fold, "[%d]", FF[f].level);
          MoveStr(B, ECol - C + 1, W, fold, foldColor, 10);
          ECol += l;
        } else {
          if (VRow < VCount - 1) {
            Folded = Vis(VRow + 1) - Vis(VRow) + 1;
          } else if (VRow < VCount) {
            Folded = RCount - (VRow + Vis(VRow));
          }
          l = sprintf(fold, "(%d:%d)", FF[f].level, Folded);
          MoveStr(B, ECol - C + 1, W, fold, foldColor, 10);
          ECol += l;
          MoveAttr(B, 0, W, foldColor, W);
        }
      }
    }

    if ((BB.Row != -1) && (BE.Row != -1) && (Row >= BB.Row) && (Row <= BE.Row)) {
      switch (BlockMode) {
      case bmLine:
        StartPos = 0;

        if (Row == BE.Row) EndPos = 0;
        else EndPos = W;
        break;

      case bmColumn:
        StartPos = BB.Col - C;

        if (Row == BE.Row) EndPos = BB.Col - C;
        else EndPos = BE.Col - C;
        break;

      case bmStream:

        if ((Row == BB.Row) && (Row == BE.Row)) {
          StartPos = BB.Col - C;
          EndPos   = BE.Col - C;
        } else if (Row == BB.Row) {
          StartPos = BB.Col - C;
          EndPos   = W;
        } else if (Row == BE.Row) {
          StartPos = 0;
          EndPos   = BE.Col - C;
        } else {
          StartPos = 0;
          EndPos   = W;
        }
        break;

      default:
        StartPos = EndPos = 0;
        break;
      }

      if (BFI(this, BFI_SeeThruSel)) MoveBgAttr(B,
                                                StartPos,
                                                W,
                                                hcPlain_Selected,
                                                EndPos - StartPos);
      else MoveAttr(B, StartPos, W, hcPlain_Selected, EndPos - StartPos);
    }

    if (BFI(this, BFI_ShowBookmarks)) {
      int i = 0;
      char  *Name;
      EPoint P;

      while ((i = GetBookmarkForLine(i, Row, Name, P)) != -1) {
        if (strncmp(Name, "_BMK", 4) == 0) {
          // User bookmark, hilite line
          if (BFI(this, BFI_SeeThruSel)) MoveBgAttr(B, 0, W, hcPlain_Bookmark, W);
          else MoveAttr(B, 0, W, hcPlain_Bookmark, W);
          break;
        }
      }
    }

    if ((Match.Row != -1) && (Match.Col != -1)) {
      if (Row == Match.Row) {
        if (BFI(this, BFI_SeeThruSel)) MoveBgAttr(B,
                                                  Match.Col - C,
                                                  W,
                                                  hcPlain_Found,
                                                  MatchLen);
        else MoveAttr(B, Match.Col - C, W, hcPlain_Found, MatchLen);
      }
    }
  } else if (VRow == VCount) {
    if (BFI(this, BFI_ShowMarkers)) MoveChar(B, 0, W, ConGetDrawChar(
                                               DCH_END), hcPlain_Markers, W);
  }
}