cvthelp.tpu 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. ! TITLE CVTHELP.TPU
  2. ! IDENT 01-001
  3. !
  4. !++
  5. ! Copyright (c) 1990-2001 Info-ZIP. All rights reserved.
  6. !
  7. ! See the accompanying file LICENSE, version 2000-Apr-09 or later
  8. ! (the contents of which are also included in zip.h) for terms of use.
  9. ! If, for some reason, all these files are missing, the Info-ZIP license
  10. ! also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
  11. !
  12. !++
  13. !
  14. ! Program: CVTHELP.TPU
  15. !
  16. ! Author: Hunter Goatley
  17. !
  18. ! Date: January 12, 1992
  19. !
  20. ! Purpose: Convert .HELP files to RUNOFF .RNH files. Substitutes
  21. ! RUNOFF commands for tags imbedded in the .HELP file.
  22. !
  23. ! Calling sequence:
  24. !
  25. ! $ EDIT/TPU/NOJOURNAL/NODISPLAY/COMMAND=CVTHELP file.HELP
  26. !
  27. ! Modified by:
  28. !
  29. ! 01-001 Hunter Goatley 7-FEB-2001 15:40
  30. ! Added <NEXT> for qualifier separators.
  31. !
  32. ! 01-000 Hunter Goatley 12-JAN-1992 15:15
  33. ! Original version.
  34. !
  35. !--
  36. Procedure eve_convert_help
  37. Local temp
  38. ,x
  39. ;
  40. qualifier_level := 0;
  41. hg$substitute_topic(current_buffer, "<MAIN>", ".indent-3", "1");
  42. hg$substitute_topic(current_buffer, "<QUALIFIER>", ".sk;.indent-3", "");
  43. hg$substitute_topic(current_buffer, "<TOPIC>", ".indent-3", "2");
  44. hg$substitute_topic(current_buffer, "<SUBTOPIC>", ".indent-3", "3");
  45. hg$substitute_topic(current_buffer, "<SUBSUBTOPIC>", ".indent-3", "4");
  46. hg$substitute_comment(current_buffer,"<QUALIFIERS>",".indent-3;2 Qualifiers");
  47. hg$substitute_comment(current_buffer,"<PARAMETER>",".indent-2");
  48. hg$substitute_comment(current_buffer,"<PTEXT>",".lm+3");
  49. hg$substitute_comment(current_buffer,"<TXETP>",".lm-3");
  50. hg$substitute_comment(current_buffer,"<ETEXT>",".lm+4");
  51. hg$substitute_comment(current_buffer,"<TXETE>",".lm-4");
  52. hg$substitute_comment(current_buffer,"<INIT>",".noflags;.lm3;.rm70");
  53. hg$substitute_comment(current_buffer,"<LITERAL>",".lm+4;.literal");
  54. hg$substitute_comment(current_buffer,"<LARETIL>",".end literal;.lm-4");
  55. hg$substitute_comment(current_buffer,"<DOT1LIST>",'.list 1,"o"');
  56. hg$substitute_comment(current_buffer,"<DOT0LIST>",'.list 0,"o"');
  57. hg$substitute_comment(current_buffer,"<ENTRY>",".le");
  58. hg$substitute_comment(current_buffer,"<TSIL>",".end list");
  59. hg$substitute_comment(current_buffer,"<CENTER>",".center");
  60. hg$substitute_comment(current_buffer,"<FORMAT>",".sk;.indent2");
  61. hg$substitute_comment(current_buffer,"<NOTE>",".note");
  62. hg$substitute_comment(current_buffer,"<ETON>",".end note");
  63. hg$substitute_comment(current_buffer, LINE_BEGIN & LINE_END,".sk");
  64. hg$substitute_comment(current_buffer, LINE_BEGIN & "|", "");
  65. hg$substitute_comment(current_buffer,"<NEXT>",".br");
  66. EndProcedure; ! eve_convert_help
  67. Procedure hg$substitute_comment (the_buffer, target, new)
  68. Local temp
  69. ,save_pos
  70. ,x
  71. ;
  72. on_error;
  73. endon_error;
  74. save_pos := mark(none);
  75. position(beginning_of(the_buffer));
  76. loop
  77. x := search(target, forward);
  78. exitif x = 0;
  79. position (x);
  80. erase_character(length(x));
  81. copy_text(new);
  82. endloop;
  83. position(save_pos);
  84. EndProcedure; ! hg$substitute_comment
  85. Procedure hg$substitute_topic (the_buffer, target, new, level)
  86. Local temp
  87. ,save_pos
  88. ,x
  89. ;
  90. on_error;
  91. endon_error;
  92. save_pos := mark(none);
  93. position(beginning_of(the_buffer));
  94. loop
  95. x := search(target, forward);
  96. exitif x = 0;
  97. position (x);
  98. erase_character(length(x));
  99. move_vertical(-1);
  100. if (length(current_line) = 0)
  101. then copy_text("|");
  102. endif;
  103. move_vertical(1);
  104. copy_text(".!------------------------------------------------------");
  105. split_line;
  106. copy_text(new);
  107. move_horizontal(-current_offset);
  108. move_vertical(1);
  109. if level <> "" then
  110. copy_text(level + " ");
  111. ! else
  112. ! if qualifier_level = 0
  113. ! then
  114. ! copy_text("2 Qualifiers");
  115. ! split_line; split_line;
  116. ! copy_text(new); split_line;
  117. ! qualifier_level := 1;
  118. ! endif;
  119. endif;
  120. move_horizontal(-current_offset);
  121. move_vertical(1);
  122. if length(current_line) = 0
  123. then
  124. if (target = "<MAIN>") OR (target = "<TOPIC>")
  125. OR (target = "<SUBTOPIC>") or (target = "<SUBSUBTOPIC>")
  126. then copy_text(".br");
  127. else copy_text(".sk");
  128. endif;
  129. endif;
  130. endloop;
  131. position(save_pos);
  132. EndProcedure; ! hg$substitute_topic
  133. !===============================================================================
  134. Procedure tpu$init_procedure
  135. Local temp
  136. ,orig_filespec
  137. ,f
  138. ;
  139. on_error
  140. endon_error;
  141. !Prompt user for information
  142. orig_filespec := get_info(command_line, "file_name");
  143. if orig_filespec = ""
  144. then
  145. message("No .HELP file given");
  146. quit;
  147. endif;
  148. f := file_parse(orig_filespec, ".HELP"); !Add .LIS ending
  149. ! Create a buffer and window for editing
  150. main_buf := create_buffer ("MAIN",f);
  151. set (eob_text, main_buf, "[End of buffer]");
  152. position (beginning_of(main_buf));
  153. eve_convert_help;
  154. f := file_parse(orig_filespec,"","",NAME);
  155. write_file (main_buf, f+".RNH");
  156. quit;
  157. EndProcedure; !TPU$INIT_PROCEDURE
  158. tpu$init_procedure;