############################################################################
#
#	File:     events.icn
#
#	Subject:  Program to show events
#
#	Author:   Ralph E. Griswold
#
#	Date:     September 20, 1994
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This program lists the events that occur in the execution of the icode
#  file given as the first argument on the command line.  Any other command-
#  line arguments are passed to the icode file.
#
#  The image of the event code is given in the first column, its
#  description is given in the second column, and an image of the
#  event value is given in the third column.
#
#  The following option is supported:
#
#	-o s	direct output to file named s; default &output
#
############################################################################
#
#  Requires:  MT-Icon and event monitoring.
#
############################################################################
#
#  Links:  evinit, evnames, evsyms, options
#
############################################################################

link evinit
link evnames
link evsyms
link options

procedure main(args)
   local opts, output, symmap

   symmap := evsyms()

   opts := options(args, "o:")
   output := open(\opts["o"], "w") | &output

   EvInit(args) | stop("*** cannot open icode file ***")


   while EvGet() do
      write(output, left(\symmap[&eventcode], 14),
         left(evnames(&eventcode), 35), image(&eventvalue))

end
