• R/O
  • SSH
  • HTTPS

svardos: Commit


Commit MetaInfo

Revision528 (tree)
Time2021-11-26 00:23:01
Authormateuszviste

Log Message

fixed /P pagination computations

Change Summary

Incremental Difference

--- svarcom/trunk/cmd/dir.c (revision 527)
+++ svarcom/trunk/cmd/dir.c (revision 528)
@@ -99,6 +99,15 @@
9999 }
100100
101101
102+static void dir_pagination(unsigned short *availrows) {
103+ *availrows -= 1;
104+ if (*availrows == 0) {
105+ press_any_key();
106+ *availrows = screen_getheight() - 1;
107+ }
108+}
109+
110+
102111 static int cmd_dir(struct cmd_funcparam *p) {
103112 const char *filespecptr = NULL;
104113 struct DTA *dta = (void *)0x80; /* set DTA to its default location at 80h in PSP */
@@ -207,6 +216,8 @@
207216
208217 if (filespecptr == NULL) filespecptr = ".";
209218
219+ availrows = screen_getheight() - 2;
220+
210221 /* special case: "DIR drive:" (truename() fails on "C:" under MS-DOS 6.0) */
211222 if ((filespecptr[0] != 0) && (filespecptr[1] == ':') && (filespecptr[2] == 0)) {
212223 if ((filespecptr[0] >= 'a') && (filespecptr[0] <= 'z')) {
@@ -236,6 +247,7 @@
236247 for (i = 0; buff2[i] != 0; i++) if (buff2[i] == '?') buff2[i] = 0;
237248 outputnl(buff2);
238249 outputnl("");
250+ availrows -= 3;
239251 }
240252
241253 /* if dir: append a backslash (also get its len) */
@@ -250,7 +262,6 @@
250262 return(-1);
251263 }
252264
253- availrows = screen_getheight();
254265 wcolcount = 0; /* may be used for columns counting with wide mode */
255266
256267 do {
@@ -306,6 +317,8 @@
306317 if (++wcolcount == wcols) {
307318 wcolcount = 0;
308319 outputnl("");
320+ } else {
321+ availrows++; /* wide mode is the only one that does not write one line per file */
309322 }
310323 break;
311324
@@ -314,14 +327,14 @@
314327 break;
315328 }
316329
317- if ((flags & DIR_FLAG_PAUSE) && (--availrows < 2)) {
318- press_any_key();
319- availrows = screen_getheight();
320- }
330+ if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
321331
322332 } while (findnext(dta) == 0);
323333
324- if (wcolcount != 0) outputnl(""); /* in wide mode make sure to end on a clear row */
334+ if (wcolcount != 0) {
335+ outputnl(""); /* in wide mode make sure to end on a clear row */
336+ if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
337+ }
325338
326339 /* print out summary (unless bare output mode) */
327340 if (format != DIR_OUTPUT_BARE) {
@@ -336,6 +349,7 @@
336349 output(buff2 + i);
337350 output(" ");
338351 outputnl("bytes");
352+ if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
339353 /* xxxx bytes free */
340354 i = cmd_dir_df(&summary_totsz, drv);
341355 if (i != 0) outputnl(doserr(i));
@@ -345,6 +359,7 @@
345359 output(buff2 + i);
346360 output(" ");
347361 outputnl("bytes free");
362+ if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows);
348363 }
349364
350365 return(-1);
--- svarcom/trunk/history.txt (revision 527)
+++ svarcom/trunk/history.txt (revision 528)
@@ -6,6 +6,7 @@
66 === ver 2021.1 (xxxx.xx.xx) ==================================================
77
88 - prompt fixed when current drive becomes invalid (eg. empty diskette drive)
9+ - DIR: fixed /P pagination in wide mode
910
1011
1112 === ver 2021.0 (2021.11.24) ==================================================
Show on old repository browser