EpsonFX1PrinterStream.st
author Claus Gittinger <cg@exept.de>
Sat, 11 Nov 1995 16:22:01 +0100
changeset 112 3e18f2cfe430
parent 85 df13b436b54e
child 126 fca9404da9d4
permissions -rw-r--r--
uff - version methods changed to return stings

"
 COPYRIGHT (c) 1991 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

PrinterStream subclass:#EpsonFX1PrinterStream
	 instanceVariableNames:''
	 classVariableNames:''
	 poolDictionaries:''
	 category:'Streams-External'
!

!EpsonFX1PrinterStream class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1991 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

version
    ^ '$Header: /cvs/stx/stx/libbasic2/EpsonFX1PrinterStream.st,v 1.11 1995-11-11 15:21:19 cg Exp $'
!

documentation
"
    This class defines protocol for simple text prinitng on an Epson-FX1
    (and compatible) printer. It knows the escape codes for bold, italic etc.

    I cannot tell, if this is really an Epson -
    all I have is a Citizen 120D to test - the doc says its an FX1.
"
! !

!EpsonFX1PrinterStream methodsFor:'layout'!

reset
    super nextPut:(Character esc).
    super nextPut:$@
!

pageHeight:inch
    super nextPut:(Character esc).
    super nextPut:$C.
    super nextPut:(Character value:0).
    super nextPut:(Character value:inch)
!

linesPerPage:n
    super nextPut:(Character esc).
    super nextPut:$C.
    super nextPut:(Character value:n)
!

noTopMargin
    super nextPut:(Character esc).
    super nextPut:$O
!

topMargin:n
    super nextPut:(Character esc).
    super nextPut:$N.
    super nextPut:(Character value:n)
!

proportional:aBoolean
    super nextPut:(Character esc).
    super nextPut:$p.
    aBoolean ifTrue:[
	super nextPut:$1
    ] ifFalse:[
	super nextPut:$0
    ]
!

newPage
    super nextPut:(Character value:12)
! !

!EpsonFX1PrinterStream methodsFor:'access writing'!

character:char fromCharacterSet:set
    "send a character from an alternate character set"

    "send <ESC>R<set><char><ESC>R<\0>"
    super nextPut:(Character esc).
    super nextPut:$R.
    super nextPut:(Character value:set).
    super nextPut:char.
    super nextPut:(Character esc).
    super nextPut:$R.
    super nextPut:(Character value:0)
!

nextPut:aCharacter
    "catch special characters 
     - currently only german umlauts are handled - needs more"

    |ascii|

    ascii := aCharacter asciiValue.
    (ascii < 128) ifTrue:[
	^ super nextPut:aCharacter
    ].
    (ascii == 16rfc) ifTrue:[   "udiaeresis"
	^ self character:$} fromCharacterSet:2
    ].
    (ascii == 16re4) ifTrue:[   "adiaeresis"
	^ self character:${ fromCharacterSet:2
    ].
    (ascii == 16rf6) ifTrue:[   "odiaeresis"
	^ self character:$| fromCharacterSet:2
    ].
    (ascii == 16rdc) ifTrue:[   "Udiaeresis"
	^ self character:$] fromCharacterSet:2
    ].
    (ascii == 16rc4) ifTrue:[   "Adiaeresis"
	^ self character:$[ fromCharacterSet:2
    ].
    (ascii == 16rd6) ifTrue:[   "Odiaeresis"
	^ self character:$\ fromCharacterSet:2
    ].
    (ascii == 16rdf) ifTrue:[   "ssharp"
	^ self character:$~ fromCharacterSet:2
    ]
!

cr
    "have to output cr-nl here"

    super nextPutUntranslated:(Character value:13).
    super nextPutUntranslated:(Character value:10).
    self spaces:LeftMargin
!

bold
    "set font to bold"

    "send <ESC>G will do that"
    super nextPut:(Character esc).
    super nextPutAll:'G'
!

italic
    "set font to italic"

    "send <ESC>4 will do that"
    super nextPut:(Character esc).
    super nextPutAll:'4'
!

normal
    "set font to normal"

    "send <ESC>H<ESC>5 will do that"
    super nextPut:(Character esc).
    super nextPutAll:'H'.
    super nextPut:(Character esc).
    super nextPutAll:'5'
! !