english
version "1.0"
identify "%Z%%M% %I% %E%"

#: Copyright (c) 1997 by Wayne C. Gramlich.
#, All rights reserved.
#,
#, Permission to use, copy, modify, distribute, and sell this software
#, for any purpose is hereby granted without fee provided that the above
#, copyright notice and this permission are retained.  The author makes
#, no representations about the suitability of this software for any purpose.
#, It is provided "as is" without express or implied warranty.

module x_char_generate

#: This module generates the {x_char} module and associated C interface code.

import
    c_import
    character
    format
    in_stream
    logical
    out_stream
    string
    system
    vector
    unsigned

procedure main
    takes
	system system
    returns unsigned

    #: This procedure will test out the c_import code.

    c_stream :@= system.standard_out_stream
    stipple_stream :@= c_stream

    c_import :@= create@c_import("x_char")
    import_standard@(c_import)

    type_short_integer :@= c_import.type_short_integer
    type_short_unsigned :@= c_import.type_short_unsigned

    include_append@(c_import, "X11/Xlib.h")
    #include_append@(c_import, "X11/Xutil.h")
    #import_append@(c_import, "x_display")

    c_record :@= record_create@(c_import, typedef_struct, "XCharStruct",
      "x_char", "X11 character record", true, true, true)
    field_append@(c_record, "lbearing", type_short_integer, "left_bearing",
      '#: Left edge of record', true, false)
    field_append@(c_record, "rbearing", type_short_integer, "right_bearing",
      '#: Right edge of record', true, false)
    field_append@(c_record, "width", type_short_integer, "width",
      '#: Distance to next character origin', true, false)
    field_append@(c_record, "ascent", type_short_integer, "ascent",
      '#: Baseline to top edge of character', true, false)
    field_append@(c_record, "descent", type_short_integer, "descent",
      '#: Baseline to bottom edge of character', true, false)
    field_append@(c_record, "attributes", type_short_integer, "attributes",
      '#: Per character flags (not predefined)', true, false)

    # Declare interface routines:
    comment :@= allocate@string()
    #string_append@(comment,
    # '    #: This procedure will lookup and return the keyboard character\n\')
    #string_append@(comment,
    #  '    #, number associated with {event} and {index}.\n\')
    #procedure2_append@(c_import,
    #  "XLookupKeysym", "keyboard_symbol_lookup", "x_key_event",
    #  type_unsigned,
    # 'event', type_x_key_event, 'index', type_unsigned, comment)

    if process@(c_import, 'x_key_event_generate', system)
	return 1
    return 0
