{routine to diplay files in a 'more' fashion on subwindows}

%external %string (80) Copyright %alias "NEWS_DISPLAY_(C)_RMM_85" = -
   "Copyright (C) 1985 Richard M. Marshall"

%include "News.Inc"
%include "IE:Terminal.Inc"

%own %integer Featuring = No

{-SAFE PUT SYMBOL-}

%external %routine Safe Put Symbol (%integer Ch)
   %if Ch&128 # 0 %start
      Graph On
      Degree Sign
      Graph Off
      Ch = Ch&127
   %finish
   %if Ch = TAB %start
      Put Symbol (TAB)
   %else %if Ch = ACK
      Featuring = Yes
      Feature
   %else %if Ch = SO 
      Featuring = No
      Normal
   %else %if Ch < ' ' %or -
             Ch = DEL
      %if Featuring = Yes %start
         Normal
      %else
         Feature
      %finish
      %if Ch = DEL %start
         Put String ("^?")
      %else
         Put Symbol ('^')
         Put Symbol (Ch + '@')
      %finish
      %if Featuring = Yes %start
         Feature
      %else
         Normal
      %finish
   %else 
      Put Symbol (Ch)
   %finish
%end {Safe Put Symbol}

{-DISPLAY FILE-}

%external %routine Display File (%integer Start,
                                          Top,        {of screen to use}
                                          Bottom,
                                          Amount,     {number of characters}
                                          Wait)       {wait at end?}
   %integer CY,
            Total Amount = Amount
   %byte Ch

   {MORE}

   %routine More
      %byte Ch,
            Aborted = No

      Feature
      Put String ("--More--")
      %if Amount > 0 %start
         Put String (" (")
         Put Integer (((Total Amount - Amount) * 100) // Total Amount)
         Put String ("%)")
      %finish
      Normal 
      %cycle
         Ch = Get Key
         %if Ch = 'q' %or -
             Ch = 'Q' %start
            Aborted = Yes
            %exit
         %else %if Ch = EM
            %signal Total Abort
         %else %if Ch = '?'
            Clear Line
            Feature
            Put String ("Q quit; RETURN next line; SPACE next page")
            Normal
         %else %if Ch = CR %or -
                   Ch = Keypad Enter
            Forward Scroll (Top, Bottom)
            CY = CY - 1
            %exit
         %else %if Ch = ' '
            CY = Top
            %exit
         %else 
            Put Symbol (BEL)
         %finish
      %repeat
      Cursor (0, CY)
      Clear Line
      %signal 15 %if Aborted = Yes
      Feature %if Featuring = Yes
   %end {More}

   {CONTINUE}

   %routine Continue
      %byte Ch

      %while CY < Bottom %cycle
         CY = CY + 1
         Cursor (0, CY)
         Clear Line
      %repeat
      %if Wait = Yes %start
         Feature
         Put String ("Press any key to continue")
         Normal 
         %cycle
            Ch = Get Key
            %if Ch = '?' %start
               Clear Line
               Feature
               Put String -
             ("The SPACE bar is the biggest key on the keyboard, just press it")
            %else
               %exit
            %finish
         %repeat
         %signal Total Abort %if Ch = EM
         Clear Line
      %finish
   %end {Continue}

   {-MAIN CODE OF DISPLAY FILE-}

   %on 9, 15 %start
      %return %if Event_Event = 15
      Continue
      %return
   %finish

   CY = Start
   Cursor (0, CY)
   Clear Line
   Featuring = No
   %cycle
      Read Symbol (Ch)
      Amount = Amount - 1   
      %if Ch = NL %start
         CY = CY + 1
         Cursor (0, CY)
         Clear Line
         More %if CY = Bottom %and -
                  Amount # 0
      %else
         Safe Put Symbol (Ch)
      %finish
   %repeat %until Amount = 0
   Continue
%end {Display File}
