source: branches/1.9-appstore/source/cocoa-ide/hemlock/unused/archive/screen.lisp

Last change on this file was 6567, checked in by Gary Byers, 18 years ago

Move lots of (currently unused, often unlikely to ever be used) stuff to an
archive directory.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1;;; -*- Log: hemlock.log; Package: Hemlock-Internals -*-
2;;;
3;;; **********************************************************************
4;;; This code was written as part of the CMU Common Lisp project at
5;;; Carnegie Mellon University, and has been placed in the public domain.
6;;;
7#+CMU (ext:file-comment
8 "$Header$")
9;;;
10;;; **********************************************************************
11;;;
12;;; Written by Bill Chiles.
13;;;
14;;; Device independent screen management functions.
15;;;
16
17(in-package :hemlock-internals)
18
19
20
21;;;; Screen management initialization.
22
23(declaim (special *echo-area-buffer*))
24
25;;; %INIT-SCREEN-MANAGER creates the initial windows and sets up the data
26;;; structures used by the screen manager. The "Main" and "Echo Area" buffer
27;;; modelines are set here in case the user modified these Hemlock variables in
28;;; his init file. Since these buffers don't have windows yet, these sets
29;;; won't cause any updates to occur. This is called from %INIT-REDISPLAY.
30;;;
31(defun %init-screen-manager (display)
32 (setf (buffer-modeline-fields *current-buffer*)
33 (value hemlock::default-modeline-fields))
34 (setf (buffer-modeline-fields *echo-area-buffer*)
35 (value hemlock::default-status-line-fields))
36 (if (windowed-monitor-p)
37 (init-bitmap-screen-manager display)
38 (init-tty-screen-manager (get-terminal-name))))
39
40
41
42
43;;;; Window operations.
44
45(defun make-window (start &key (modelinep t) (device nil) window
46 (proportion .5)
47 (font-family *default-font-family*)
48 (ask-user nil) x y
49 (width (value hemlock::default-window-width))
50 (height (value hemlock::default-window-height)))
51 "Make a window that displays text starting at the mark start. The default
52 action is to make the new window a proportion of the current window's height
53 to make room for the new window.
54
55 Proportion determines what proportion of the current window's height
56 the new window will use. The current window retains whatever space left
57 after accommodating the new one. The default is to split the current window
58 in half.
59
60 Modelinep specifies whether the window should display buffer modelines.
61
62 Device is the Hemlock device to make the window on. If it is nil, then
63 the window is made on the same device as CURRENT-WINDOW.
64
65 Window is an X window to be used with the Hemlock window. The supplied
66 window becomes the parent window for a new group of windows that behave
67 in a stack orientation as windows do on the terminal.
68
69 Font-Family is the font-family used for displaying text in the window.
70
71 If Ask-User is non-nil, Hemlock prompts the user for missing X, Y, Width,
72 and Height arguments to make a new group of windows that behave in a stack
73 orientation as windows do on the terminal. This occurs by invoking
74 hi::*create-window-hook*. X and Y are supplied as pixels, but Width and
75 Height are supplied in characters."
76
77 (let* ((device (or device (device-hunk-device (window-hunk (current-window)))))
78 (window (funcall (device-make-window device)
79 device start modelinep window font-family
80 ask-user x y width height proportion)))
81 (unless window (editor-error "Could not make a window."))
82 (invoke-hook hemlock::make-window-hook window)
83 window))
84
85(defun delete-window (window)
86 "Make Window go away, removing it from the screen. This uses
87 hi::*delete-window-hook* to get rid of parent windows on a bitmap device
88 when you delete the last Hemlock window in a group."
89 (when (<= (length *window-list*) 2)
90 (error "Cannot kill the only window."))
91 (invoke-hook hemlock::delete-window-hook window)
92 (setq *window-list* (delq window *window-list*))
93 (funcall (device-delete-window (device-hunk-device (window-hunk window)))
94 window)
95 ;;
96 ;; Since the programmer's interface fails to allow users to determine if
97 ;; they're commands delete the current window, this primitive needs to
98 ;; make sure Hemlock doesn't get screwed. This inadequacy comes from the
99 ;; bitmap window groups and the vague descriptions of PREVIOUS-WINDOW and
100 ;; NEXT-WINDOW.
101 (when (eq window *current-window*)
102 (let ((window (find-if-not #'(lambda (w) (eq w *echo-area-window*))
103 *window-list*)))
104 (setf (current-buffer) (window-buffer window)
105 (current-window) window))))
106
107(defun next-window (window)
108 "Return the next window after Window, wrapping around if Window is the
109 bottom window."
110 (check-type window window)
111 (funcall (device-next-window (device-hunk-device (window-hunk window)))
112 window))
113
114(defun previous-window (window)
115 "Return the previous window after Window, wrapping around if Window is the
116 top window."
117 (check-type window window)
118 (funcall (device-previous-window (device-hunk-device (window-hunk window)))
119 window))
120
121
122
123
124;;;; Random typeout support.
125
126;;; PREPARE-FOR-RANDOM-TYPEOUT -- Internal
127;;;
128;;; The WITH-POP-UP-DISPLAY macro calls this just before displaying output
129;;; for the user. This goes to some effor to compute the height of the window
130;;; in text lines if it is not supplied. Whether it is supplied or not, we
131;;; add one to the height for the modeline, and we subtract one line if the
132;;; last line is empty. Just before using the height, make sure it is at
133;;; least two -- one for the modeline and one for text, so window making
134;;; primitives don't puke.
135;;;
136(defun prepare-for-random-typeout (stream height)
137 (let* ((buffer (line-buffer (mark-line (random-typeout-stream-mark stream))))
138 (real-height (1+ (or height (rt-count-lines buffer))))
139 (device (device-hunk-device (window-hunk (current-window)))))
140 (funcall (device-random-typeout-setup device) device stream
141 (max (if (and (empty-line-p (buffer-end-mark buffer)) (not height))
142 (1- real-height)
143 real-height)
144 2))))
145
146;;; RT-COUNT-LINES computes the correct height for a window. This includes
147;;; taking wrapping line characters into account. Take the MARK-COLUMN at
148;;; the end of each line. This is how many characters long hemlock thinks
149;;; the line is. When it is displayed, however, end of line characters are
150;;; added to the end of each line that wraps. The second INCF form adds
151;;; these to the current line length. Then INCF the current height by the
152;;; CEILING of the width of the random typeout window and the line length
153;;; (with added line-end chars). Use CEILING because there is always at
154;;; least one line. Finally, jump out of the loop if we're at the end of
155;;; the buffer.
156;;;
157(defun rt-count-lines (buffer)
158 (with-mark ((mark (buffer-start-mark buffer)))
159 (let ((width (window-width (current-window)))
160 (count 0))
161 (loop
162 (let* ((column (mark-column (line-end mark)))
163 (temp (ceiling (incf column (floor (1- column) width))
164 width)))
165 ;; Lines with no characters yield zero temp.
166 (incf count (if (zerop temp) 1 temp))
167 (unless (line-offset mark 1) (return count)))))))
168
169
170;;; RANDOM-TYPEOUT-CLEANUP -- Internal
171;;;
172;;; Clean up after random typeout. This clears the area where the
173;;; random typeout was and redisplays any affected windows.
174;;;
175(defun random-typeout-cleanup (stream &optional (degree t))
176 (let* ((window (random-typeout-stream-window stream))
177 (buffer (window-buffer window))
178 (device (device-hunk-device (window-hunk window)))
179 (*more-prompt-action* :normal))
180 (update-modeline-field buffer window :more-prompt)
181 (random-typeout-redisplay window)
182 (setf (buffer-windows buffer) (delete window (buffer-windows buffer)))
183 (funcall (device-random-typeout-cleanup device) stream degree)
184 (when (device-force-output device)
185 (funcall (device-force-output device)))))
186
187;;; *more-prompt-action* is bound in random typeout streams before
188;;; redisplaying.
189;;;
190(defvar *more-prompt-action* :normal)
191(defvar *random-typeout-ml-fields*
192 (list (make-modeline-field
193 :name :more-prompt
194 :function #'(lambda (buffer window)
195 (declare (ignore window))
196 (ecase *more-prompt-action*
197 (:more "--More--")
198 (:flush "--Flush--")
199 (:empty "")
200 (:normal
201 (concatenate 'simple-string
202 "Random Typeout Buffer ["
203 (buffer-name buffer)
204 "]")))))))
Note: See TracBrowser for help on using the repository browser.