Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

67 řádky
2.0KB

  1. /* vdir.c - the :dir command for the c64 vim clone.
  2. *
  3. * Kept in its own unit: power c miscompiles jumps once one object file holds more
  4. * than 8 KB of code (a return in main jumped to garbage), so vim.c must stay small.
  5. */
  6. extern int redraw;
  7. /* :dir - show the disk directory over the editor, a page at a time.
  8. the drive sends it as a basic program: load address, then per line a link
  9. word, the block count, the text and a 0; a link of 0 ends it.
  10. RUN/STOP stops early, any other key pages on. returns 1 if it listed */
  11. dirlist()
  12. {
  13. int f, lo, hi, bl, bh, ch, row, col, r, p, k;
  14. char t[8];
  15. if (open(15, 8, 15, "") == 0) return 0; /* command channel first */
  16. f = open(5, 8, 0, "$");
  17. if (f == 0) {
  18. close(15);
  19. return 0;
  20. }
  21. for (r = 0; r < 25; r++) sclr(r, 0, 40);
  22. getc(5); /* load address */
  23. getc(5);
  24. row = 0;
  25. for (;;) {
  26. lo = getc(5);
  27. hi = getc(5);
  28. if (lo < 0) break;
  29. if (hi < 0) break;
  30. if (lo == 0 && hi == 0) break; /* end of directory */
  31. bl = getc(5);
  32. bh = getc(5);
  33. if (bh < 0) break;
  34. p = dnum(t, 0, bl + bh * 256);
  35. col = 0;
  36. for (k = 0; k < p; k++) spc(row, col++, t[k]);
  37. col = 5;
  38. for (;;) {
  39. ch = getc(5);
  40. if (ch <= 0) break;
  41. if (ch < 32) ch = 32; /* reverse on etc: show a blank */
  42. if (col < 40) spc(row, col++, ch);
  43. }
  44. row++;
  45. if (row == 24) {
  46. sclr(24, 0, 40);
  47. sps(24, 0, "-- more --");
  48. k = skey();
  49. for (r = 0; r < 25; r++) sclr(r, 0, 40);
  50. row = 0;
  51. if (k == 3) break;
  52. }
  53. }
  54. close(5);
  55. close(15); /* last: it closes everything */
  56. if (row > 0) {
  57. sclr(24, 0, 40);
  58. sps(24, 0, "-- any key --");
  59. skey();
  60. }
  61. redraw = 2;
  62. return 1;
  63. }

Powered by TurnKey Linux.