home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / most423.zip / help.c < prev    next >
C/C++ Source or Header  |  1994-01-28  |  3KB  |  123 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #ifdef VMS
  5. #include <stat.h>
  6. #else
  7. #include <sys/types.h>
  8. #include <sys/stat.h>
  9. #endif
  10.  
  11. #include <stdlib.h>
  12.  
  13. #include "window.h"
  14. #include "file.h"  
  15. #include "display.h"  
  16. #include "line.h"
  17. #include "most.h"  
  18. #include "sysdep.h"
  19.   
  20. #ifndef MOST_HELP_USE_DOC
  21. /* This section provided by Mats Akerberg (mats@efd.lth.se) */
  22.   
  23. static char *help[] = {
  24. "SPACE,^D,D,d        *Scroll down one Screen.",
  25. "RETURN, DOWN        *Move forward one line.",
  26. "u,U,^U, DELETE      *Move Up one screen.",
  27. "UP                  *Move up one line.",
  28. "R, r, ^R             Redraw Screen.",
  29. "T,t                  Top of File.",
  30. "B,b                  Bottom of file.",
  31. "RIGHT                Scroll Screen Left (to view lines right of right margin)",
  32. "LEFT                 Scroll Screen Right (To view lines left of left margin)",
  33. "F,f,/               *Find forward",
  34. "?                   *Find Backward",
  35. "n,N                 *Find next in current search direction.",
  36. "J,j,g,G              Goto line.",
  37. "%                    Goto percent.",
  38. "q,Q                  Quit MOST.",
  39. ":N,:n                Quit this file and view next.",
  40. "^X2,^W2              Split window",
  41. "^X1,^W1              Make only one window.",
  42. "o,O,^Xo,^Wo          Move to other window.",
  43. " *Note:  This command may be repeated `n' times By entering a number then",
  44. "        the command key, e.g.,  '5 SPACE' moves 5 screens forward.",
  45. NULL };
  46.  
  47. void do_help_command()
  48. {
  49.     int i,ct;
  50.     char *beg, *end;
  51.     char line[80];
  52.     char attr[80];
  53.     
  54.     i = 1;
  55.     ct = 0;
  56.     set_scroll_region(1,SCREEN_HEIGHT);
  57.     cls();
  58.     while( i<SCREEN_ROWS)
  59.       {
  60.           if( help[ct]!=NULL)
  61.             {
  62.                 beg = help[ct];
  63.                 end = (help[ct] + strlen(help[ct++]));
  64.                 analyse_line((unsigned char *) beg, (unsigned char *) end, line, attr);
  65.                 output(line,end - beg,attr,'$');
  66.            tt_putchar('\n');
  67.            i++;
  68.             }
  69.           else
  70.             {
  71.         tt_reverse_video();
  72.                 send_string_to_term("Press any key to continue.");
  73.            tt_normal_video();
  74.         getkey();
  75.                 redraw_display();
  76.         return;
  77.             }
  78.       }
  79. }
  80.  
  81. #else
  82. void do_help_command()
  83. {
  84.    char *helpfile, *buf_name;
  85.  
  86.     buf_name = "*help*";
  87.     helpfile = getenv("MOST_HELP");
  88.     if (helpfile == NULL)
  89.       {
  90.      static char tempname[255];     /* L_tmpnam */
  91.      struct stat statb;
  92.  
  93.      head(MOST_PROGRAM, tempname);
  94.      strcat(tempname, "most.doc");
  95.      if (0 == stat(tempname, &statb))
  96.        {
  97.           helpfile = tempname;
  98.        }
  99.       }
  100.    if (helpfile != NULL)
  101.      {
  102.     if (file_visible(buf_name)) return;
  103.     if (!split_window())
  104.       {
  105.          message("Two many windows.",1);
  106.          return;
  107.       }
  108.     update_status(1);  /* create status line of prev. window */
  109.     other_window(1);
  110.     (void) find_file(helpfile);
  111.     strcpy(BUF->file,buf_name);
  112.     window_buffer();
  113.     redraw_window();
  114.     update_status(1);
  115.      }
  116.    else
  117.      {
  118.     message("You must set the environment variable 'MOST_HELP' to point to the help file.",1);
  119.      }
  120. }       
  121. #endif
  122.  
  123.