pro oneline_event,event
;
;+
;   Name: oneline_event
;
;   Purpose: event driver for oneline
;
;   History:
;	10-Jan-1994 (SLF)
;-
common oneline_blk, baseid

top_struct=get_wuvalue(event.top)
case (strtrim(event_name(event),2)) of
   "BUTTON":begin                               ; option selection
      case strupcase(get_wvalue(event.id)) of
         "QUIT": begin
		widget_control, event.top,/destroy, bad_id=destroyed
		delvarx, baseid
	    endcase
	  "SHOW HEADER":      top_struct.docmode= 1-event.select
	  "SHOW SOURCE CODE": top_struct.docmode= event.select
          else: message,/info,"UNKNOWN BUTTON"
       endcase
   endcase 
   "LIST": begin
      if top_struct.docbase eq 0 then begin
         doc_base=widget_base(/column,title='Documentation')
	 doc_text=widget_text(doc_base,ysize=30,xsize=80,/scroll)
	 top_struct.docbase=doc_base
         top_struct.doctext=doc_text      
	 xmanager,'dochead',doc_base, event='oneline_event', $
	    group=top_struct.topbase
         widget_control, doc_base, /realize
      endif
      widget_control,/sensitive, top_struct.mbuts(0)
      widget_control,/sensitive, top_struct.mbuts(1)
      widget_control,top_struct.docbase, /map, /sensitive
      cfiles=get_wuvalue(event.id)
      filepath=path_sw(cfiles(event.index))
      header=['------ FILE: ' + filepath + ' ------','']
      if filepath(0) ne '' then text=rd_tfile(filepath) else $
	text="Can't Find File: " + cfiles(event.index) + ' !!'
      startt=(wc_where(text,';+*'))(0) > 0
      stopt = (wc_where(text,';-*'))(0) > 0
      if top_struct.docmode eq 0 and (stopt-startt ge 0) then $
	  text=text(startt:stopt)
;      if stopt-startt eq 0 then head=text else head=text(startt:stopt)
      text=[header,text]
      widget_control,set_value=text,top_struct.doctext
   endcase
endcase

widget_control,event.top, set_uvalue=top_struct, bad_id=destroyed

return
end

