Subversion Repositories SvarDOS

Rev

Rev 1085 | Rev 1142 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1085 Rev 1141
Line 162... Line 162...
162
static enum cmd_result cmd_dir(struct cmd_funcparam *p) {
162
static enum cmd_result cmd_dir(struct cmd_funcparam *p) {
163
  const char *filespecptr = NULL;
163
  const char *filespecptr = NULL;
164
  struct DTA *dta = (void *)0x80; /* set DTA to its default location at 80h in PSP */
164
  struct DTA *dta = (void *)0x80; /* set DTA to its default location at 80h in PSP */
165
  unsigned short i;
165
  unsigned short i;
166
  unsigned short availrows;  /* counter of available rows on display (used for /P) */
166
  unsigned short availrows;  /* counter of available rows on display (used for /P) */
-
 
167
  unsigned short screenw = screen_getwidth();
167
  unsigned short wcols = screen_getwidth() / WCOLWIDTH; /* number of columns in wide mode */
168
  unsigned short wcols = screenw / WCOLWIDTH; /* number of columns in wide mode */
168
  unsigned char wcolcount;
169
  unsigned char wcolcount;
169
  struct nls_patterns *nls = (void *)(p->BUFFER + (p->BUFFERSZ / 2));
170
  struct nls_patterns *nls = (void *)(p->BUFFER + (p->BUFFERSZ / 2));
170
  char *buff2 = p->BUFFER + (p->BUFFERSZ / 2) + sizeof(*nls);
171
  char *buff2 = p->BUFFER + (p->BUFFERSZ / 2) + sizeof(*nls);
171
  unsigned long summary_fcount = 0;
172
  unsigned long summary_fcount = 0;
172
  unsigned long summary_totsz = 0;
173
  unsigned long summary_totsz = 0;
Line 207... Line 208...
207
  }
208
  }
208
 
209
 
209
  i = nls_getpatterns(nls);
210
  i = nls_getpatterns(nls);
210
  if (i != 0) nls_outputnl_doserr(i);
211
  if (i != 0) nls_outputnl_doserr(i);
211
 
212
 
-
 
213
  /* disable usage of thousands separator on narrow screens */
-
 
214
  if (screenw < 80) nls->thousep[0] = 0;
-
 
215
 
212
  /* parse command line */
216
  /* parse command line */
213
  for (i = 0; i < p->argc; i++) {
217
  for (i = 0; i < p->argc; i++) {
214
    if (p->argv[i][0] == '/') {
218
    if (p->argv[i][0] == '/') {
215
      const char *arg = p->argv[i] + 1;
219
      const char *arg = p->argv[i] + 1;
216
      char neg = 0;
220
      char neg = 0;
Line 373... Line 377...
373
        }
377
        }
374
        output(buff2 + strlen(buff2) - 10);
378
        output(buff2 + strlen(buff2) - 10);
375
        /* two spaces and NLS DATE */
379
        /* two spaces and NLS DATE */
376
        buff2[0] = ' ';
380
        buff2[0] = ' ';
377
        buff2[1] = ' ';
381
        buff2[1] = ' ';
-
 
382
        if (screenw >= 80) {
378
        nls_format_date(buff2 + 2, dta->date_yr + 1980, dta->date_mo, dta->date_dy, nls);
383
          nls_format_date(buff2 + 2, dta->date_yr + 1980, dta->date_mo, dta->date_dy, nls);
-
 
384
        } else {
-
 
385
          nls_format_date(buff2 + 2, (dta->date_yr + 80) % 100, dta->date_mo, dta->date_dy, nls);
-
 
386
        }
379
        output(buff2);
387
        output(buff2);
380
 
388
 
381
        /* one space and NLS TIME */
389
        /* one space and NLS TIME */
382
        nls_format_time(buff2 + 1, dta->time_hour, dta->time_min, 0xff, nls);
390
        nls_format_time(buff2 + 1, dta->time_hour, dta->time_min, 0xff, nls);
383
        outputnl(buff2);
391
        outputnl(buff2);
Line 417... Line 425...
417
  }
425
  }
418
 
426
 
419
  /* print out summary (unless bare output mode) */
427
  /* print out summary (unless bare output mode) */
420
  if (format != DIR_OUTPUT_BARE) {
428
  if (format != DIR_OUTPUT_BARE) {
421
    unsigned short alignpos;
429
    unsigned short alignpos;
-
 
430
    unsigned char uint32maxlen = 13; /* 13 is the max len of a 32 bit number with thousand separators (4'000'000'000) */
-
 
431
    if (screenw < 80) uint32maxlen = 10;
422
    /* x file(s) */
432
    /* x file(s) */
423
    memset(buff2, ' ', 13); /* 13 is the max len of a 32 bit number with thousand separators (4'000'000'000) */
433
    memset(buff2, ' ', uint32maxlen);
424
    i = nls_format_number(buff2 + 13, summary_fcount, nls);
434
    i = nls_format_number(buff2 + uint32maxlen, summary_fcount, nls);
425
    alignpos = sprintf(buff2 + 13 + i, " %s ", svarlang_str(37,22)/*"file(s)"*/);
435
    alignpos = sprintf(buff2 + uint32maxlen + i, " %s ", svarlang_str(37,22)/*"file(s)"*/);
426
    output(buff2 + i);
436
    output(buff2 + i);
427
    /* xxxx bytes */
437
    /* xxxx bytes */
428
    i = nls_format_number(buff2 + 13, summary_totsz, nls);
438
    i = nls_format_number(buff2 + uint32maxlen, summary_totsz, nls);
429
    output(buff2 + i);
439
    output(buff2 + i + 1);
430
    output(" ");
440
    output(" ");
431
    nls_outputnl(37,23); /* "bytes" */
441
    nls_outputnl(37,23); /* "bytes" */
432
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
442
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
433
    /* xxxx bytes free */
443
    /* xxxx bytes free */
434
    i = cmd_dir_df(&summary_totsz, drv);
444
    i = cmd_dir_df(&summary_totsz, drv);
435
    if (i != 0) nls_outputnl_doserr(i);
445
    if (i != 0) nls_outputnl_doserr(i);
436
    alignpos += 13 + 13;
446
    alignpos += uint32maxlen * 2;
437
    memset(buff2, ' ', alignpos); /* align the freebytes value to same column as totbytes */
447
    memset(buff2, ' ', alignpos); /* align the freebytes value to same column as totbytes */
438
    i = nls_format_number(buff2 + alignpos, summary_totsz, nls);
448
    i = nls_format_number(buff2 + alignpos, summary_totsz, nls);
439
    output(buff2 + i);
449
    output(buff2 + i + 1);
440
    output(" ");
450
    output(" ");
441
    nls_outputnl(37,24); /* "bytes free" */
451
    nls_outputnl(37,24); /* "bytes free" */
442
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
452
    if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
443
  }
453
  }
444
 
454