(*$M-*)
DEFINITION MODULE Printer;

FROM SYSTEM IMPORT
 CAST;
FROM Exec IMPORT
 nonstd,DevicePtr,IOFlagSet,Message,UnitPtr,UByte;
FROM Graphics IMPORT
 ColorMapPtr,RastPortPtr,ViewModeSet;

CONST
 printerName="printer.device";
 rawWrite=nonstd+0;
 prtCommand=nonstd+1;
 dumpRPort=nonstd+2;

 ris=0;     (* ESCc  reset                    ISO *)
 rin=1;     (* ESC#1 initialize               +++ *)
 ind=2;     (* ESCD  lf                       ISO *)               
 nel=3;     (* ESCE  return,lf                ISO *)         
 ri=4;      (* ESCM  reverse lf               ISO *)      
 
 sgr0=5;    (* ESC[0m normal char set         ISO *)    
 sgr3=0;    (* ESC[3m italics on              ISO *)        
 sgr23=7;   (* ESC[23m italics off            ISO *)
 sgr4=8;    (* ESC[4m underline=0;            ISO *)
 sgr24=9;   (* ESC[24m underline off          ISO *)
 sgr1=10;   (* ESC[1m boldface on             ISO *)
 sgr22=11;  (* ESC[22m boldface off           ISO *)
 sfc=12;    (* SGR30-39  set foreground color ISO *)
 sbc=13;    (* SGR40-49  set background color ISO *)

 shorp0=14; (* ESC[0w normal pitch            DEC *)
 shorp2=15; (* ESC[2w elite on                DEC *)
 shorp1=16; (* ESC[1w elite off               DEC *)
 shorp4=17; (* ESC[4w condensed fine on       DEC *)
 shorp3=18; (* ESC[3w condensed off           DEC *)
 shorp6=19; (* ESC[6w enlarged on             DEC *)
 shorp5=20; (* ESC[5w enlarged off            DEC *)

 den6=  21; (* ESC[6"z shadow print on        DEC (sort of) *)
 den5=  22; (* ESC[5"z shadow print off       DEC *)
 den4=  23; (* ESC[4"z doublestrike on        DEC *)
 den3=  24; (* ESC[3"z doublestrike off       DEC *)
 den2=  25; (* ESC[2"z  NLQ on                DEC *)
 den1=  26; (* ESC[1"z  NLQ off               DEC *)

 sus2=  27; (* ESC[2v superscript on          +++ *)
 sus1=  28; (* ESC[1v superscript off         +++ *)
 sus4=  29; (* ESC[4v subscript on            +++ *)
 sus3=  30; (* ESC[3v subscript off           +++ *)
 sus0=  31; (* ESC[0v normalize the line      +++ *)
 plu=   32; (* ESCL  partial line up          ISO *)
 pld=   33; (* ESCK  partial line down        ISO *)

 fnt0=  34; (* ESC(B US char set              DEC *)
 fnt1=  35; (* ESC(R French char set          DEC *)
 fnt2=  36; (* ESC(K German char set          DEC *)
 fnt3=  37; (* ESC(A UK char set              DEC *)
 fnt4=  38; (* ESC(E Danish I char set        DEC *)
 fnt5=  39; (* ESC(H Sweden char set          DEC *)
 fnt6=  40; (* ESC(Y Italian char set         DEC *)
 fnt7=  41; (* ESC(Z Spanish char set         DEC *)
 fnt8=  42; (* ESC(J Japanese char set        +++ *)
 fnt9=  43; (* ESC(6 Norweign char set        DEC *)
 fnt10= 44; (* ESC(C Danish II char set       +++ *)

 prop2= 45; (* ESC[2p  proportional on        +++ *)
 prop1= 46; (* ESC[1p  proportional off       +++ *)
 prop0= 47; (* ESC[0p  proportional clear     +++ *)
 tss=   48; (* ESC[n E set proportional offset ISO *)
 jfy5=  49; (* ESC[5 F auto left justify      ISO *)
 jfy7=  50; (* ESC[7 F auto right justify     ISO *)
 jfy6=  51; (* ESC[6 F auto full justify      ISO *)
 jfy0=  52; (* ESC[0 F auto justify off       ISO *)
 jfy3=  53; (* ESC[3 F letter space (justify) ISO (special) *)
 jfy1=  54; (* ESC[1 F word fill(auto center) ISO (special) *)

 verp0= 55; (* ESC[0z  1/8" line spacing      +++ *)
 verp1= 56; (* ESC[1z  1/6" line spacing      +++ *)
 slpp=  57; (* ESC[nt  set form length n      DEC *)
 perf=  58; (* ESC[nq  perf skip n (n>0)      +++ *)
 perf0= 59; (* ESC[0q  perf skip off          +++ *)

 lms=   60; (* ESC#9   Left margin set        +++ *)
 rms=   61; (* ESC#0   Right margin set       +++ *)
 tms=   62; (* ESC#8   Top margin set         +++ *)
 bms=   63; (* ESC#2   Bottom marg set        +++ *)
 stbm=  64; (* ESC[Pn1;Pn2r  T&B margins      DEC *)
 slrm=  65; (* ESC[Pn1;Pn2s  L&R margin       DEC *)
 cam=   66; (* ESC#3   Clear margins          +++ *)

 hts=   67; (* ESCH    Set horiz tab          ISO *)
 vts=   68; (* ESCJ    Set vertical tabs      ISO *)
 tbc0=  69; (* ESC[0g  Clr horiz tab          ISO *)
 tbc3=  70; (* ESC[3g  Clear all h tab        ISO *)
 tbc1=  71; (* ESC[1g  Clr vertical tabs      ISO *)
 tbc4=  72; (* ESC[4g  Clr all v tabs         ISO *)
 tbcall=73; (* ESC#4   Clr all h & v tabs     +++ *)
 tbsall=74; (* ESC#5   Set default tabs       +++ *)
 extend=75; (* ESC[Pn"x extended commands     +++ *)
 
TYPE
 Error=(
  e0,cancel,notGraphics,invertHam,badDimension,dimensionOvflow,
  internalMemory,bufferMemory
 );
 IOPrinter=RECORD
  message:Message;
  device:DevicePtr;
  unit:UnitPtr;
  command:CARDINAL;
  flags:IOFlagSet;
  error:Error;
  prtCommand:CARDINAL;
  parm0:UByte;
  parm1:UByte;
  parm2:UByte;
  parm3:UByte;
 END;
 IOPrinterPtr=POINTER TO IOPrtCmdReq;
 Special=(
  milCols,milRows,fullCols,fullRows,fracCols,fracRows,center,
  aspect,density1,density2,density4
 );
 SpecialSet=SET OF Special;

CONST
 density3=SpecialSet{density1,density2};
 densityMask=CAST(SpecialSet,0F00H);

TYPE
 IODRPReq=RECORD
  message:Message;
  device:DevicePtr;
  unit:UnitPtr;
  command:CARDINAL;
  flags:IOFlagSet;
  error:Error;
  rastPort:RastPortPtr;
  colorMap:ColorMapPtr;
  modesHi:CARDINAL;
  modes:ViewModeSet;
  srcX:CARDINAL;
  srcY:CARDINAL;
  srcWidth:CARDINAL;
  srcHeight:CARDINAL;
  destCols:LONGINT;
  destRows:LONGINT;
  special:SpecialSet;
 END;
 IODRPReqPtr=POINTER TO IODRPReq;
 
END Printer.
