home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / most-3.2 / part01 / help.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-13  |  3.1 KB  |  118 lines

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