PreviousUpNext

15.4.822  src/lib/prettyprint/big/devices/simple-textio-dev.pkg

## simple-textio-dev.pkg
## A simple (no styles) pretty-printing device for output to file outstreams.

# Compiled by:
#     src/lib/prettyprint/big/devices/prettyprint-devices.sublib

###                 "Teach us delight in simple things,
###                  and mirth that has no bitter springs."
###
###                                   -- Rudyard Kipling



package simple_text_io_device: (weak)
api {

    include Prettyprint_Device;         # Prettyprint_Device    is from   src/lib/prettyprint/big/src/prettyprint-device.api

    open_device:  {   dst:  file::Output_Stream,
                      wid:  Int
                  } -> Device;

}
{
    Device = DEV  {
        dst:  file::Output_Stream,
        wid:  Int
      };

    Style = Void;            # No style support 

    fun same_style    _ = TRUE;
    fun push_style    _ = ();
    fun pop_style     _ = ();
    fun default_style _ = ();

    open_device = DEV;

    # Maximum printing depth (in terms of boxes) 
    #
    fun depth _ = NULL;

    # The width of the device 
    #
    fun line_width (DEV { wid, ... } ) = THE wid;

    # The suggested maximum width of text on a line 
    #
    fun text_width _ = NULL;

    # Output some number of spaces to the device:
    #
    fun space (DEV { dst, ... }, n)
        =
        file::write (dst, number_string::pad_left ' ' n "");

    # Output a newline to the device:
    #
    fun newline (DEV { dst, ... } )
        =
        file::write_one (dst, '\n');

    # Output a string/character in
    # the current style to the device:
    #
    fun string (DEV { dst, ... }, s) = file::write (dst, s);
    fun char (DEV { dst, ... }, c) = file::write_one (dst, c);

    # If the device is buffered,
    # then flush any buffered output:
    #
    fun flush (DEV { dst, ... } ) = file::flush dst;

};



## COPYRIGHT (c) 1997 Bell Labs, Lucent Technologies.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2012,
## released under Gnu Public Licence version 3.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext