home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / sharew / exoten / rec / scr.rec < prev    next >
Encoding:
Text File  |  1989-09-13  |  8.9 KB  |  312 lines

  1. [SCR.REC]
  2. [6.9.89]
  3. [G. Cisneros, 10.86, 8.89]
  4.  
  5. [A screen editor under MS-DOS]
  6.  
  7. {
  8.  
  9. [*** Screen control subroutines using interrupt 16 ***]
  10.  
  11. (0''CLpL'1'$r&S;) 0        [address of subr. 1 to PDL [CS:EP]]
  12.  
  13. [mov di,(PX)        push di            mov 4[di],cx
  14.  mov ax,[di]        int 10H            mov 6[di],dx
  15.  mov bx,2[di]        pop di            ret
  16.  mov cx,4[di]        mov [di],ax
  17.  mov dx,6[di]        mov 2[di],bx                ]
  18. (@0'C3065589044D89025D8905895F10CD5706558B044D8B025D8B058B0000BF'Hv
  19. pL'2'$r&S'C3'HvL) 1
  20.  
  21. (@1;) 2            [initialize INT 10H subroutine]
  22.  
  23. (pL@0uLS@1) 3        [do interrupt 10H given register block]
  24.  
  25. (@3L;) 4        [interrupt and lift block]
  26.  
  27. [only ah (top) & al (next) on the PDL]
  28. (pGm%            [save function number (ah), make a byte]
  29.  m%n            [make a byte out of (al)]
  30.  |0|0|0|        [other registers have 0s]
  31.  @3            [int 10h]
  32.  pLn
  33.  15=um^^gmLLnn;        [fn=15, return current display page & mode (top)]
  34.  8=gmLLn;        [fn=8,  return character at cursor]
  35.  3=4+,0&S;        [fn=3,  return block with cursor position]
  36.  LLL;) 5
  37.  
  38. [*** Chars to next tab stop ***]
  39. (pG8/L8&-;) 8
  40.  
  41. [*** Home cursor ***]
  42. (0,2@5;) h
  43.  
  44. [*** Scrolling primitives ***]
  45. {
  46.  (%6,0m;) u        [scroll up full screen, (top = # of lines)]
  47.  
  48.  (%7,0m;) d        [scroll down full screen, (top = # of lines)]
  49.  
  50.  (256*m%7;) o        [open lines (top: row; next: # of lines)]
  51.  
  52.  (256*m%6;) c        [close lines (top: row; next: # of lines)]
  53.  
  54.  (256*mm        [erase to eol: top = row #]
  55.   1792pG|        [blank (fn 7, 0 lines) to attribute 7]
  56.   80n-lyG+|        [upper left corner: next = # of blanks]
  57.   n79+|            [lower right corner: to last column]
  58.   @4) b
  59.  
  60.  (256*m            [top: starting row (& column 0)]
  61.   pG256*lyG+79+        [next: # of lines -1  => ending row & column 79]
  62.   m^%7%|1792|nn&||@4) e    [clear a set of lines]
  63.  
  64.  (@@%|1792|n|'174F'H|@4;;)} s        [scroll main]
  65.  
  66. ((`);R3%=_;L;) *            [panic exit]
  67.  
  68. [*** Type on status line at column given by top ***]
  69. (@cm512,0|0|n%|24%|@4TLn@4;) S
  70.  
  71. [*** Save current cursor position on PDL complement ***]
  72. (0,3@5pL512v^^0&Sm;) c
  73.  
  74. [*** Move cursor to ([0],[1]) ***]
  75. (512,0|0|0$r(80=0pGpG0$S2$S1$r^1$S;;)%|    [start block, get column]
  76.     1$rpG32767(N)            [is row # negative?]
  77.         ~'d'@s@h            [yes, scroll down,]
  78.         j2$rb<q2$SLj0@LJj0@l>        [redraw,]
  79.         0pG1$S%|@t;            [set cursor;]
  80.     24/0=%|@4;            [no, position if <25]
  81.     L^pG'u'@s24&-pG1$S%|        [else scroll up,]
  82.     pG@4Z<j0@LJj0@l>@t;q        [redraw, position]
  83. ) C
  84.  
  85. [*** Adjust block before setting cursor ***]
  86. (pL6+0$r%&S@4;) t
  87.  
  88. [*** Bracket to end of line ***]
  89. [((80a;LZ;)q((d);10%EjL;A:)Y;) b]
  90.  
  91. [*** Number of screen lines to end of current line ***]
  92. (j(10%U;Z;)qL0$r(9%Ez@8+:10%(E)A^:;)&Yj80/&L;) B
  93.  
  94. [*** Adjust cursor and WS pointers when moving from line to line ***]
  95. (0$r=Jq2$SLz;9%EzpGm8/L8&-(lyG+pG0$rNnL;BjLnpG0$S;):10%(Ej)A^:pG0$S:) l
  96.  
  97. [*** SP, CR, LF on short lines ***]
  98. (d' 'TLdL2573TL;;) +
  99.  
  100. [*** Type a single line, expanding tabs ***]
  101. (80=0@+;9%Ez@8pG(d' 'TL:;)+:10%(Ej)ABQTLz^:80&-@+;) L
  102.  
  103. [*** Redraw to the bottom of the screen ***]
  104. ((AB)L;                    [done if no more text]
  105.  (d);                    [done if 24 lines out]
  106.  j0@L                    [type out a single line]
  107.  (10%Ez;;)                [skip LF in WS]
  108. :;) R
  109.  
  110. [*** Fill screen from WS start ***]
  111. (0'd'@s@h                [clear window, home cursor]
  112. J(AB24@R;' 'TL8%TL;)            [redraw 24 lines]
  113. Jj@h0pGpG0$S1$S2$S;) D            [reset cursor and pointers]
  114.  
  115. [*** To end of workspace ***]
  116. (@*(A);            [no advance: we're there]
  117. BZ<q&L1920(N;>0)    [more than a screenful to the end?]
  118. 0,0$r(80=^(AB0);10%EzL^0:9%Ez@8+:A^:L;)    [no, count lines]
  119. Jj>pG20N(d@\:;)@d:    [move cursor if less than 20 lines]
  120. LZz0,960m(B10%E^12=znL;ndm:L;)Z<@D>L1:) E
  121.  
  122. [*** Find a string ***]
  123. ((4$r^^y0(=)G;L'Search string? '4@q''=)jV@v;;) V
  124.  
  125. [*** Redraw after finding ***]
  126. (qLJ<Y0@E>    [fake end of workspace]
  127.  0=1$rpG22NL;    [stop if no lines left to draw and not on last row]
  128.  LqLZ<j0$r@L>(10%Ez;;)23,1$r-@R@CY;) v
  129.  
  130. [*** Replace a string ***]
  131. ((6$r0=0,4$r^^S;L;)
  132. (4$r^^y0(=)G;
  133. {(;)I (L'Search string? '4@q''(=)' Replacement?  '5@qL1,6$S;)};)
  134. jU@v'Replace? (Yes/No/Rest/Cancel) '0@q
  135. ((pG\122NpG\97&N\32-%;;)
  136. 'Y'=@B4$r^^ypGmGED5$r^^ypGmGI(nnN@r;@e;)5$r^^r(d@>:;);
  137. 'N'=4$r^^r(d@>:;);
  138. 'C'=0,6$S;
  139. 'R'(=)LR:(@B4$r^^ypGmGED5$r^^ypGmGI(nnN@r;@e;)5$r^^r(d@>:;)4$r^^yGjU@v:;);)
  140. ;@I;) X
  141.  
  142. [*** Query for a string or a character ***]
  143. (@cm
  144. "                                                                             "
  145. 1@S512,0|0|'1801'H|@4TLn(0=n@4R;m(@j8%=:24%=:;)pGn$rPn@4;)@I;) q
  146.  
  147. [*** Read a string ***]
  148. (R24%=24%;8%=8%;13%="";(pG\127&N;pG\31N;)9%(=9%)L:
  149.     T@cnpL6+1G&L\76="";L
  150.     @j8%=L8%T' 'TLTL: 24%=L8%T' 'TLTL24%;
  151.     |;) j
  152.  
  153. [*** Advance cursor one byte ***]
  154. (2$r
  155.     (9%Ez0$r@8+0$S^;            [tab]
  156.      (10%E;(AB)L;0$r^80=;0$S^)        [other]
  157.      AL1$r^1$S0,0$S0;A;)
  158. 2$S @C;) >
  159.  
  160. [*** Advance cursor one line ***]
  161. (qL0$r2$rpGbjZ<79,0$Sj0@l>            [to end of line]
  162.   (@>;2$S0$SYj)                    [try advancing one]
  163.   L0$SLZ<j0@l>@C;;) \
  164.  
  165. [*** Find start of this line, bracket last portion ***]
  166. (qL((B);10%Ez;:)qL&YjY
  167.     <qL0(80=LqL0:9%Ez@8+:A^:;)0$SYq2$SLz>;) F
  168.  
  169. [*** Retract cursor one byte ***]
  170. (Bj2$r1-,2$S
  171.    (9%Ej(0$rd0$S;@F1$r1-,1$S;)            [tab?]
  172.     (@C0,8@5' '(=)L0$r^0$S;            [yes, skip back]
  173.      0$r(d);pG8/L7=L;L0$S:);
  174.    (10%Ej;0$rd0$S)            [no, simple backspace]
  175.       @F1$r1-,1$S;;)            [which may back into previous line]
  176. @C;;) <
  177.  
  178. [*** Retract cursor one line ***]
  179. (j2$rb(B)z;
  180. Aj0pGpG2$S$pGrmS@<npG0$rN0$Sj2$r(b;'bsp'@PL;)<j0@l>@C;L;) ^
  181.  
  182. [*** Cursor to start of line ***]
  183. (j2$rbj0pGpG$S2$S@C;) g
  184.  
  185. [*** Cursor to end of line ***]
  186. (@gZ<0(80=79Bj;9%E(pG71N@8+z;jJ><z;):10%(Ej)A^:;)0$SJq2$SLz>@C;) d
  187.  
  188. [*** Text addition ***]
  189. (13%=                    [CR or LF]
  190.     ((A)10%I' 'TL@>' 'TL8%TL;        [WS end: insert LF]
  191.      B10%Ej10%I@>1,1$r'o'@s@C' 'TL@C;
  192.      j80,0$r-,1$r'b'@s            [clean to EOL]
  193.      1$r23=1'u'@s0pG$S10%IzqL@CZ<j0@L>Y@C;    [on last screen line]
  194.      ^1$S@B10%Iz0pGpG$S2$S@BpGm
  195.         (-,0=1,1$r'o'@s;L;)n@Z        [open a line if needed]
  196.      pGmqLm1$r'e'@s@C@K@C;);        [rewrite]
  197.  
  198. 10%Ej    m0$r(lyG9%=@8pG(d' 'TL:;)+;TL^;)nI@>        [addition at LF]
  199.     (80=1,1$r'o'@s@C;L;)' 'TL@C;
  200.  
  201. 9%=                    [HT]
  202.     ((A)9%I0$r@8^(d' 'TL:;)L@>;B
  203.     3$r0=(9%Ej;@B1aD9%I@e;);            [replace with HT]
  204.     L@B9%I@e;);                    [insert HT]
  205.  
  206. 3$r0=                            [replace]
  207.     (9%E(0$r@8,1(=L)LL@B&1aDI&@r;);            [replace HT]
  208.     ABfBTL@>;                    [replace non HT]
  209.     TI' 'TL@>;);                    [add at end]
  210.  
  211. L                            [insert]
  212.     (9%Ej(0$r@8,2&NLTI@>;L);            [insert at HT]
  213.     AB@B&I@e;                    [insert other]
  214.     TI' 'TL@>;);                    [add at end]
  215.  
  216. ) T
  217.  
  218. [*** Type as many blanks as given on the PDL ***]
  219. [((pG8N;8-'        'TL:)(d' 'TL:;);) k]
  220.  
  221. [*** Text removal ***]
  222. (j(A);B@B(10%E^;;)1aD@r;;) z
  223.  
  224. [** erase to end of line ***]
  225. (j(A);B10%E;@B(10%U;Z;)D@r;) w
  226.  
  227. [** erase line ***]
  228. (@g(A);B@B(10%V^;Z;)D@r;) u
  229.  
  230. [*** Redraw after addition ***]
  231. (@BpGm&-qLm(0=;@Z0=;1$r^'o'@s;)
  232. @C@K@>;) e
  233.  
  234. [*** Limit bottom row ***]
  235. (pG1$r+23N;d:) Z
  236.  
  237. [*** Redraw after removal ***]
  238. (@BpGm-(pG32767N;~^;)qLm(0=;@Z0=;pGpG1$r^'c'@s24,1$r-&-,0$rm
  239.             @xpG24&-,256*m512,0|0|n|@4@R;)
  240. @ClyGY@K@C;) r
  241.  
  242. [*** Redraw current line ***]
  243. {(0=' 'TL8%TL;0,3@5pd+gmLLn\'b'@s;) +
  244. (Z<j0$r@L>nn@Z(10%EL;@R;)Yj;)} K
  245.  
  246. [*** Skip screen lines ***]
  247. (dn(80=;9%Ez@8+:10%EzL;A^:Lm)0m:nL;) x
  248.  
  249. [*** Show free space ***]
  250. (''wpL6+ymrn-#'===='|'Free: '&|5@SL;) f
  251.  
  252. [*** Show file name (from var 29) ***]
  253. (29$r0=;yw('\'Fz:;)ZQ&w56@S;) A
  254.  
  255. [*** Type status line ***]
  256. ("===================REC Workspace Screen Editor===File: ======================"
  257. 1@S@f@A@i;) I
  258.  
  259. [*** Show insert status ***]
  260. (3$r(0='======';L'INSERT';)70@S;) i
  261.  
  262. [*** Pause with a prompt on the status line ***]
  263. ('==========='5@S5@SR@f;) P
  264.  
  265. [*** MAIN PROGRAM ***]
  266.  
  267. (9(dpG$pGpGmrm0&S:;)            [initialize variables 0-8]
  268. 1,3$S                    [start in insert mode]
  269. 62c0&Sml4$S                [find string buffer]
  270. 62c0&Sml5$S                [replacement string buffer]
  271. ['xyz'p|l|''w]
  272. (@2)                    [initialize INT 10H routines]
  273. 0,15@5&\8$S                [get mode, save active page #]
  274. \pG7$S(7=7;L3;)0@5            [get mode, set 80x25 mode]
  275. 0,5@5                    [set page 0]
  276.  
  277. J(13%FD:;)                [remove CRs]
  278. @D@I@f                    [write first screenful]
  279. 0,28$(pGr0=;a@v;L;)S            [cursor at [28], if not 0]
  280.  
  281.    (R    ((10%=;13%=;)13%;9%=9%;)@T@f:    [LF, CR, HT]
  282.     (pG\126NpG\32&N@T;)@f:        [text]
  283.     200% = @^:            [up arrow]
  284.     203% = @<:            [left arrow]
  285.     205% = (@>;;):            [right arrow]
  286.     208% = @\:            [down arrow]
  287.     201% = 24(@*d@^:;):        [Pg Up]
  288.     209% = 24(@*d@\:;):        [Pg Dn]
  289.     199% = @D:            [Home]
  290.     207% = 0@EL:            [End]
  291.     187% = @V:            [F1: find]
  292.     232% = 0,4$r^^S:        [Alt F1: cancel find string]
  293.     188% = @X:            [F2: replace]
  294.     233% = 0,6$S:            [Alt F2: cancel replacement]
  295.     189% = @g:            [F3: left margin]
  296.     190% = @d:            [F4: right margin]
  297.     210% = 1,3$r-,3$S@i:        [ins toggle]
  298.     211% = @z@f:            [Delete]
  299.     8%   = ((B);A@<@z;)@f:        [BS]
  300.     24%  = @u@f:            [^X: erase line]
  301.     26%  = @w@f:            [^Z: erase to eol]
  302.     5%   = ;            [^E: exit]
  303.     22%  = R@T@f:            [^V: next char literal]
  304.     17%  = ('Quit? (y/n)'@P('y'=;'Y'=;)JZD;);    [^Q: quit]
  305.     L:)
  306. 8$r5@5,7$r0@5        [reset original active page and mode]
  307. J(10%Fj13%IAA:;)J    [restore CR before LF]
  308. [{(2573TL;)+(!TL@+''w!TL@+!TL@+p|l|!TL@+R(3%=_;L;)!TL;)}]
  309. nLnL9(dnnS:;)        [restore variables]
  310. ;)
  311. }
  312. [end]