enqueue.icn: Procedures for queued events

procedure pack_intrvl:     encode event interval
procedure unpack_intrvl:   decode event interval
procedure pack_modkeys:    encode modifier keys
procedure unpack_modkeys:  decode modifier keys
procedure Enqueue:         enqueue event

link enqueue
May 2, 2001; Gregg M. Townsend
Requires: Version 9 graphics
This file is in the public domain.

These procedures manipulate Icon window events.

Enqueue(W, eventcode, x, y, modkeys, interval) posts an event.

pack_modkeys(s)         encodes the modifier keys for an event.
unpack_modkeys(n)       decodes a modifier key value.

pack_intrvl(n)          encodes an event interval.
unpack_intrvl(n)        decodes an event interval.
____________________________________________________________

   Icon's event queue is a list accessed via Pending(); the list
can be inspected or altered by the Icon program.  An event is stored
as three consecutive entries on the list.  The first is the event code:
a string for a keypress, or an integer for any other event.  The next
two list entries are integers, interpreted as a packed structure:
    0000 0000 0000 0SMC  XXXX XXXX XXXX XXXX   (second entry)
    0EEE MMMM MMMM MMMM  YYYY YYYY YYYY YYYY   (third entry)

The fields have these meanings:
    X...X   &x: 16-bit signed x-coordinate value
    Y...Y   &y: 16-bit signed y-coordinate value
    SMC     &shift, &meta, and &control (modifier keys)
    E...M   &interval, interpreted as  M * 16 ^ E
    0       currently unused; should be zero


   pack_modkeys(s) encodes a set of modifier keys, returning an
integer with the corresponding bits set.  The string s contains
any combination of the letters c, m, and s to specify the bits
desired.

   pack_intrvl(n) encodes an interval of n milliseconds and returns
a left-shifted integer suitable for combining with a y-coordinate.

   unpack_modkeys(n) returns a string containing 0 to 3 of the
letters c, m, and s, depending on which modifier key bits are
set in the argument n.

   unpack_intrvl(n) discards the rightmost 16 bits of the integer
n (the y-coordinate) and decodes the remainder to return an
integer millisecond count.

   Enqueue([window,] eventcode, x, y, modkeys, interval) synthesizes
and enqueues an event for a window, packing the interval and modifier
keys (specified as above) into the correct places.  Default values
are:
    eventcode = &null
    x = 0
    y = 0
    interval = 0
    modkeys = ""

Source code | Program Library Page | Icon Home Page