Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  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.  
  41.    qualifier_level := 0;
  42.    hg$substitute_topic(current_buffer, "<MAIN>", ".indent-3", "1");
  43.    hg$substitute_topic(current_buffer, "<QUALIFIER>", ".sk;.indent-3", "");
  44.    hg$substitute_topic(current_buffer, "<TOPIC>", ".indent-3", "2");
  45.    hg$substitute_topic(current_buffer, "<SUBTOPIC>", ".indent-3", "3");
  46.    hg$substitute_topic(current_buffer, "<SUBSUBTOPIC>", ".indent-3", "4");
  47.    hg$substitute_comment(current_buffer,"<QUALIFIERS>",".indent-3;2 Qualifiers");
  48.    hg$substitute_comment(current_buffer,"<PARAMETER>",".indent-2");
  49.    hg$substitute_comment(current_buffer,"<PTEXT>",".lm+3");
  50.    hg$substitute_comment(current_buffer,"<TXETP>",".lm-3");
  51.    hg$substitute_comment(current_buffer,"<ETEXT>",".lm+4");
  52.    hg$substitute_comment(current_buffer,"<TXETE>",".lm-4");
  53.    hg$substitute_comment(current_buffer,"<INIT>",".noflags;.lm3;.rm70");
  54.    hg$substitute_comment(current_buffer,"<LITERAL>",".lm+4;.literal");
  55.    hg$substitute_comment(current_buffer,"<LARETIL>",".end literal;.lm-4");
  56.    hg$substitute_comment(current_buffer,"<DOT1LIST>",'.list 1,"o"');
  57.    hg$substitute_comment(current_buffer,"<DOT0LIST>",'.list 0,"o"');
  58.    hg$substitute_comment(current_buffer,"<ENTRY>",".le");
  59.    hg$substitute_comment(current_buffer,"<TSIL>",".end list");
  60.    hg$substitute_comment(current_buffer,"<CENTER>",".center");
  61.    hg$substitute_comment(current_buffer,"<FORMAT>",".sk;.indent2");
  62.    hg$substitute_comment(current_buffer,"<NOTE>",".note");
  63.    hg$substitute_comment(current_buffer,"<ETON>",".end note");
  64.    hg$substitute_comment(current_buffer, LINE_BEGIN & LINE_END,".sk");
  65.    hg$substitute_comment(current_buffer, LINE_BEGIN & "|", "");
  66.    hg$substitute_comment(current_buffer,"<NEXT>",".br");
  67.  
  68. EndProcedure;           ! eve_convert_help
  69.  
  70. Procedure hg$substitute_comment (the_buffer, target, new)
  71. Local   temp
  72.         ,save_pos
  73.         ,x
  74.         ;
  75.   on_error;
  76.   endon_error;
  77.  
  78.   save_pos := mark(none);
  79.   position(beginning_of(the_buffer));
  80.   loop
  81.         x := search(target, forward);
  82.         exitif x = 0;
  83.         position (x);
  84.         erase_character(length(x));
  85.         copy_text(new);
  86.   endloop;
  87.  
  88.   position(save_pos);
  89.  
  90. EndProcedure;           ! hg$substitute_comment
  91.  
  92. Procedure hg$substitute_topic (the_buffer, target, new, level)
  93. Local   temp
  94.         ,save_pos
  95.         ,x
  96.         ;
  97.   on_error;
  98.   endon_error;
  99.  
  100.   save_pos := mark(none);
  101.   position(beginning_of(the_buffer));
  102.   loop
  103.         x := search(target, forward);
  104.         exitif x = 0;
  105.         position (x);
  106.         erase_character(length(x));
  107.         move_vertical(-1);
  108.         if (length(current_line) = 0)
  109.         then copy_text("|");
  110.         endif;
  111.         move_vertical(1);
  112.         copy_text(".!------------------------------------------------------");
  113.         split_line;
  114.         copy_text(new);
  115.         move_horizontal(-current_offset);
  116.         move_vertical(1);
  117.         if level <> "" then
  118.                 copy_text(level + " ");
  119. !       else
  120. !           if qualifier_level = 0
  121. !           then
  122. !               copy_text("2 Qualifiers");
  123. !               split_line; split_line;
  124. !               copy_text(new); split_line;
  125. !               qualifier_level := 1;
  126. !           endif;
  127.         endif;
  128.         move_horizontal(-current_offset);
  129.         move_vertical(1);
  130.         if length(current_line) = 0
  131.         then
  132.             if (target = "<MAIN>") OR (target = "<TOPIC>")
  133.                 OR (target = "<SUBTOPIC>") or (target = "<SUBSUBTOPIC>")
  134.             then copy_text(".br");
  135.             else copy_text(".sk");
  136.             endif;
  137.         endif;
  138.   endloop;
  139.  
  140.   position(save_pos);
  141.  
  142. EndProcedure;           ! hg$substitute_topic
  143.  
  144. !===============================================================================
  145. Procedure tpu$init_procedure
  146. Local   temp
  147.         ,orig_filespec
  148.         ,f
  149.         ;
  150.  
  151.    on_error
  152.    endon_error;
  153.  
  154.  !Prompt user for information
  155.  
  156.   orig_filespec := get_info(command_line, "file_name");
  157.   if orig_filespec = ""
  158.   then
  159.         message("No .HELP file given");
  160.         quit;
  161.   endif;
  162.   f := file_parse(orig_filespec, ".HELP");              !Add .LIS ending
  163.  
  164.     ! Create a buffer and window for editing
  165.  
  166.   main_buf := create_buffer ("MAIN",f);
  167.   set (eob_text, main_buf, "[End of buffer]");
  168.  
  169.   position (beginning_of(main_buf));
  170.  
  171.   eve_convert_help;
  172.  
  173.   f := file_parse(orig_filespec,"","",NAME);
  174.  
  175.   write_file (main_buf, f+".RNH");
  176.  
  177.  quit;
  178. EndProcedure;           !TPU$INIT_PROCEDURE
  179.  
  180. tpu$init_procedure;
  181.