      subroutine zoom( pb_id, display, libdb )

      implicit	none
cc
cc Purpose:	Provide a window of expanded information about a given 
cc		generation of an element.
cc
      include	'($smgdef)'
      include	'($iodef)'
      include	'smg_refs.fin'
      include	'libed.fin'
      include	'cmsdef.fin'

      integer*4		pb_id
      record	/display/	display, z_disp
      record	/library_data_block/	libdb

      integer*4		kb_id
      integer*4		smg_stat, cms_status
      integer*4		line, col, pos
      integer*4		i
      character*80	string
      character*1	text
      integer*4		terminator
      integer*4		tokens_found, token_start(1:10), token_length(1:10)

      integer*4	chklen
      external	chklen

      integer*4	add_element_to_display
      external	add_element_to_display

cc Create a virtual display for the info.
      z_disp.width = 60
      smg_stat = smg$create_virtual_display( 15, z_disp.width, z_disp.id,
     + 			smg$m_border, smg$m_reverse )

      line = display.line
      col = 1

c  quiet SMG during display update.
      smg_stat = smg$begin_display_update(z_disp.id)

cc Get element name at present cursor position.
      smg_stat = smg$set_cursor_abs( display.id, line, col )
      smg_stat = smg$read_from_display( display.id, string )
      call find_tokens( string, 10, 
     +		tokens_found, token_start, token_length )

      do i = 1, tokens_found
         if ((token_start(i) .le. display.column) .and.
     +	     (token_start(i) + token_length(i) - 1 .ge. display.column) )then
            col = display.column
            pos = i
         endif
      enddo

      i = token_start(pos)
      z_disp.element = string(i:i+token_length(pos)-1)
      z_disp.generation = display.generation
      z_disp.type = disp_zoom

cc Label the display with the element name and generation expression.
      smg_stat = smg$label_border( z_disp.id, 
     +			string(i:i+token_length(pos)-1)//', '//
     +			display.generation(1:chklen(display.generation)),
     +			,,, smg$m_reverse )

cc Ask CMS about the element.
      cms_status = cms$show_generation( 
     +		libdb,
     +		add_element_to_display, z_disp,	! user output routine and arg.
     +		z_disp.element(1:chklen(z_disp.element)),
     +		z_disp.generation(1:chklen(z_disp.generation)),
     +		, , , 1,
     +		 )

      i = smg$cursor_row(z_disp.id)-1

      smg_stat = smg$change_virtual_display( z_disp.id, i, z_disp.width )

      smg_stat = smg$end_display_update(z_disp.id)

cc Paste up the display.
      smg_stat = 
     + 	smg$paste_virtual_display( z_disp.id, pb_id, 7, 10 )

      smg_stat = smg$set_cursor_abs( display.id, line, col )

      smg_stat = smg$create_virtual_keyboard( kb_id )

cc Wait for any character to continue.
      smg_stat = smg$read_string( 	kb_id, text,
     + 					, 1, 
     + 		io$m_escape+io$m_nofiltr+io$m_noecho+io$m_trmnoecho, ,
     + 					,
     + 					,
     + 					terminator, )

      if ( terminator .eq. smg$k_trm_ctrlw ) then
            smg_stat = smg$repaint_screen( pb_id )
      endif

cc Clean up and return.
      smg_stat = smg$delete_virtual_keyboard( kb_id )

      smg_stat = smg$pop_virtual_display( z_disp.id, pb_id )

      end
