Ejemplo n.º 1
0
int draw_number(const char *num, int x, int y)
{
    int len = strlen(num);
    int i;
    int written = 0;

    int valid_length = digitlen(num);

    if (x < 0)
        x = (COLS - WIDTH(valid_length)) / 2;

    if (y < 0)
        y = (LINES - HEIGHT) / 2;


    for (i = 0; i < len; ++i)
    {
        char glyph = map_glyph(num[i]);

        if (glyph < 0)
            continue;

        draw_digit(glyph, x, y);
        x += DIGIT_SPACING + DIGIT_WIDTH;

        ++written;
    }

    return written;
}
Ejemplo n.º 2
0
void printcounts(int** counts, char** filenames, int file_i, SeqcOpts opts) {

  int widestdigit = 3;
  // if we are printing totals we need those character widths too 
  int i, j;
  i = opts.totals ? 0 : 1;

  for (; i < file_i; i++) {
    for(j = 0; j < 3; j++) {
      if (digitlen(counts[i][j]) > widestdigit)
        widestdigit = digitlen(counts[i][j]);
    }
  }

  for (i = 1; i < file_i+1; i++) {
    printf(" ");
    if (opts.countlong) {
      printf("%*d ", widestdigit, counts[i][0]);
    }
    if (opts.countnuc) {
      printf("%*d ", widestdigit, counts[i][1]);
    }
    if (opts.countseq) {
      printf("%*d ", widestdigit, counts[i][2]);
    }
    printf("%s\n", filenames[i]);
  }  

  if (opts.totals) {

    printf(" ");

    if (opts.countlong) {
      printf("%*d ", widestdigit, counts[0][0]);
    } else {
      if (opts.countnuc) {
        printf("%*d ", widestdigit, counts[0][1]);
      }
      if (opts.countseq) {
        printf("%*d ", widestdigit, counts[0][2]);
      }
    }
    printf("%s\n", filenames[0]);
  }
}