;1;; -*-* Mode:LISP; Package:LASER2; Base:8; Fonts:(CPTFONT HL12B); Readtable:CL 1-*-*
;1;; Copyright (c) 1985, LISP Machine, Inc.*

;1;; Description: Laser2 data structures*
;1;; Programmer: James M. Turner*

;1;; FNORD FNORD FNORD FNORD FNORD FNORD FNORD FNORD FNORD FNORD*
;1;; FNORD FNORD            Note to the Illuminated:           FNORD FNORD*
;1;; FNORD FNORD    Fnords have been liberally distributed     FNORD FNORD*
;1;; FNORD FNORD    in the sources to create a sense of      FNORD FNORD*
;1;; FNORD FNORD    tension and discomfort in anyone who    FNORD FNORD*
;1;; FNORD FNORD    tries to muck with the code.             FNORD FNORD*
;1;; FNORD FNORD            --- The DO Illuminati             FNORD FNORD*
;1;; FNORD FNORD                 (Death to LOOP!)            FNORD FNORD*
;1;; FNORD FNORD FNORD FNORD FNORD FNORD FNORD FNORD FNORD FNORD*


;1;; The flavor used to run the Laser2.*
;1;; Instance variables:*
;1;;*
;1;; TCP-STREAM: The stream which actually transmits characters to the*
;1;; Laser2. This also gets bound to a file stream when queuing to another machine.*
;1;;*
;1;; PRINTER-QUEUE: The list of jobs waiting to be printed.*
;1;;*
;1;; SERVER-PROCESS: So we can reset or kill ourselves.*
;1;;*
;1;; FONT-COUNT: The total number of fonts used in IMAGE mode*
;1;;*
;1;; FONT-STACK: Used to return to current font after doing things like headers.*
;1;;*
;1;; HEADER-FONT-NUMBER: Since the header font could also be a normal font used*
;1;; in the text, don't download it twice.*
;1;;*
;1;; FONT-DESCRIPTORS: A list of FDs in the same order as FONTS.*
;1;;*
;1;; V-POS: Where are we vertically?*
;1;;*
;1;; PAGE-COUNT: Page number*
;1;;*
;1;; CHAR-COUNT: How many characters across the line are we?*
;1;;*
;1;; FONTS: List of all font names, in the same order as FONT-DESCRIPTORS*
;1;;*
;1;; FONT-MAPS: The maps inside the FDs.*
;1;;*
;1;; CURRENT-MAP: The map for CURRENT-FONT*
;1;;*
;1;; LINE-SPACE: Amount of line consumed so far.*
;1;;*
;1;; LASER2-REMOTE: If NIL, I own a TCP connection to a Laser2, if a string,*
;1;; the name of a Lambda that owns a TCP connection I can use.*
;1;;*
;1;; CURRENT-DESCRIPTOR, CURRENT-FONT: See CURRENT-MAP.*
;1;;*
;1;; CURRENT-JOB: The entry in PRINTER-QUEUE currently being printed.*

(defflavor laser2-stream
	   (tcp-stream
	    (printer-queue)
	    server-process
	    font-count
	    font-stack
	    header-font-number
	    font-descriptors
	    v-pos
	    page-count
	    char-count
	    fonts
	    font-maps
	    current-map
	    line-space
	    current-descriptor
	    current-font
	    laser2-remote
	    current-job) ()
  :settable-instance-variables
  :gettable-instance-variables
  :initable-instance-variables)


(defmethod (laser2-stream :after :init) (&rest ignore)
  (send self :poll-bridges))

(defun poll-bridges ()
  (send *laser2-stream* :poll-bridges))

(defmethod (laser2-stream :poll-bridges) ()
  (if (and (find-package "TCP")
	   (boundp (intern "*TCP-ENABLED-P*" 'tcp))
	   (symeval (intern "*TCP-ENABLED-P*" 'tcp)))
      (setq laser2-remote nil)
    (if (setq laser2-remote (laser2-find-server)) ()
	  (setq laser2-remote :NONE))))

;1;; The present instantiation of LASER2-STREAM*

(defvar *laser2-stream* nil)

(defvar reporting-window nil)

(defvar *laser2-print-mode* :IMAGE)

(defvar *default-orientation* ':portrait)

(defvar laser2-owner-lock nil)


