home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / utilities / dirutils / visualshell / src / display2.c < prev    next >
C/C++ Source or Header  |  1992-10-29  |  19KB  |  607 lines

  1.             /*********************************
  2.          *                               *
  3.          *   Visual Shell v1.17  10/92   *
  4.          *                               *
  5.          *     by Torsten Jürgeleit      *
  6.          *                               *
  7.          *        display part 2         *
  8.          *                               *
  9.          *********************************/
  10.  
  11.     /* Includes */
  12.  
  13. #include "includes.h"
  14. #include "imports.h"
  15. #include "protos.h"
  16.  
  17.     /* Install string gadget in status line and get input */
  18.  
  19.    BYTE *
  20. get_input(USHORT mode, BYTE *default_input)
  21. {
  22.    struct Gadget      *gad = &gadget;
  23.    struct StringInfo  *sinfo = (struct StringInfo *)gad->SpecialInfo;
  24.    struct IntuiText   *itext = gad->GadgetText;
  25.    BYTE   *prompt, *buffer = (BYTE *)sinfo->Buffer;
  26.    USHORT max_input_len, prompt_width;
  27.  
  28.    /* Init prompt text */
  29.    event_mode = EVENT_MODE_IGNORE;
  30.    print_fkey_text(FKEY_MODE_NONE);
  31.    switch (mode) {
  32.       case INPUT_MODE_FREQ_ENTRY :
  33.       case INPUT_MODE_TREQ_ENTRY :
  34.      prompt        = "Speed search";
  35.      max_input_len = MAX_SEARCH_STRING_LEN;
  36.      break;
  37.       case INPUT_MODE_VIEW_LINE :
  38.       case INPUT_MODE_HISTORY_LINE :
  39.      prompt        = "Jump to line";
  40.      max_input_len = 10;
  41.      break;
  42.       case INPUT_MODE_VIEW_SEARCH :
  43.      prompt        = "Search for ($ for hex num)";
  44.      max_input_len = MAX_SEARCH_STRING_LEN;
  45.      break;
  46.       case INPUT_MODE_HISTORY_SEARCH :
  47.      prompt        = "Search for";
  48.      max_input_len = MAX_SEARCH_STRING_LEN;
  49.      break;
  50.       case INPUT_MODE_FILE_PATTERN :
  51.      prompt        = "New file pattern";
  52.      max_input_len = MAX_PATTERN_LEN;
  53.      break;
  54.       case INPUT_MODE_SELECT_PATTERN_MARK :
  55.      prompt        = "Select pattern for mark";
  56.      max_input_len = MAX_PATTERN_LEN;
  57.      break;
  58.       case INPUT_MODE_SELECT_PATTERN_UNMARK :
  59.      prompt        = "Select pattern for unmark";
  60.      max_input_len = MAX_PATTERN_LEN;
  61.      break;
  62.       case INPUT_MODE_CD :
  63.      prompt        = "New directory";
  64.      max_input_len = MAX_GADGET_BUFFER_LEN;
  65.      break;
  66.       case INPUT_MODE_USER_FUNCTION :
  67.      prompt        = "New user function";
  68.      max_input_len = MAX_USER_FUNCTION_LEN;
  69.      break;
  70.       case INPUT_MODE_COPY :
  71.      prompt        = "Copy to";
  72.      max_input_len = MAX_GADGET_BUFFER_LEN;
  73.      break;
  74.       case INPUT_MODE_RENAME_MOVE :
  75.      prompt        = "Rename or move to";
  76.      max_input_len = MAX_GADGET_BUFFER_LEN;
  77.      break;
  78.       case INPUT_MODE_MAKE_DIR :
  79.      prompt        = "Make new dir";
  80.      max_input_len = MAX_GADGET_BUFFER_LEN;
  81.      break;
  82.       case INPUT_MODE_FIND :
  83.      prompt        = "Find pattern";
  84.      max_input_len = MAX_PATTERN_LEN;
  85.      break;
  86.       default :
  87.      prompt        = "Input";
  88.      max_input_len = MAX_GADGET_BUFFER_LEN;
  89.      break;
  90.    }
  91.    prompt_width = strlen(prompt) * 8 + 8;
  92.  
  93.    /* Init string gadget */
  94.    gad->LeftEdge = prompt_width + BORDER_LEFT;
  95.    gad->TopEdge  = BORDER_TOP;
  96.    gad->Width    = vsh_width - prompt_width - BORDER_LEFT - BORDER_RIGHT;
  97.    gad->Height   = 9;
  98.    if (mode == INPUT_MODE_VIEW_LINE || mode == INPUT_MODE_HISTORY_LINE) {
  99.       gad->Activation = LONGINT;
  100.    } else {
  101.       gad->Activation = 0;
  102.    }
  103.    itext->LeftEdge = -prompt_width;
  104.    itext->IText    = (UBYTE *)prompt;
  105.  
  106.    /* Init gadget input buffer */
  107.    sinfo->DispPos  = 0;
  108.    sinfo->MaxChars = max_input_len;
  109.    if (default_input) {
  110.  
  111.       /* Default input text too long? */
  112.       if (strlen(default_input) >= (max_input_len - 1)) {
  113.  
  114.      /* Truncate default input text */
  115.      *(default_input + max_input_len - 1) = '\0';
  116.      DisplayBeep(NULL);
  117.       }
  118.       strcpy(buffer, default_input);
  119.       sinfo->BufferPos = strlen(default_input);
  120.    } else {
  121.       *buffer          = '\0';
  122.       sinfo->BufferPos = 0;
  123.    }
  124.    *(buffer + max_input_len - 1) = '\0';
  125.  
  126.    /* Clear status line, change screen font and install string gadget */
  127.    SetAPen(con_rport, (LONG)COLOR0);
  128.    RectFill(con_rport, (LONG)(BORDER_LEFT - 2), (LONG)BORDER_TOP, (LONG)
  129.          (vsh_width - BORDER_RIGHT + 1), (LONG)(BORDER_TOP_HIDDEN - 3));
  130.    SetFont(&con_window->WScreen->RastPort, con_font);   /* need console 8x8 font for string gadgets */
  131.    AddGadget(con_window, gad, -1L);
  132.    RefreshGadgets(gad, con_window, NULL);
  133.    ActivateGadget(gad, con_window, NULL);
  134.  
  135.    /* Input action loop */
  136.    event_mode = EVENT_MODE_INPUT;
  137.    do {
  138.       if (mode == INPUT_MODE_FREQ_ENTRY) {
  139.      switch (action) {
  140.         case VSH_ACTION_SPEED_SEARCH :
  141.            jump_to_freq_entry(buffer, JUMP_MODE_FIRST);
  142.            break;
  143.         case VSH_ACTION_SHIFT_GADGET_END_KEY :
  144.            jump_to_freq_entry(buffer, JUMP_MODE_NEXT);
  145.            action = VSH_ACTION_NONE;
  146.            break;
  147.      }
  148.       }
  149.       if (mode == INPUT_MODE_TREQ_ENTRY) {
  150.      switch (action) {
  151.         case VSH_ACTION_SPEED_SEARCH :
  152.            jump_to_treq_entry(buffer, JUMP_MODE_FIRST);
  153.            break;
  154.         case VSH_ACTION_SHIFT_GADGET_END_KEY :
  155.            jump_to_treq_entry(buffer, JUMP_MODE_NEXT);
  156.            action = VSH_ACTION_NONE;
  157.            break;
  158.      }
  159.       }
  160.       Wait(SIGF_ACTION);
  161.    } while (action != VSH_ACTION_GADGET_END_KEY && action != VSH_ACTION_ESC);
  162.  
  163.    /* Remove string gadget and restore old screen font */
  164.    RemoveGadget(con_window, &gadget);
  165.    SetFont(&con_window->WScreen->RastPort, old_wb_font);
  166.  
  167.    /* Abort ? */
  168.    if (action == VSH_ACTION_ESC || *buffer == '\0') {
  169.  
  170.       /* Restore function key texts ? */
  171.       switch (mode) {
  172.      case INPUT_MODE_FREQ_ENTRY :
  173.      case INPUT_MODE_TREQ_ENTRY :
  174.      case INPUT_MODE_FILE_PATTERN :
  175.      case INPUT_MODE_SELECT_PATTERN_MARK :
  176.      case INPUT_MODE_SELECT_PATTERN_UNMARK :
  177.      case INPUT_MODE_CD :
  178.      case INPUT_MODE_USER_FUNCTION :
  179.      case INPUT_MODE_COPY :
  180.      case INPUT_MODE_RENAME_MOVE :
  181.      case INPUT_MODE_MAKE_DIR :
  182.         change_fkey_text();
  183.         break;
  184.      case INPUT_MODE_VIEW_LINE :
  185.      case INPUT_MODE_VIEW_SEARCH :
  186.      case INPUT_MODE_HISTORY_LINE :
  187.      case INPUT_MODE_HISTORY_SEARCH :
  188.      case INPUT_MODE_FIND :
  189.         break;
  190.       }
  191.  
  192.       /* Clear break signal */
  193.       if (action == VSH_ACTION_ESC) {
  194.      SetSignal(0L, (LONG)SIGBREAKF_CTRL_C);
  195.       }
  196.       buffer = NULL;
  197.    }
  198.    action = VSH_ACTION_NONE;
  199.    return(buffer);
  200. }
  201.     /* Get answer (yes/no/all) */
  202.  
  203.    USHORT
  204. get_answer(USHORT mode, BYTE *text, USHORT default_answer)
  205. {
  206.    struct Gadget      *gad = &gadget;
  207.    struct StringInfo  *sinfo = &gadget_info;
  208.    struct IntuiText   *itext = &gadget_text;
  209.    BYTE   *format, *default_input, prompt[MAX_LINE_LEN],
  210.       *path = &line2_buffer[0], *buffer = &gadget_buffer[0];
  211.    USHORT len, answer;
  212.    BOOL   keepon = TRUE;
  213.  
  214.    /* Init prompt text */
  215.    event_mode = EVENT_MODE_IGNORE;
  216.    switch (mode) {
  217.       case ANSWER_MODE_COPY_NO_READ :
  218.      format = "Read protection set for %s - copy (y/n/a)?";
  219.      build_limited_path_name(path, NULL, text, max_line_len - 39 - 4,
  220.                           LIMITED_PATH_MODE_NORMAL);
  221.      break;
  222.       case ANSWER_MODE_COPY_OVERWRITE :
  223.      format = "Destination %s exists - overwrite (y/n/a)?";
  224.      build_limited_path_name(path, NULL, text, max_line_len - 42 - 4,
  225.                           LIMITED_PATH_MODE_NORMAL);
  226.      break;
  227.       case ANSWER_MODE_DELETE_START :
  228.      if (text) {
  229.         format = "Delete %ld entries (y/n)?";
  230.      } else {
  231.         format = "Delete current entry (y/n)?";
  232.      }
  233.      path   = NULL;
  234.      break;
  235.       case ANSWER_MODE_DELETE_NO_DELETE :
  236.      format = "Delete protection set for %s - delete (y/n/a)?";
  237.      build_limited_path_name(path, NULL, text, max_line_len - 43 - 4,
  238.                           LIMITED_PATH_MODE_NORMAL);
  239.      break;
  240.       case ANSWER_MODE_QUIT :
  241.      format = "Quit Visual Shell (y/n)?";
  242.      path   = NULL;
  243.      break;
  244.    }
  245.    if (path) {
  246.       SPrintf(&prompt[0], format, path);
  247.    } else {
  248.       SPrintf(&prompt[0], format, text);
  249.    }
  250.    len = strlen(&prompt[0]);
  251.  
  252.    /* Init string gadget */
  253.    gad->LeftEdge   = len * 8 + 8 + BORDER_LEFT;
  254.    gad->TopEdge    = BORDER_TOP;
  255.    gad->Width      = vsh_width - len * 8 - 8 - BORDER_LEFT - BORDER_RIGHT;
  256.    gad->Height     = 9;
  257.    gad->Activation = 0;
  258.  
  259.    itext->LeftEdge = -(len * 8 + 8);
  260.    itext->IText    = (UBYTE *)&prompt[0];
  261.  
  262.    /* Init gadget input buffer */
  263.    switch (default_answer) {
  264.       case ANSWER_TYPE_YES :
  265.      default_input = "y";
  266.      break;
  267.       case ANSWER_TYPE_NO :
  268.      default_input = "n";
  269.      break;
  270.       case ANSWER_TYPE_ALL :
  271.      default_input = "a";
  272.      break;
  273.       default :
  274.      default_input = NULL;
  275.      break;
  276.    }
  277.    if (default_input) {
  278.       strcpy(buffer, default_input);
  279.       len = strlen(default_input);
  280.    } else {
  281.       *buffer = '\0';
  282.       len     = 0;
  283.    }
  284.    sinfo->DispPos   = 0;
  285.    sinfo->MaxChars  = 2;
  286.    sinfo->BufferPos = len;
  287.  
  288.    /* Clear status line, change screen font and install string gadget */
  289.    SetAPen(con_rport, (LONG)COLOR0);
  290.    RectFill(con_rport, (LONG)(BORDER_LEFT - 2), (LONG)BORDER_TOP, (LONG)
  291.          (vsh_width - BORDER_RIGHT + 1), (LONG)(BORDER_TOP_HIDDEN - 3));
  292.    SetFont(&con_window->WScreen->RastPort, con_font);   /* need console 8x8 font for string gadgets */
  293.    AddGadget(con_window, gad, -1L);
  294.    RefreshGadgets(gad, con_window, NULL);
  295.    ActivateGadget(gad, con_window, NULL);
  296.  
  297.    /* Input action loop */
  298.    do {
  299.       event_mode = EVENT_MODE_INPUT;   /*ANSWER;*/
  300.       Wait(SIGF_ACTION);
  301.  
  302.       /* Check action */
  303.       if (action == VSH_ACTION_ESC) {
  304.  
  305.      /* Clear break signal */
  306.      SetSignal(0L, (LONG)SIGBREAKF_CTRL_C);
  307.      answer = ANSWER_TYPE_ESC;
  308.      keepon = FALSE;
  309.       } else {
  310.      if (action == VSH_ACTION_GADGET_END_KEY ||
  311.                 action == VSH_ACTION_SHIFT_GADGET_END_KEY) {
  312.         /* Check answer */
  313.         switch (toupper(*buffer)) {
  314.            case 'Y' :
  315.           answer = ANSWER_TYPE_YES;
  316.           keepon = FALSE;
  317.           break;
  318.            case 'N' :
  319.           answer = ANSWER_TYPE_NO;
  320.           keepon = FALSE;
  321.           break;
  322.            case 'A' :
  323.           switch (mode) {
  324.              case ANSWER_MODE_DELETE_START :
  325.              case ANSWER_MODE_QUIT :
  326.             DisplayBeep(NULL);
  327.             ActivateGadget(gad, con_window, NULL);
  328.             break;
  329.              default :
  330.             answer = ANSWER_TYPE_ALL;
  331.             keepon = FALSE;
  332.             break;
  333.           }
  334.           break;
  335.            default :
  336.           DisplayBeep(NULL);
  337.           ActivateGadget(gad, con_window, NULL);
  338.           break;
  339.         }
  340.      }
  341.       }
  342.    } while (keepon == TRUE);
  343.  
  344.    /* Remove string gadget and restore old screen font */
  345.    RemoveGadget(con_window, &gadget);
  346.    SetFont(&con_window->WScreen->RastPort, old_wb_font);
  347.    action = VSH_ACTION_NONE;
  348.    return(answer);
  349. }
  350.     /* Print directory info to specified filerequester */
  351.  
  352.    VOID
  353. print_dir_info(struct FileRequest  *freq1)
  354. {
  355.    struct FileRequest  *freq2 = (freq1 == &file_req[0] ? &file_req[1] :
  356.                                   &file_req[0]);
  357.    struct Info  *info = &freq2->fr_Info;
  358.    USHORT left   = freq1->fr_Display.d_LeftEdge,
  359.       top    = freq1->fr_Display.d_TopEdge,
  360.       vlines = freq1->fr_Display.d_VisibleLines, vpos, len;
  361.    BYTE   *line = &line1_buffer[0];
  362.  
  363.    if (show_flag && freq1->fr_Mode == FREQ_MODE_INFO) {
  364.       SetAPen(con_rport, (LONG)COLOR0);
  365.       RectFill(con_rport, (LONG)left, (LONG)top, (LONG)(left +
  366.                 MAX_FREQ_LINE_WIDTH), (LONG)(top + vlines * 8));
  367.       if (! info->i_Valid) {   /* valid info data ? */
  368.      display_text_centered(COLOR2, COLOR3, left, (USHORT)(top + vlines * 
  369.               4), "No directory selected !", MAX_FREQ_LINE_LEN);
  370.       } else {
  371.      vpos = top + (vlines - MAX_INFO_LINES) * (USHORT)4;
  372.      display_text_centered(COLOR1, COLOR2, left, vpos,
  373.                  "Infos about current disk", MAX_FREQ_LINE_LEN);
  374.      len = (USHORT)(strchr(&freq2->fr_DirName[0], ':') -
  375.                              &freq2->fr_DirName[0]);
  376.      strncpy(line, &freq2->fr_DirName[0], (size_t)len);
  377.      *(line +  len) = '\0';
  378.      display_text_centered(COLOR3, COLOR0, left, vpos += (USHORT)8,
  379.                            line, MAX_FREQ_LINE_LEN);
  380.      SPrintf(line, "Volume name : %s", &info->i_VolumeName[0]);
  381.      display_text_left(COLOR1, COLOR0, left, vpos += (USHORT)8,
  382.                            line, MAX_FREQ_LINE_LEN);
  383.      SPrintf(line, "Disk state  : %s", (info->i_DiskState ==
  384.               ID_WRITE_PROTECTED ? "Read only" : "Read/Write"));
  385.      display_text_left(COLOR1, COLOR0, left, vpos += (USHORT)8,
  386.                            line, MAX_FREQ_LINE_LEN);
  387.      SPrintf(line, "Block size  : %ld", info->i_BytesPerBlock);
  388.      display_text_left(COLOR1, COLOR0, left, vpos += (USHORT)8,
  389.                            line, MAX_FREQ_LINE_LEN);
  390.      SPrintf(line, "Total bytes : %ld", info->i_TotalSize);
  391.      display_text_left(COLOR1, COLOR0, left, vpos += (USHORT)8,
  392.                            line, MAX_FREQ_LINE_LEN);
  393.      SPrintf(line, "Free bytes  : %ld", info->i_FreeSize);
  394.      display_text_left(COLOR1, COLOR0, left, vpos += (USHORT)8,
  395.                            line, MAX_FREQ_LINE_LEN);
  396.      SPrintf(line, "Soft errors : %ld", info->i_NumSoftErrors);
  397.      display_text_left(COLOR1, COLOR0, left, vpos += (USHORT)8,
  398.                            line, MAX_FREQ_LINE_LEN);
  399.      display_text_centered(COLOR1, COLOR0, left, vpos += (USHORT)8,
  400.                        (BYTE *)NULL, MAX_FREQ_LINE_LEN);
  401.      display_text_centered(COLOR1, COLOR2, left, vpos += (USHORT)8,
  402.                   "Infos about current dir", MAX_FREQ_LINE_LEN);
  403.      build_limited_path_name(line, NULL, &freq2->fr_DirName[0],
  404.                    MAX_FREQ_LINE_LEN, LIMITED_PATH_MODE_NORMAL);
  405.      display_text_centered(COLOR3, COLOR0, left, vpos += (USHORT)8,
  406.                            line, MAX_FREQ_LINE_LEN);
  407.      SPrintf(line, "Dirs        : %ld", info->i_Dirs);
  408.      display_text_left(COLOR1, COLOR0, left, vpos += (USHORT)8,
  409.                            line, MAX_FREQ_LINE_LEN);
  410.      SPrintf(line, "Files       : %ld", info->i_Files);
  411.      display_text_left(COLOR1, COLOR0, left, vpos += (USHORT)8,
  412.                            line, MAX_FREQ_LINE_LEN);
  413.      SPrintf(line, "Used bytes  : %ld", info->i_FileSizes);
  414.      display_text_left(COLOR1, COLOR0, left, vpos += (USHORT)8,
  415.                            line, MAX_FREQ_LINE_LEN);
  416.       }
  417.    }
  418. }
  419.     /* Refresh directory info for the other filerequester */
  420.  
  421.    VOID
  422. refresh_dir_info(struct FileRequest  *freq1)
  423. {
  424.    struct FileRequest  *freq2 = (freq1 == &file_req[0] ? &file_req[1] :
  425.                                   &file_req[0]);
  426.  
  427.    if (show_flag && freq2->fr_Mode == FREQ_MODE_INFO) {
  428.       print_dir_info(freq2);
  429.    }
  430. }
  431.     /* Print about page */
  432.  
  433.    VOID
  434. print_about_page(VOID)
  435. {
  436.    USHORT i, color, left_offset, top_offset = BORDER_TOP +
  437.               MAX_OUTPUT_HEIGHT / 2 - MAX_ABOUT_LINES * 4 - 6;
  438.    BYTE   *text;
  439.  
  440.    SetAPen(con_rport, (LONG)COLOR2);
  441.    RectFill(con_rport, (LONG)BORDER_LEFT, (LONG)BORDER_TOP, (LONG)
  442.               (vsh_width - BORDER_RIGHT - 1), (LONG)(cli_vpos - 4));
  443.    for (i = 0; i < MAX_ABOUT_LINES; i++) {
  444.       if (text = about_line[i]) {
  445.      if (text == (BYTE *)-1L) {
  446.         text  = compile_date;
  447.         color = 1;
  448.      } else {
  449.         color = *text++ - '0';
  450.      }
  451.      left_offset = (vsh_width - strlen(text) * 8) / 2;   /* center line */
  452.      display_text(color, COLOR2, left_offset, (USHORT)(top_offset + i *
  453.                                   8), text);
  454.       }
  455.    }
  456.    text        = prompt_line[3];   /* print prompt line */
  457.    color       = *text++ - '0';
  458.    left_offset = (vsh_width - strlen(text) * 8) / 2;
  459.    display_text(color, COLOR2, left_offset, (USHORT)(cli_vpos - 3 - 2 * 8),
  460.                                       text);
  461. }
  462.     /* Refresh about page */
  463.  
  464.    VOID
  465. refresh_about_page(VOID)
  466. {
  467.    print_about_page();
  468.    draw_line(COLOR1, (USHORT)2, (USHORT)(cli_vpos - 2), (USHORT)
  469.                    (vsh_width - 3), (USHORT)(cli_vpos - 2));
  470.    draw_line(COLOR1, (USHORT)2, (USHORT)(vsh_height - FKEY_HEIGHT), (USHORT)
  471.                (vsh_width - 3), (USHORT)(vsh_height - FKEY_HEIGHT));
  472.    print_fkey_text(FKEY_MODE_QUIT_ONLY);
  473. }
  474.     /* Print help page */
  475.  
  476.    BOOL
  477. print_help_page(USHORT page_num)
  478. {
  479.    USHORT save_page_num = page_num, max_lines  = MAX_OUTPUT_HEIGHT / 8 - 3,
  480.       top_offset = MAX_OUTPUT_HEIGHT / 2 - (max_lines - 1) * 4;
  481.    SHORT  i, color, indent, left_offset;
  482.    BYTE   c, *text, **line = &help_line[0], *last_head_line = NULL;
  483.    BOOL   next_page, last_page = FALSE;
  484.  
  485.    SetAPen(con_rport, (LONG)COLOR2);
  486.    RectFill(con_rport, (LONG)BORDER_LEFT, (LONG)BORDER_TOP, (LONG)
  487.               (vsh_width - BORDER_RIGHT - 1), (LONG)(cli_vpos - 4));
  488.    /* search start of selected help page */
  489.    while (page_num && last_page == FALSE) {
  490.       for (i = 0, next_page = FALSE; i < max_lines && last_page == FALSE &&
  491.                           next_page == FALSE; i++) {
  492.      if (!(text = *line++)) {   /* valid help line ? */
  493.         last_page = TRUE;
  494.      } else {
  495.         if ((c = *text++) == 'H') {   /* new head line ? */
  496.            last_head_line = text;
  497.            if (i > 0) {   /* new head line already at start of new page ? */
  498.           next_page = TRUE;
  499.            }
  500.         } else {
  501.            if (i == 0) {   /* new page ? */
  502.           c = 'H';   /* print first old head line */
  503.           *line--;
  504.            }
  505.         }
  506.         if (next_page == FALSE) {   /* start new page ? */
  507.            if (c == 'H') {   /* head line ? */
  508.           i++;   /* one empty line after head line */
  509.            } else {   /* normal line */
  510.           if (c == 'K') {   /* keyboard type specified ? */
  511.              if (vsh_keyboard_type != (*text++ - '0')) {   /* wrong keyboard ? */
  512.             i--;   /* once again the same line */
  513.              }
  514.           }
  515.            }
  516.         }
  517.         if (! *line) {   /* no more help lines ? */
  518.            last_page = TRUE;
  519.         }
  520.      }
  521.       }
  522.       if (last_page == FALSE) {   /* skip next page ? */
  523.      page_num--;
  524.       }
  525.    }
  526.    /* print selected help page */
  527.    for (i = 0, next_page = FALSE; i < max_lines && last_page == FALSE &&
  528.                           next_page == FALSE; i++) {
  529.       if (!(text = *line++)) {   /* valid help line ? */
  530.      last_page = TRUE;
  531.       } else {
  532.      if ((c = *text++) == 'H') {   /* new head line ? */
  533.         last_head_line = text;
  534.         if (i > 0) {   /* new head line already at start of new page ? */
  535.            next_page = TRUE;
  536.         }
  537.      } else {
  538.         if (i == 0) {   /* new page ? */
  539.            text = last_head_line;   /* print first old head line */
  540.            c    = 'H';
  541.            *line--;
  542.         }
  543.      }
  544.      if (next_page == FALSE) {   /* start new page ? */
  545.         if (c == 'H') {   /* head line ? */
  546.            color  = 3;
  547.            indent = 0;
  548.         } else {   /* normal help line */
  549.            if (c == 'K') {   /* keyboard type specified ? */
  550.           if (vsh_keyboard_type == (*text++ - '0')) {   /* right keyboard ? */
  551.              color  = 1;
  552.              indent = *text++ - '0';
  553.           } else {
  554.              color = -1;   /* don't print this help line */
  555.              i--;   /* once again the same line */
  556.           }
  557.            } else {
  558.           color  = 1;
  559.           indent = c - '0';
  560.            }
  561.         }
  562.         if (color != -1) {
  563.            left_offset = (vsh_width - MIN_VSH_WIDTH) / 2 + (3 +
  564.                                 indent) * 8;   /* left justify text */
  565.            display_text(color, COLOR2, left_offset, (USHORT)
  566.                         (top_offset + i * 8), text);
  567.         }
  568.         if (c == 'H') {
  569.            i++;   /* one empty line after head line */
  570.         }
  571.      }
  572.      if (! *line) {   /* no more help lines ? */
  573.         last_page = TRUE;
  574.      }
  575.       }
  576.    }
  577.    if (last_page == FALSE) {   /* print prompt line */
  578.       if (save_page_num) {
  579.      text = prompt_line[1];
  580.       } else {
  581.      text = prompt_line[0];
  582.       }
  583.    } else {
  584.       text = prompt_line[2];
  585.    }
  586.    color       = *text++ - '0';
  587.    left_offset = (vsh_width - strlen(text) * 8) / 2;   /* center line */
  588.    display_text(color, COLOR2, left_offset, (USHORT)(cli_vpos - 3 - 2 * 8),
  589.                                       text);
  590.    return(last_page);
  591. }
  592.     /* Refresh help page */
  593.  
  594.    BOOL
  595. refresh_help_page(USHORT page_num)
  596. {
  597.    BOOL last_page;
  598.  
  599.    last_page = print_help_page(page_num);
  600.    draw_line(COLOR1, (USHORT)2, (USHORT)(cli_vpos - 2), (USHORT)
  601.                    (vsh_width - 3), (USHORT)(cli_vpos - 2));
  602.    draw_line(COLOR1, (USHORT)2, (USHORT)(vsh_height - FKEY_HEIGHT), (USHORT)
  603.                (vsh_width - 3), (USHORT)(vsh_height - FKEY_HEIGHT));
  604.    print_fkey_text(FKEY_MODE_QUIT_ONLY);
  605.    return(last_page);
  606. }
  607.