1 ;;; BEGIN INCLUDE FILE emacs-rdis-dcls.incl.lisp
  2 
  3 
  4 ;;; HISTORY COMMENTS:
  5 ;;;  1) change(87-12-23,Schroth), approve(), audit(), install():
  6 ;;;     Original Written: Way back when by BSGreenberg
  7 ;;;  2) change(87-12-23,Schroth), approve(88-02-29,MCR7852),
  8 ;;;     audit(88-06-08,RBarstad), install(88-08-01,MR12.2-1071):
  9 ;;;     Updated for split-screen changes: defined displayline and split
 10 ;;;     structures, changed named arrays to array pointers.  Used
 11 ;;;     defmacro and defstruct changes from Barry Margolin.
 12 ;;;                                                      END HISTORY COMMENTS
 13 
 14 
 15 
 16 ;;; Include file for Emacs redisplay modules
 17 
 18 (%include defmacro)
 19 (declare (macros nil))                            ;drop these macros at load
 20 (%include defstruct)
 21 (%include backquote)
 22 (%include setf)
 23 
 24 ;;; Macro to make an array pointer look like a named array
 25 ;;; This creates a special variable and an access macro with the name given
 26 ;;; as the first argument.  The remaining variable number of arguments define
 27 ;;; the number of arguments the access macro needs and correspond to array
 28 ;;; dimensions.  Note that the array is NOT allocated by this macro.  The
 29 ;;; programmer must do so manually.
 30 ;;; Note that since the access macro generates an 'arraycall', it may be
 31 ;;; used with setf.  This is not the case with named arrays.
 32 
 33 (defmacro defarray (array-name &rest indices)
 34           `(progn 'compile
 35                   (declare (special ,array-name))
 36                   (defmacro ,array-name (,@indices)
 37                             (list 'arraycall t ',array-name ,@indices))))
 38 
 39 (defarray screen line-index)                      ;Screen rdis-lines
 40 (defarray newscreen line-index)                   ;New windows being built
 41 (defarray eline-conts line-index)                 ;Old linecontents
 42 
 43 (defarray windows window-num)                     ;Window structures
 44 (defarray uwindows uwindow-index)                 ;User-indices into windows.
 45 
 46 ;;;
 47 ;;; Screen Hardware Window Data Structures
 48 ;;;
 49 ;;; Hardware windows are called "splits" to avoid confusion with the EMACS
 50 ;;; concept of a window.
 51 ;;;
 52 
 53 (defarray splits split-index)                     ;one entry / hardware window
 54 
 55 ;;; The above array has one entry per hardware window the terminal can display.
 56 ;;; When not in split mode, only one is active and it is not really used.
 57 ;;; In split mode, this array stores the entire redisplay state for that
 58 ;;; split (hardware window) as if it were the entire screen.
 59 ;;; Moving to a new window causes a context switch using this array.
 60 ;;; See the (defstruct (split ...)) definition below.
 61 
 62 
 63 (defarray usplits usplit-number)                  ;one entry per user split
 64                                                   ; these index into the
 65                                                   ; splits array
 66 
 67 (defmacro aos (x) `(incf ,x))
 68 (defmacro sos (x) `(decf ,x))
 69 (defmacro rbarf (message &optional object)
 70           `(error ,message ,object 'fail-act))
 71 
 72 ;;;
 73 ;;;  Screen/editorline structures
 74 ;;;
 75 (defstruct (window
 76              (:eval-when (eval compile))
 77              (:type list))
 78            (startline 0)
 79            (numlines 0)
 80            (bufmark nil)
 81            (bufsym nil)
 82            (window-split nil))                    ;split the  window is in
 83 
 84 (defmacro rplac-startline (window new-startline)
 85           `(setf (startline ,window) ,new-startline))
 86 (defmacro rplac-numlines (window new-numlines)
 87           `(setf (numlines ,window) ,new-numlines))
 88 (defmacro rplac-bufmark (window new-bufmark)
 89           `(setf (bufmark ,window) ,new-bufmark))
 90 (defmacro rplac-bufsym (window new-bufsym)
 91           `(setf (bufsym ,window) ,new-bufsym))
 92 (defmacro rplac-split (window split)
 93           `(setf (window-split ,window) ,split))
 94 
 95 (defstruct (uwindow                               ;user window array element
 96              (:eval-when (eval compile))
 97              (:type list)
 98              (:conc-name))
 99            (windowx 0)                            ;index into windows array
100            (split nil))                           ;split owning the uwindow
101 
102 (defmacro uwind (window-number)
103           `(windows (uwindow-windowx (uwindows ,window-number))))
104 (defmacro uwind-split (window-number)             ;returns split given uwindows index
105           `(uwindow-split (uwindows ,window-number)))
106 
107 ;;;
108 ;;; Display-line structure.
109 ;;; (This commentary lifted from e_redisplay)
110 ;;;
111 ;;;       Screen is maintained as the array "screen", containing knowledge
112 ;;;       and images of screen. Each element of "screen" is called a "displayline",
113 ;;;       and looks like this:
114 ;;;
115 ;;;       (editorline "printablerepresentationwithnonewline" . printinglength)
116 ;;;
117 ;;;       The array "newscreen" is used during redisplay computation only.
118 ;;;
119 ;;;       The array "eline-conts" parallels the window array of redisplay lines
120 ;;;       maintaining what e_ calls "line-contents" so that an "eq" check can
121 ;;;       be made (see redisplay-window) to avoid detabbification and resultant
122 ;;;       consing, for eq lines with eq contents cannot detabbify differently.
123 
124 (defstruct (displayline
125              (:eval-when (eval compile))
126              (:type list*))                       ;save a cons cell
127            (eline nil)                            ;the editorline
128            (linedata nil)                         ;the directly displayable image w/o NL
129            (lineln 0))                            ;interesting length of image
130 ;;;
131 ;;; Display-line special macros. These operate on the screen array elements.
132 ;;;
133 (defmacro rplac-eline (displayline new-eline)
134           `(setf (eline ,displayline) ,new-eline))
135 (defmacro rplac-linedata (displayline new-linedata)
136           `(setf (linedata ,displayline) ,new-linedata))
137 (defmacro rplac-lineln (displayline new-lineln)
138           `(setf (lineln ,displayline) ,new-lineln))
139 
140 ;;;
141 ;;; The screen split data structure
142 ;;;
143 ;;; This structure is used to contain the data relevant to a screen split (hardware window)
144 ;;; which is viewed as a seperate virtual screen.  As such, all display screen
145 ;;; data is stored in a split structure when that split is not active. When a split is
146 ;;; active, its data is copied into the globalredisplay and window manager data
147 ;;; (after the prior data.)
148 ;;;
149 
150 (defstruct (split
151              (:eval-when (eval compile))
152              (:type array)                        ;use arrays to speed access to elements
153              (:conc-name))
154            (line-length 0)                        ;usable split width (consider cursor wrap, scrolling etc.)
155            (width 0)                              ;real width on screen (used only be creation stuff)
156            (height 0)                             ;split depth = main-window-size
157            (id 0)                                 ;used to talk to CTL
158            (home-X 0)                             ;home location on ABS screen
159            (home-Y 0)
160            (damaged t)                            ;needs to be redisplayed
161            (screen nil)                           ;array of display-lines
162            (eline-conts nil)                      ;array of corr. elines
163            (windows nil)                          ;the windows in this split
164            (nwindows 0))
165 
166 
167 ;;; END   INCLUDE FILE emacs-rdis-dcls.incl.lisp