helpwin.red 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. % helpwin.red
  2. %
  3. % interfacing reduce help file to Microsoft help compiler rtf structure
  4. %
  5. % Author: Herbert Melenk, ZIB Berlin
  6. %
  7. % November 1992
  8. %
  9. fluid '(outc newl par !*font !*newline !*windows);
  10. !*windows:=t;
  11. helvetica:= "f2";
  12. courier:= "f4";
  13. % The original version of this file had initoutput() as an empty
  14. % procedure, but after the run it used shell commands to concatenate
  15. % the following text at the start and end of the generated file. To
  16. % reduce the amount of shell programming needed and keep as much as
  17. % possible in REDUCE code the (fixed) header and trailer text is
  18. % generated explicitly (albeit clumsily) here now.
  19. symbolic procedure initoutput ();
  20. begin
  21. scalar o;
  22. o := wrs outfile!*;
  23. prin2t "{\rtf1\ansi \deff0{\fonttbl{\f0\froman Tms Rmn;}";
  24. prin2t "{\f1\fdecor Symbol;}";
  25. prin2t "{\f2\fswiss Helv;}";
  26. prin2t "{\f3\fmodern pica;}";
  27. prin2t "{\f4\fmodern Courier;}";
  28. prin2t "{\f5\fmodern elite;}";
  29. prin2t "{\f6\fmodern prestige;}";
  30. prin2t "{\f7\fmodern lettergothic;}";
  31. prin2t "{\f8\fmodern gothicPS;}";
  32. prin2t "{\f9\fmodern cubicPS;}";
  33. prin2t "{\f10\fmodern lineprinter;}";
  34. prin2t "{\f11\fswiss Helvetica;}";
  35. prin2t "{\f12\fmodern avantegarde;}";
  36. prin2t "{\f13\fmodern spartan;}";
  37. prin2t "{\f14\fmodern metro;}";
  38. prin2t "{\f15\fmodern presentation;}";
  39. prin2t "{\f16\fmodern APL;}";
  40. prin2t "{\f17\fmodern OCRA;}";
  41. prin2t "{\f18\fmodern OCRB;}";
  42. prin2t "{\f19\froman boldPS;}";
  43. prin2t "{\f20\froman emperorPS;}";
  44. prin2t "{\f21\froman madaleine;}";
  45. prin2t "{\f22\froman zapf humanist;}";
  46. prin2t "{\f23\froman classic;}";
  47. prin2t "{\f24\froman roman f;}";
  48. prin2t "{\f25\froman roman g;}";
  49. prin2t "{\f26\froman roman h;}";
  50. prin2t "{\f27\froman timesroman;}";
  51. prin2t "{\f28\froman century;}";
  52. prin2t "{\f29\froman palantino;}";
  53. prin2t "{\f30\froman souvenir;}";
  54. prin2t "{\f31\froman garamond;}";
  55. prin2t "{\f32\froman caledonia;}";
  56. prin2t "{\f33\froman bodini;}";
  57. prin2t "{\f34\froman university;}";
  58. prin2t "{\f35\fscript Script;}";
  59. prin2t "{\f36\fscript scriptPS;}";
  60. prin2t "{\f37\fscript script c;}";
  61. prin2t "{\f38\fscript script d;}";
  62. prin2t "{\f39\fscript commercial script;}";
  63. prin2t "{\f40\fscript park avenue;}";
  64. prin2t "{\f41\fscript coronet;}";
  65. prin2t "{\f42\fscript script h;}";
  66. prin2t "{\f43\fscript greek;}";
  67. prin2t "{\f44\froman kana;}";
  68. prin2t "{\f45\froman hebrew;}";
  69. prin2t "{\f46\froman roman s;}";
  70. prin2t "{\f47\froman russian;}";
  71. prin2t "{\f48\froman roman u;}";
  72. prin2t "{\f49\froman roman v;}";
  73. prin2t "{\f50\froman roman w;}";
  74. prin2t "{\f51\fdecor narrator;}";
  75. prin2t "{\f52\fdecor emphasis;}";
  76. prin2t "{\f53\fdecor zapf chancery;}";
  77. prin2t "{\f54\fdecor decor d;}";
  78. prin2t "{\f55\fdecor old english;}";
  79. prin2t "{\f56\fdecor decor f;}";
  80. prin2t "{\f57\fdecor decor g;}";
  81. prin2t "{\f58\fdecor cooper black;}";
  82. prin2t "{\f59\fnil linedraw;}";
  83. prin2t "{\f60\fnil math7;}";
  84. prin2t "{\f61\fnil math8;}";
  85. prin2t "{\f62\fnil bar3of9;}";
  86. prin2t "{\f63\fnil EAN;}";
  87. prin2t "{\f64\fnil pcline;}";
  88. prin2t "{\f65\fnil tech h;}";
  89. prin2t "{\f66\fswiss Helvetica-Narrow;}";
  90. prin2t "{\f67\fmodern Modern;}";
  91. prin2t "{\f68\froman Roman;}}";
  92. terpri();
  93. princ "{\colortbl;\red0\green0\blue0;\red0\green0\blue255;";
  94. prin2t "\red0\green255\blue255;\red0\green255\blue0;";
  95. princ "\red255\green0\blue255;\red255\green0\blue0;";
  96. prin2t "\red255\green255\blue0;\red255\green255\blue255;}";
  97. princ "{\stylesheet{\s244 \fs16\up6 \sbasedon0\snext0";
  98. prin2t " footnote reference;}";
  99. prin2t "{\s245 \fs20 \sbasedon0\snext245 footnote text;}";
  100. prin2t "{\s246\li720 \i\fs20 ";
  101. prin2t "\sbasedon0\snext255 heading 9;}";
  102. prin2t "{\s247\li720 \i\fs20 \sbasedon0\snext255 heading 8;}";
  103. prin2t "{\s248\li720 \i\fs20 \sbasedon0\snext255 heading 7;}";
  104. prin2t "{\s249\li720 \fs20\ul \sbasedon0\snext255 heading 6;}";
  105. prin2t "{\s250\li720 \b\fs20 \sbasedon0\snext255 heading 5;}";
  106. prin2t "{\s251\li360 ";
  107. prin2t "\ul \sbasedon0\snext255 heading 4;}";
  108. prin2t "{\s252\li360 \b \sbasedon0\snext255 heading 3;}";
  109. prin2t "{\s253\sb120 \b\f2 \sbasedon0\snext0 heading 2;}";
  110. prin2t "{\s254\sb240 \b\f2\ul \sbasedon0\snext0 heading 1;}";
  111. prin2t "{\s255\li720 \fs20 \sbasedon0\snext255 Normal Indent;}";
  112. prin2t "{\fs20 ";
  113. prin2t "\snext0 Normal;}";
  114. prin2t "{\s2\fi-240\li480\sb80\tx480 \f11 \sbasedon0\snext2 nscba;}";
  115. prin2t "{\s3\fi-240\li240\sa20 \f11 \sbasedon0\snext3 j;}";
  116. prin2t "{\s4\li480\sa20 \f11 \sbasedon0\snext4 ij;}";
  117. prin2t "{\s5\sb80\sa20 \f11 \sbasedon0\snext5 btb;}";
  118. prin2t "{\s6\fi-240\li2400\sb20\sa20 \f11\fs20 ";
  119. prin2t "\sbasedon0\snext6 ctcb;}";
  120. prin2t "{\s7\fi-240\li480\sa40\tx480 \f11 \sbasedon0\snext7 ns;}";
  121. prin2t "{\s8\sa120 \f11\fs28 \sbasedon0\snext8 TT;}";
  122. prin2t "{\s9\fi-240\li2400\sa20 \f11 \sbasedon0\snext9 crtj;}";
  123. prin2t "{\s10\fi-240\li480\tx480 \f11 \sbasedon0\snext10 nsca;}";
  124. prin2t "{\s11\sa20 \f11 ";
  125. prin2t "\sbasedon0\snext11 bt;}";
  126. prin2t "{\s12\li240\sb120\sa40 \f11 \sbasedon0\snext12 Hf;}";
  127. prin2t "{\s13\li240\sb120\sa40 \f11 \sbasedon0\snext13 Hs;}";
  128. prin2t "{\s14\li480\sb120\sa40 \f11 \sbasedon0\snext14 RT;}";
  129. princ "{\s15\fi-2160\li2160\sb240\sa80\tx2160 \f11";
  130. prin2t " \sbasedon0\snext15 c;}";
  131. prin2t "{";
  132. prin2t "\s16\li2160\sa20 \f11 \sbasedon0\snext16 ct;}";
  133. prin2t "{\s17\li240\sa20 \f11 \sbasedon0\snext17 it;}";
  134. prin2t "{\s18\li480 \f11\fs20 \sbasedon0\snext18 nsct;}";
  135. prin2t "{\s19\fi-160\li400\sb80\sa40 \f11 \sbasedon0\snext19 nscb;}";
  136. prin2t "{\s20\fi-2640\li2880\sb120\sa40\brdrb\brdrs \brdrbtw\brdrs ";
  137. prin2t "\tx2880 \f11 \sbasedon0\snext20 HC2;}";
  138. princ "{\s21\fi-2640\li2880\sb120\sa20\tx2880 \f11";
  139. prin2t " \sbasedon0\snext21 C2;}";
  140. prin2t "{\s22\fi-240\li2400\sa20 \f11\fs20 \sbasedon0\snext22 ctc;}";
  141. prin2t "{\s23\li2160\sb160 \f11 \sbasedon0\snext23 crt;}";
  142. prin2t "{\s24\li480\sb20\sa40 \f11 ";
  143. prin2t "\sbasedon0\snext24 or;}}";
  144. terpri();
  145. princ "{\info{\author Dan Davids}{\operator Dan Davids}";
  146. prin2t "{\creatim\yr2137\mo8\dy7}";
  147. princ "{\revtim\yr1990\mo5\dy9\hr16\min54}{\version3}";
  148. prin2t "{\edmins3134}{\nofpages0}";
  149. prin2t "{\nofwords65536}{\nofchars69885}{\vern8310}}";
  150. terpri();
  151. prin2t "\ftnbj \sectd \linex576\endnhere ";
  152. prin2t "\pard\plain \sl240 \fs20 ";
  153. terpri();
  154. terpri();
  155. terpri();
  156. wrs o;
  157. end;
  158. symbolic procedure endoutput ();
  159. begin
  160. scalar o;
  161. o := wrs outfile!*;
  162. prin2t "}";
  163. wrs o
  164. end;
  165. symbolic procedure verbatim u; !*verbatim := u;
  166. symbolic procedure newfont(f);
  167. if currentfont neq f then
  168. <<fontoff(); currentfont:=f; fonton()>>;
  169. symbolic procedure fontoff();
  170. <<if !*font then channelprin2(outfile!*,"}");
  171. outc:=nil;
  172. !*font:=nil>>;
  173. symbolic procedure fonton();
  174. <<if not !*font then
  175. <<channelprintf(outfile!*,"{\%w ",currentfont); outc := nil>>;
  176. !*font:=t>>;
  177. symbolic procedure myprin2 u;
  178. <<!*newline:=nil; channelprin2(outfile!*,u)>>;
  179. symbolic procedure myprin2_protected u;
  180. <<if u memq '(!{ !}) then myprin2 "\";
  181. myprin2 u;
  182. >>;
  183. fluid '(!*verbescape);
  184. symbolic procedure emit_start_verbatim(); nil;
  185. symbolic procedure emit_end_verbatim(); nil;
  186. symbolic procedure verbprin2 u;
  187. if u = '!\ then <<myprin2 u ; !*verbescape :=t>>
  188. else
  189. if u=!$eol!$ then <<myprin2 " \par"; myterpri();!*verbescape := nil>>
  190. else
  191. if (u = '!&) then
  192. <<myprin2 "\tab "; !*verbescape:=par:=newl:=outc:=nil>>
  193. else
  194. if u memq '(!{ !}) then
  195. <<if not !*verbescape then myprin2 "\"; myprin2 u;
  196. !*verbescape := nil>>
  197. else
  198. <<myprin2 u; !*verbescape := nil>>;
  199. symbolic procedure myterpri();
  200. channelterpri outfile!*;
  201. symbolic procedure number4out n;
  202. % print number with 4 digits.
  203. << if n<10 then textout "0";
  204. if n<100 then textout "0";
  205. if n<1000 then textout "0";
  206. textout n>>;
  207. % par = t: paragraph has been terminated - no new data so far
  208. % newl = t: last character has been an EOL
  209. symbolic procedure textout(u);
  210. if par and (u=!$eol!$ or u='! ) then nil else
  211. <<fonton();
  212. if u=!$eol!$ and (!*verbatim or newl)
  213. then <<print_newline();
  214. outc:='! ;
  215. if not !*verbatim then second_newline();
  216. newl:=nil;
  217. par:=t>>
  218. else
  219. if (u = '!&) then
  220. <<myprin2 "\tab "; par:=newl:=outc:=nil>>
  221. else
  222. if (u = '!$) then
  223. newfont(if currentfont = helvetica then courier else helvetica)
  224. else
  225. if (u memq '(!{ !})) then <<myprin2 '!\; myprin2 u>> else
  226. if (u neq '! ) or (outc neq '! ) or !*verbatim
  227. then
  228. <<if u=!$eol!$ and outc neq '! then myprin2 '! ;
  229. myprin2(u); outc := u;
  230. if u=!$eol!$ then newl:=t else
  231. if u neq '! then newl:=nil;
  232. par:=nil;
  233. >>;
  234. >>;
  235. % -------- paragraph heading ---------------------------
  236. symbolic procedure par_heading(type);
  237. <<verbprin2 !$eol!$;
  238. for each x in explode type do verbprin2 x;
  239. verbprin2 ":";
  240. verbprin2 !$eol!$;
  241. >>;
  242. % -------- directory structure -------------------------
  243. symbolic procedure base_new_dir(name); nil;
  244. symbolic procedure emit_dir_new(); nil;
  245. symbolic procedure emit_dir_key u;
  246. emit_node_key u;
  247. symbolic procedure emit_dir_separator();
  248. emit_node_separator();
  249. symbolic procedure emit_dir_label u;
  250. emit_node_label u;
  251. symbolic procedure emit_dir_title u;
  252. emit_node_title(u,nil,'section);
  253. symbolic procedure emit_dir_browse(u,n);
  254. emit_node_browse(u,n);
  255. % ---- node structure
  256. symbolic procedure emit_node_separator();
  257. <<fonton();
  258. myterpri(); myterpri();
  259. channelprin2(outfile!*,"\page");
  260. myterpri(); myterpri();
  261. outc:='! ; par:=t;
  262. >>;
  263. symbolic procedure set_tab();
  264. myprin2 "\pard \tx3420 ";
  265. symbolic procedure release_tab();
  266. myprin2 "\pard \sl240 ";
  267. symbolic procedure textoutl(l);
  268. % l is a list of characters to be printed.
  269. % special action for names: \ in front of _ suppressed because
  270. % of Microsoft HC logic (don't know why).
  271. if atom l then textout l else
  272. while l do
  273. <<if not(car l = '!\) or null cdr l or not(cadr l = '!_)
  274. then textout car l;
  275. l := cdr l>>;
  276. symbolic procedure textout2(l);
  277. if atom l then myprin2 l else
  278. for each x in l do myprin2
  279. if x='! then '!_ else x;
  280. symbolic procedure printem(s);
  281. % print italic
  282. begin
  283. myprin2 "{\i ";
  284. mapc(s,'myprin2);
  285. myprin2 "} ";
  286. end;
  287. symbolic procedure printem(s);
  288. begin
  289. fontoff();
  290. myprin2 "{\f3 ";
  291. mapc(s,'myprin2_protected);
  292. myprin2 "} ";
  293. end;
  294. symbolic procedure printref u;
  295. begin scalar r;
  296. r:= get_label u;
  297. if null r then return printem u;
  298. fontoff();
  299. myterpri();
  300. myprin2 "{\f2\uldb ";
  301. mapc(u,'myprin2);
  302. myprin2 "}{\v\f2 ";
  303. mapc(r,'myprin2);
  304. myprin2 "}"; myprin2 " ";
  305. myterpri();
  306. end;
  307. symbolic procedure printnameref u;
  308. printref u;
  309. fluid '(key_database);
  310. symbolic procedure emit_node_keys u;
  311. begin scalar keys;
  312. keys := assoc(u,key_database);
  313. if null keys then return;
  314. keys := cdr keys;
  315. fonton();
  316. myterpri();
  317. myprin2 " K{\footnote \pard\plain \sl240 \fs20 K ";
  318. while keys do
  319. <<textoutl car keys; keys:= cdr keys;
  320. if keys then myprin2";">>;
  321. myprin2 "}";
  322. myterpri();
  323. end;
  324. symbolic procedure emit_node_key u;
  325. emit_hidden_node_key u;
  326. symbolic procedure emit_hidden_node_key u;
  327. if current_node!* then
  328. begin scalar q;
  329. q:= assoc(current_node!*,key_database);
  330. if null q then
  331. key_database := (current_node!* . {u}).key_database
  332. else
  333. if not member(u,cdr q) then cdr q:=u.cdr q;
  334. end;
  335. symbolic procedure emit_node_label u;
  336. <<fonton();
  337. myterpri();
  338. myprin2 "#{\footnote \pard\plain \sl240 \fs20 # ";
  339. textout2 u;
  340. myprin2 "}";
  341. myterpri();
  342. >>;
  343. symbolic procedure emit_node_title(u,dummy,type);
  344. <<fonton();
  345. myterpri();
  346. myprin2 "${\footnote \pard\plain \sl240 \fs20 $ ";
  347. textoutl u;
  348. myprin2 "}";
  349. myterpri();
  350. >>;
  351. symbolic procedure emit_node_browse(u,n);
  352. <<fonton();
  353. myterpri();
  354. myprin2 "+{\footnote \pard\plain \sl240 \fs20 + ";
  355. textout u;
  356. textout ":";
  357. number4out n;
  358. myprin2 "}";
  359. myterpri();
  360. >>;
  361. symbolic procedure print_bold u;
  362. <<fontoff();
  363. myprin2 "{\b\f2 ";
  364. mapc(u,'myprin2);
  365. myprin2 "}";
  366. >>;
  367. symbolic procedure emit_dir_header();
  368. <<fontoff();
  369. myprin2 "{\f2 \par }\pard \sl240 {\f2 \par }";
  370. myterpri();
  371. >>;
  372. symbolic procedure emit_dir_entry(name,lab);
  373. begin scalar alias;
  374. fontoff();
  375. myprin2 "{\f2 \tab}{\f2\uldb ";
  376. mapc(name,'myprin2);
  377. myprin2 "}";
  378. myterpri();
  379. myprin2 "{\v\f2 ";
  380. textout2 lab;
  381. myprin2 "}";
  382. if (alias:=assoc(lab,aliases)) then
  383. <<myprin2 " "; myprin2 cdr alias>>;
  384. print_newline();
  385. end;
  386. symbolic procedure print_newline();
  387. <<if null !*newline then
  388. <<fonton(); channelprin2(outfile!*,"\par "); channelterpri outfile!*>>;
  389. !*newline:=t
  390. >>;
  391. symbolic procedure second_newline();
  392. <<!*newline :=nil; print_newline()>>;
  393. symbolic procedure print_tab ();
  394. <<fonton(); myprin2 "\tab ">>;
  395. %------------------- printstruct -------------------------------
  396. symbolic procedure printstruct();
  397. <<terpri(); printstruct1(car record,1)>>;
  398. symbolic procedure printstruct1(r,n);
  399. <<for i:=1:n do prin2 " ";
  400. mapc(name r,'prin2);
  401. terpri();
  402. for each x in reverse seq r do
  403. printstruct1(nil . x,n+1);
  404. >>;
  405. end;