C
C This file SCREEN.FOR was created to allow the file attributes to be displayed
C in a second window and not affect the file name.

C-------------------------------------------------------------------C
C Toggle:  Switch to the other format of file displays.   Also      C
C Change the command choices on the bottom of the screen.           C
C The full information will show the UIC, File protect and Time/dateC
C The 'LESSINFO' format is faster since we don't have to open and   C
C close each file to get the other information.                     C
C-------------------------------------------------------------------C
       Subroutine Toggle(Redo, Repaint) 
       Implicit Integer*4 (A - Z)
       Character*1 Maybe
       Include 'common.include'
C-------------------------------------------------------------------C
       Redo = 0
       If (Fast .EQ. 1) then
         If (lib$matchc ( CMD, 'mM') .gt. 0) then 
           Fast = 0
           Redo = 1
           Call SetChoices(Fast)
         End If
       Else 
         If (lib$matchc ( CMD, 'Ll') .gt. 0) then 
           Fast = 1
    	   redo = 0
           Do 100 I = 1, 1000
              Do 150 J = 1, 55
150                Ldattributes(I)(J:J) = ' ' 
100        Continue
           Call SetChoices(Fast)
    	   Call Write24
         End If
       End If
       Return 
       End
C-------------------------------------------------------------------C
C Write 24 lines of 'LD' array on the CRT.  Display data starts withC
C LD(TOPLINE).  TOPLINE is a global variable.                       C
C-------------------------------------------------------------------C
       Subroutine Write24
       Implicit Integer*4 (A - Z)
       Character*1 Temp
       Character*80 Temp80
       Include 'common.include'
C-------------------------------------------------------------------C
       Call Lib$Set_Cursor(1,1)
       Do I = TopLine,TopLine + 21
         Call Lib$Erase_Line((I-TopLine)+1, 1)
         If (I .LE. LastLine) then 
           Call Writel(Ld(I),(I-TopLine)+1,1)
    	   If (fast .eq. 0) then

    	     if (  (lib$matchc (':', Ld(i)) .eq. 0) .or.
     -	        (  lib$matchc ('.dir;', Ld(i)) .gt. 0)) then
    	       call writel( ldattributes(i), (i-topline) +1, 
     -		 file_attr_pos)
    	     end if !DO NOT WIPE OUT THE DIRECTORIES
    	   end if !FOR FULL DIRECTORY
         Else
           Call Lib$Erase_Page((I-TopLine)+1, 1)
           Goto 50
         End If ! .lt. lastline
       End Do
50     Continue
       Call Fix23
       Call SetChoices(Fast) ! Set up bottom line array
	if (choices .ne. ' ') then
	  Call Lib$Put_Screen(Choices, 24, 1)
	end if
       Call Writel(SmallScreen,1,1)
       Return
       End
C-------------------------------------------------------------------C
C Downarrow was entered.  Move the cursor down one line on the CRT. C
C-------------------------------------------------------------------C
       Subroutine DnArrow
       Implicit Integer*4 (A - Z)
       Include 'common.include'
C-------------------------------------------------------------------C
       Cl = CursorLine + TopLine -1
       If (Cl .LT. LastLine) then  
         Call Writel(Dull, CursorLine, 1)
    	 if (fast .eq. 1) then
    	   Call Writel(Ld(Cl), CursorLine, 1)
    	 else
    	   Call Writel(Ld(Cl)(1:file_attr_pos), CursorLine, 1)
    	   Call Writel(Ldattributes(Cl), CursorLine, file_attr_pos)
    	 end if
100      Cl = CursorLine + TopLine -1
         If (CursorLine .GT. 21) then
           TopLine = TopLine + 1
           CursorLine = 22
           Call Lib$Set_Cursor(22, 1)
C    	   call smg$put_chars ( names_id, char(13)//char(10), 22, 1)
c    	   call smg$put_chars ( names_id, ld(topline+21), 22, 1)
           Call Writel(Char(13)//Char(10),22,1)
    	   if (fast .eq. 1) then
    	     Call Writel(Ld(TopLine + 21), 22, 1)
    	   else
    	     Call Writel(Ld(TopLine + 21), 22, 1)
    	     Call Writel(Ldattributes(TopLine + 21), 22, file_attr_pos)
    	   end if
         Else
           CursorLine = CursorLine + 1
         End If
         Cl = TopLine + CursorLine - 1
         If (Cl .GT. LastLine) then 
           Cursorline = Cursorline - 1
           Goto 200
         End If
         Cl = TopLine + CursorLine - 1
         If (Cl .LT. FirstUsed) then
           TopLine = 1
           Cursorline = FirstUsed
         End If
         Cl = TopLine + CursorLine - 1
         If (Ld(Cl)(1:26) .EQ. '                          ') goto 100
         If (Ld(Cl)(1:32) 
     1      .EQ. '         Directories:  Total of ') goto 100
         If (Ld(Cl)(1:32)
     1      .EQ. '               Files:  Total of ') goto 100
         If (Ld(Cl)(1:26)
     1      .EQ. '          This Directory: ') goto 100
       End If
200    Continue
       Return
       End
C-------------------------------------------------------------------C
C Up arrow was entered.  Move the Cursor up one line on the CRT.    C
C-------------------------------------------------------------------C
       Subroutine UpArrow
       Implicit Integer*4 (A - Z)
       Include 'common.include'
C-------------------------------------------------------------------C
       If ((Cursorline .EQ. Firstused) .AND. (TopLine .EQ. 1)) then 
c    	 call mess ('quit')
c    	 call get1char(cmd)
         goto 300
       Else
         Cl = TopLine + CursorLine - 1
c   	 call smg$put_chars ( names_id, dull, cursorline, 1)
c    	 call smg$put_chars ( names_id, ld(cl),
c     -     cursorline, 1)
         Call Writel(Dull, CursorLine, 1)
    	 if (fast .eq. 1) then
c    	   call mess (' first but fast ')
           Call Writel(Ld(Cl), CursorLine, 1)
c    	 call get1char(cmd)
    	 else
c    	   call mess ('first ')
           Call Writel(Ld(Cl)(1:file_attr_pos), CursorLine, 1)
           Call Writel(Ldattributes(Cl), CursorLine, file_attr_pos)
c    	 call get1char(cmd)
    	 end if
100      Cl = TopLine + CursorLine - 1
         If (CursorLine .LT. 2) then
           TopLine = TopLine - 1
           CursorLine = 1
           Call Lib$Set_Cursor(1,1)
           Call Lib$Down_Scroll()
    	   if (fast .eq. 1) then
c    	     call mess (' second but fast ')
             Call Writel(Ld(topline), 1, 1)
c    	 call get1char(cmd)
    	   else
c    	     call mess (' second ')
             Call Writel(Ld(topline)(1:file_attr_pos), 1, 1)
    	     Call Writel(Ldattributes(TopLine), 1, file_attr_pos)
c    	 call get1char(cmd)
    	   end if
         Else
           CursorLine = CursorLine - 1
         End If
200      If (CursorLine + TopLine .LE. FirstUsed) then 
           Cursorline = FirstUsed
           TopLine = 1
           Call Write24
           Goto 300
         End If
         Cl = TopLine + CursorLine - 1
         If (Ld(Cl)(1:26)
     1      .EQ. '                          ') goto 100
         If (Ld(Cl)(1:32)
     1      .EQ. '         Directories:  Total of ') goto 200
         If (Ld(Cl)(1:32)
     1      .EQ. '               Files:  Total of ') goto 100
         If (Ld(Cl)(1:26)
     1      .EQ. '          This Directory: ') goto 200
       End If
300    Return
10010  Format('+',A80)
       End
C-------------------------------------------------------------------C
C The page key was entered.  Display the next page of 'LD' data.    C
C-------------------------------------------------------------------C
       Subroutine PAGE
       Implicit Integer*4 (A - Z)
       Include 'common.include'
C-------------------------------------------------------------------C
       Call Lib$Set_Cursor(1,1)
       Cl = Topline + Cursorline - 1
       If ((Forward .EQ. 1) 
     1    .AND. ((TopLine + 21) .GE. LastLine)) then 
c    	 call smg$put_chars ( names_id, dull, cursorline, 1)
c    	 call smg$put_chars ( names_id, ld(cl),
c     -     cursorline, 1)
         Call Writel(Dull, CursorLine, 1)
    	 if (fast .eq. 1) then
           Call Writel(Ld(Cl), CursorLine, 1)
    	 else
           Call Writel(Ld(Cl)(1:file_attr_pos), CursorLine, 1)
           Call Writel(Ldattributes(Cl), CursorLine, file_attr_pos)
    	 end if
         CursorLine = (Lastline - TopLine) + 1 ! Go to last file
         Goto 400
       End If
       If ((Forward .NE. 1)
     1    .AND. (TopLine .LT. 2)) Then
c    	 call smg$put_chars ( names_id, dull, cursorline, 1)
c    	 call smg$put_chars ( names_id, ld(cl),
c     -     cursorline, 1)
         Call Writel(Dull, CursorLine, 1)
    	 if (fast .eq. 1) then
           Call Writel(Ld(Cl), CursorLine, 1)
    	 else
           Call Writel(Ld(Cl)(1:file_attr_pos), CursorLine, 1)
           Call Writel(Ldattributes(Cl), CursorLine, file_attr_pos)
    	 end if
         CursorLine = FirstUsed
         Goto 400
       End If
       If (Forward .EQ. 1) TopLine = Topline + 20
       If (Forward .NE. 1) TopLine = TopLine - 20
       If ((TopLine + 21) .GE. LastLine) TopLine=LastLine-20
       If (TopLine .LT. 1) TopLine = 1
       SvDLast = DownLast
       Call DnArrow
       Call UpArrow
       Call Write24
       DownLast = SvDLast
400    Return
       End
C------------------------------------------------------------------C
C Change display to start at line 1 and put cursor there.          C
C------------------------------------------------------------------C
       Subroutine GoTop
       Implicit Integer*4 (A - Z)
       Include 'common.include'
C------------------------------------------------------------------C
       If (TopLine .NE. 1) then
         TopLine = 1
         Call Write24
       End If
       If (CursorLine .NE. FirstUsed) then
c    	 call smg$put_chars ( names_id, dull, cursorline, 1)
c    	 call smg$put_chars ( names_id, ld(topline+cursorline-1),
c     -     cursorline, 1)
         Call Writel(Dull, CursorLine, 1)
    	 if (fast .eq. 1) then
           Call Writel(Ld(TopLine+CursorLine-1), Cursorline, 1)
    	 else
           Call Writel(Ld(TopLine+CursorLine-1)(1:file_attr_pos), 
     -	    Cursorline, 1)
    	 end if
         CursorLine = 3
         Call Dnarrow
       End If
       Return
       End
C-------------------------------------------------------------------C
C Top of screen was entered.  Move the cursor to the first file on the CRT. C
C-------------------------------------------------------------------C
       Subroutine Top_of_Screen
       Implicit Integer*4 (A - Z)
       Include 'common.include'
C-------------------------------------------------------------------C
       Call Writel(Dull, CursorLine, 1)
       cl = topline + cursorline - 1
       if (fast .eq. 1) then
    	 Call Writel(Ld(Cl), CursorLine, 1)
       else
    	 Call Writel(Ld(Cl)(1:file_attr_pos), CursorLine, 1)
         Call Writel(Ldattributes(Cl), CursorLine, file_attr_pos)
       end if
       if (topline .eq. 1) then
          Cl = firstused
    	  cursorline = cl
       else
    	  cl = topline
    	  cursorline = 1
       end if
       Call Lib$Set_Cursor(1, 1)
       Return
       End !top of screen
C-------------------------------------------------------------------C
C Bottom of screen was entered.  Move the cursor to the last file on the CRT
C-------------------------------------------------------------------C
       Subroutine Bottom_of_Screen
       Implicit Integer*4 (A - Z)
       Include 'common.include'
C-------------------------------------------------------------------C
       Call Writel(Dull, CursorLine, 1)
       cl = topline + cursorline - 1
       if (fast .eq. 1) then
    	 Call Writel(Ld(Cl), CursorLine, 1)
       else
    	 Call Writel(Ld(Cl)(1:file_attr_pos), CursorLine, 1)
         Call Writel(Ldattributes(Cl), CursorLine, file_attr_pos)
       end if

       if ((topline + 21) .ge. lastline) then
    	  cl = lastline + 1 - topline
   	  cursorline = cl
       else
    	  cl = 22
    	  cursorline = cl
       end if

       Call Lib$Set_Cursor(cl, 1)

       Return
       End !Bottom of screen
