    ! EDTEXT - Text generator for EDWIN

    !############################################################################
    !#                                                                          #
    !#  This is a module from the EDWIN Graphics Package, which was developed   #
    !#  in the Department of Computer Science, at Edinburgh University, from    #
    !#  1978 to the present day, release 5 of EDWIN in October 1984.            #
    !#                                                                          #
    !#  The principal author of the EDWIN Graphics Package was J Gordon Hughes, #
    !#  while working for the Edinburgh University Computer Sceince Department. #
    !#  Parts of EDWIN have been produced by many different people, too many    #
    !#  too mention, working for different departments of Edinburgh and Leeds   #
    !#  Universities.                                                           #
    !#                                                                          #
    !#  This module is regarded as being in the public domain, and the authors  #
    !#  and accept no responsibility regarding the uses to which the software   #
    !#  will be put.                                                            #
    !#                                                                          #
    !############################################################################

    from Edwin include Specs
    from Edwin include Iprocs
    from Edwin include Icodes

    own integer TEXT FONT ESC CHAR = DISABLED
    own integer TEXT COLOUR ESC CHAR = DISABLED

    external routine TEXT alias "EDWIN_TEXT" (string(255) ST)
       integer I, OC, OF, C  { OC = Original Colour & Font, C is Char }
       OC = DISABLED;   OF = DISABLED
       for I = 1, 1, LENGTH(ST) cycle
            C = CHARNO(ST,I)
            if C=TEXT COLOUR ESC CHAR start
                if LENGTH(ST)-I>1 and '0'<=CHARNO(ST,I+1)<='9' start
                    C = CHARNO(ST,I+1) - '0';   I = I + 1
                    if LENGTH(ST)-I>1 and '0'<=CHARNO(ST,I+1)<='9' start
                        C = C * 10 + CHARNO (ST, I+1) - '0';   I = I + 1
                    finish
                    GET ATTRIBUTE (ATT COLOUR, OC) if OC=DISABLED { Remember original }
                    SET COLOUR (C)                                 { Set New colour }
                    continue
                finish
            finish else if C=TEXT FONT ESC CHAR start
                if LENGTH(ST)-I>1 and '0'<=CHARNO(ST,I+1)<='9' start
                    C = CHARNO(ST,I+1) - '0';   I = I + 1
                    if LENGTH(ST)-I>1 and '0'<=CHARNO(ST,I+1)<='9' start
                        C = C * 10 + CHARNO (ST, I+1) - '0';   I = I + 1
                    finish
                    GET ATTRIBUTE (ATT CHAR FONT, OF) if OF=DISABLED { Remember original }
                    SET CHAR FONT (C)                                 { Set New font }
                    continue
                finish
            finish
            CHARACTER (C)
       repeat
       SET COLOUR (OC) if OC#DISABLED      { Restore original colour }
       SET CHAR FONT (OF) if OF#DISABLED   { Restore original font   }
    end

    external routine TEXT COLOUR ESCAPE alias "EDWIN_TEXT_COL_ESC" (integer CH)
       TEXT COLOUR ESC CHAR = CH
    end

    external routine TEXT FONT ESCAPE alias "EDWIN_TEXT_FONT_ESC" (integer CH)
       TEXT FONT ESC CHAR = CH
    end

    external routine INQUIRE TEXT SIZE  alias "EDWIN_INQ_TEXT_SIZE" (string (255) T, integer name X, Y)
       integer OX, OY, NX, NY, Device
       Inquire Position (OX, OY)
       Device = Device Data_Dev No
       Device Data_Dev No = -1
       Text (t)
       Inquire Position (NX, NY)
       X = NX - OX
       Y = NY - OY
       Move Abs (OX, OY)
       Device Data_Dev No = Device
    end

    end of file