[inherit('sys$library:starlet','lib$spawn','smgdefs','smg$repaint_line',
'BB.PEN')]
module put_help;

[global] 
procedure put_help(header,filename:string;pause:boolean:=true);

{Paints the one page help file requested.}

var
  display : unsigned;
  head_display : unsigned;

begin
  open(bannerfile,help_logical+filename,history:=readonly,error:=continue);

  if pause then
    begin
      head_display := help_header_display;
      display := help_display;
    end
  else
    begin
      head_display := header_display;
      display := main_display;
    end;

  smg$begin_pasteboard_update(pasteboard);
  smg$erase_display(head_display);
  smg$put_chars_highwide(head_display,header+chr(0),
      1,((screen_cols div 2)-length(header)),smg$m_bold);
  smg$erase_display(display);
  smg$put_line(display,' ',1);

  if (status(bannerfile) = 0) then
    begin
      reset(bannerfile);
      while not eof(bannerfile) do
        begin
          readln(bannerfile,line);
          smg$put_line(display,line+chr(0));
        end;
    end
  else
    if pause then write_error('Unable to open help file.');

  if pause then
    begin
      smg$paste_virtual_display(head_display,pasteboard,1,1);
      smg$paste_virtual_display(display,pasteboard,3,1);
    end;

  smg$end_pasteboard_update(pasteboard);
  close(bannerfile,error:=continue);

  if pause then
    begin
      write_menu('','Press any key to continue...');
      getchar;
      smg$unpaste_virtual_display(head_display,pasteboard);
      smg$unpaste_virtual_display(display,pasteboard);
    end;
end;

end.
