helpunx.red 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. % helpunx.red
  2. %
  3. % interfacing reduce help file to unix GNU texinfo structure
  4. %
  5. % Author: Herbert Melenk, ZIB Berlin
  6. %
  7. % November 1992
  8. %
  9. % PSL dependent
  10. %-------------------- output ------------------------------------
  11. fluid '(outc newl par !*font !*newline nodechain
  12. prevnode upnodes !*terpri);
  13. symbolic procedure initoutput();
  14. <<
  15. upnodes := {"Top"};
  16. if null nodechain then
  17. nodechain:={{"dummy 2",nil,"dummy 1"}};
  18. prevnode :={nil};
  19. channellinelength(outfile!*,200);
  20. myprin2 bldmsg("@setfilename %w.info",package);
  21. myterpri();
  22. >>;
  23. symbolic procedure endoutput();
  24. nil;
  25. symbolic procedure verbatim(u);
  26. <<myterpri();
  27. if not u then toggle_line();
  28. myprin2 if u then "@example" else "@end example";
  29. myterpri();
  30. if u then toggle_line();
  31. if not u then
  32. <<myprin2t "@*"; myprin2t "@noindent"; >>;
  33. !*verbatim:=u;
  34. >>;
  35. symbolic procedure toggle_line();
  36. <<myterpri!*(); for i:=1:60 do myprin2 "_"; myterpri();>>;
  37. symbolic procedure newfont(f);
  38. if currentfont neq f then
  39. <<fontoff(); currentfont:=f; fonton()>>;
  40. symbolic procedure fontoff();
  41. <<%%% if !*font then channelprin2(outfile!*,"}");
  42. outc:=nil;
  43. !*font:=nil>>;
  44. symbolic procedure fonton();
  45. <<if not !*font then
  46. <<%%% channelprintf(outfile!*,"{\%w ",currentfont);
  47. outc := nil>>;
  48. !*font:=t>>;
  49. symbolic procedure myprin2 u;
  50. if not(u eq '!\) then
  51. <<!*newline:=nil; !*terpri :=nil; channelprin2(outfile!*,u)>>;
  52. fluid '(!*verbescape);
  53. symbolic procedure emit_start_verbatim();
  54. << myprin2 "@example"; myterpri();toggle_line()>>;
  55. symbolic procedure emit_end_verbatim();
  56. << toggle_line();myterpri();myprin2 "@end example"; myterpri();>>;
  57. symbolic procedure verbprin2 u; (textout u) where !*verbatim=t;
  58. symbolic procedure verbprin2 u;
  59. if u = '!\ then <<myprin2 '!@ ; !*verbescape :=t>>
  60. else
  61. if u=!$eol!$ then <<myprin2 " "; myterpri();!*verbescape := nil>>
  62. else
  63. if (u = '!&) then
  64. <<myprin2 " "; !*verbescape:=par:=newl:=outc:=nil>>
  65. else
  66. if u memq '(!{ !}) then
  67. <<if not !*verbescape then myprin2 "@"; myprin2 u;
  68. !*verbescape := nil>>
  69. else
  70. <<myprin2 u; !*verbescape := nil>>;
  71. symbolic procedure myprin2t u;
  72. <<!*newline:=t; channelprin2(outfile!*,u); channelterpri outfile!*;>>;
  73. symbolic procedure myterpri!*();
  74. !*terpri or myterpri();
  75. symbolic procedure myterpri();
  76. <<channelterpri outfile!*; !*terpri := t>>;
  77. symbolic procedure textout(u);
  78. if par and (u=!$eol!$ or u='! ) then nil else
  79. if u='!{ or u='!} then nil else
  80. <<fonton();
  81. if u=!$eol!$ and (!*verbatim or newl)
  82. then <<myprin2 u; %%% print_newline();
  83. outc:='! ;newl:=nil; par:=t>>
  84. else
  85. if (u = '!&) then
  86. <<myprin2 " "; par:=newl:=outc:=nil>>
  87. else
  88. if (u = '!$) then
  89. newfont(if currentfont = helvetica then courier else helvetica)
  90. else
  91. if (u neq '! ) or (outc neq '! ) or !*verbatim
  92. then
  93. <<myprin2(u); outc := u;
  94. if u=!$eol!$ then newl:=t else
  95. if u neq '! then newl:=nil;
  96. par:=nil;
  97. >>;
  98. >>;
  99. symbolic procedure textoutl(l);
  100. if null l then nil else
  101. if atom l then textout l else
  102. for each x in l do textout x;
  103. symbolic procedure textout2(l);
  104. if atom l then myprin2 l else
  105. for each x in l do myprin2
  106. if x='! then '!_ else x;
  107. % -------- paragraph heading ---------------------------
  108. symbolic procedure par_heading(type);
  109. <<verbprin2 !$eol!$;
  110. verbprin2 "@noindent"; verbprin2 !$eol!$;
  111. for each x in explode type do verbprin2 x;
  112. verbprin2 ":";
  113. verbprin2 !$eol!$; verbprin2 !$eol!$;
  114. >>;
  115. % -------- directory structure -------------------------
  116. fluid '(!*in!-directory actdir);
  117. symbolic procedure base_new_dir name;
  118. % initial call for new section
  119. <<% name := mycompress name;
  120. prevnode := nil . prevnode;
  121. upnodes:= name.upnodes;
  122. >>;
  123. symbolic procedure emit_dir_new();
  124. % closing a section.
  125. << if upnodes then
  126. <<actdir := car upnodes; upnodes:=cdr upnodes>>;
  127. if prevnode then prevnode:=cdr prevnode;
  128. >>;
  129. symbolic procedure emit_dir_key u; nil;
  130. symbolic procedure emit_dir_entry(name,lab);
  131. begin scalar n,alias;
  132. if not !*in!-directory then
  133. <<myterpri(); myprin2 "@menu"; myterpri();!*in!-directory:=t;>>;
  134. myprin2 "* ";
  135. textoutl if atom lab then name else lab;
  136. myprin2 "::";
  137. n:=length (if atom lab then name else lab)+2;
  138. for i:=n:25 do myprin2 " ";
  139. if (alias:=assoc(lab,aliases)) then
  140. <<myprin2 " "; textoutl cdr alias; myprin2 " ";>>;
  141. %%% Klappaltar textoutl name;
  142. if find_type(name) then textoutl find_type(name);
  143. myterpri();
  144. end;
  145. fluid '(typen);
  146. typen := for each x in
  147. '("package" "operator" "type" "variable" "concept"
  148. "switch" "command" "introduction" "declaration")
  149. collect explode2 x;
  150. symbolic procedure find_type(name);
  151. <<while memq('! ,name) do name:=cdr name;
  152. if name member typen then name else nil
  153. >>;
  154. symbolic procedure emit_dir_header(); nil;
  155. symbolic procedure emit_dir_separator();
  156. <<myprin2 "@end menu";
  157. myterpri(); myterpri();
  158. !*in!-directory:=nil;
  159. prevnode:=actdir . cdr prevnode;
  160. >>;
  161. symbolic procedure emit_dir_label u; nil;
  162. symbolic procedure emit_dir_title u;
  163. % emit_node_title (nil,u,'section);
  164. emit_node_title (u,u,'section);
  165. symbolic procedure emit_dir_browse(u,n); nil;
  166. % ---- node structure
  167. symbolic procedure emit_node_separator();
  168. <<
  169. myterpri(); myterpri();
  170. outc:='! ; par:=t;
  171. >>;
  172. symbolic procedure printem(s);
  173. begin
  174. fontoff();
  175. myprin2 "@titlefont{";
  176. mapc(s,'myprin2);
  177. myprin2 "}";
  178. end;
  179. symbolic procedure printem(s);
  180. <<mapc(raisestring s,'myprin2);
  181. myprin2 '! ;
  182. >>;
  183. symbolic procedure printref u;
  184. begin scalar l;
  185. l := get_label u;
  186. if l then
  187. <<myprin2 "[@pxref{";
  188. mapc(l,'myprin2);
  189. myprin2 "}] ";
  190. >>
  191. else
  192. <<mapc(u,'myprin2); myprin2 '! >>;
  193. end;
  194. symbolic procedure printnameref u;
  195. <<printref u>>;
  196. symbolic procedure emit_node_keys u; nil;
  197. symbolic procedure emit_node_key u;
  198. if !*verbatim then textoutl u else
  199. <<myprin2 "@cindex{";
  200. textoutl u;
  201. myprin2t "}";
  202. % textoutl u; das ist hier schon ausgegeben
  203. >>;
  204. symbolic procedure emit_hidden_node_key u;
  205. if !*verbatim then textoutl u else
  206. <<myprin2 "@cindex{";
  207. textoutl u;
  208. myprin2t "}";
  209. >>;
  210. symbolic procedure emit_node_label u; nil;
  211. %symbolic procedure emit_node_title (dummy,u,type);
  212. symbolic procedure emit_node_title (u,dummy,type);
  213. begin scalar slot,prev,next,up,cu,z;
  214. cu := u; % cu:=mycompress u;
  215. prev := if prevnode then car prevnode;
  216. slot := assoc(cu,nodechain);
  217. if null slot then
  218. <<slot := {cu,nil,prev};
  219. nodechain :=slot.nodechain;
  220. >>;
  221. if prevnode and car prevnode
  222. and (z:=assoc(car prevnode,nodechain)) then
  223. <<z:=cdr z; car z :=cu>>;
  224. up := if upnodes then car upnodes;
  225. fonton();
  226. myterpri();
  227. myprin2 "@node ";
  228. textoutl u; myprin2 ", ";
  229. textoutl cadr slot;myprin2 ", ";
  230. textoutl caddr slot;myprin2 ", ";
  231. textoutl (up or "(dir)");
  232. myterpri();
  233. if null up then <<myprin2 "@top"; myterpri()>>;
  234. if null prevnode then prevnode := {cu}
  235. else car prevnode := cu;
  236. end;
  237. symbolic procedure emit_node_browse(u,n);
  238. nil;
  239. symbolic procedure set_tab(); nil;
  240. symbolic procedure release_tab(); nil;
  241. symbolic procedure print_bold u;
  242. <<fontoff();
  243. myprin2 "@titlefont{";
  244. mapc(u,'myprin2);
  245. myprin2 "}";
  246. >>;
  247. symbolic procedure print_newline();
  248. <<if null !*newline then
  249. <<channelterpri outfile!*>>;
  250. !*newline:=t
  251. >>;
  252. symbolic procedure second_newline();
  253. <<!*newline :=nil; print_newline()>>;
  254. symbolic procedure print_tab (); textout " ";
  255. %--------------------------------------------------------------
  256. symbolic procedure tue();
  257. % job "c:\herbert\whelp\redindex.tex"$
  258. job("redindex.tex","hugo.x");
  259. %------------------- printstruct -------------------------------
  260. symbolic procedure printstruct();
  261. <<terpri(); printstruct1(car record,1)>>;
  262. symbolic procedure printstruct1(r,n);
  263. <<for i:=1:n do prin2 " ";
  264. mapc(name r,'prin2);
  265. terpri();
  266. for each x in reverse seq r do
  267. printstruct1(nil . x,n+1);
  268. >>;
  269. end;