-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprojector-ui.lisp
2331 lines (2157 loc) · 103 KB
/
projector-ui.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; Change History (most recent first):
;; 8 10/31/95 Bill St. Clair Move *global-comment* before all uses
;; 6 10/24/95 bill Fix bugs in remote-download code
;; 5 10/23/95 bill Remote download support
;; 4 10/13/95 bill This time for sure
;; 3 10/13/95 bill ccl3.0x25
;; 2 10/13/95 bill 3.0x25
;; 4 5/15/95 akh fix map-pathname-windows per Kalmans report
;; 3 4/11/95 akh use *tool-back-color*, add :content-color where needed
;; 2 4/4/95 akh stop trying to outsmart fred. Fred knows best.
;; 17 3/20/95 akh dont remember - twas trivial
;; 16 2/9/95 akh probably no change
;; 15 2/6/95 akh check-in-projects does modro on local disk vs: checkout modifiable because we hate true checkout.
;; Default button for mount projects is "Mount All"
;; Default button for checkout or modro is modro.
;; 14 2/3/95 akh in file-cancel-checkout - compare name with *user* not initials
;; 13 1/25/95 akh add colors, newproject dialog somewhat less confusing
;; and doesnt ask if local directory already exists (in "sslocal:")
;;
;; 12 1/17/95 akh we seem to have lost the "No comment" button
;; 11 1/17/95 akh use without-event-processing
;; 10 1/11/95 akh some merge was messed up
;; 8 1/11/95 akh move (menu-install *projector-menu*) here, window-show nil for select-projects
;; (do not edit before this line!!)
;;
;; 11/3/95 bill add "Global" button to comment-dialog. It sets *global-comment*, which
;; causes check-in-projects to use that comment for the rest of the files.
;; 10/24/95 bill set-checkin-categories-action enqueues its actions
;; 10/23/95 bill update checkoutNewerAll & CheckoutNewerCur for new arglist to check-out-projects.
;; check-out-projects now handles updating from a directory.
;; 10/13/95 bill file-checkin preserves the write date across adding hte checking comment
;; changed *lock-file-name* to "version".
;; check-in-projects no longer deletes the *lock-file-name* from the files
;; to be checked in. It does make it be checked in last, which was the
;; code's intention.
;; 11/12/95 bill file-checkout-or-modro can now return nil to mean "leave it read-only"
;; 3/24/94 akh 'character => 'base-character
;;;; The more user-interface oriented parts of the source code control system:
;;;; dialogs, menus, window manipulation functions, and the high-level
;;;; source code control functions that tie all these together with the
;;;; low-level functions (in project and projector).
;;;;
;;;; Parts of this used to live in projector.lisp
;;;;
;;;; @@@ perhaps there ought to be a project-ui mixin to the project class;
;;;; then there wouldn't need to be separate functions with separate names
;;;; for the versions of these that manipulate the user interface
(in-package :ccl)
;(require "PROJECT")
;(require "PROJECTOR")
;;;
;;; Global variables
;;;
(defvar ccl::*save-all-old-projector-versions* nil)
(defvar ccl::*scan-on-mount* t)
;;; Let the user choose scan or not. It is put in the dialog box when mounting.
;;; Hai Wang 7/9/93
(setf ccl::*scan-on-mount* nil) ; Do NOT scan when mounting initially.
(defvar *current-project* nil)
(defvar *break-on-projector-errors* nil)
(declaim (special *projects-menu* *projector-menu* *scan-project-files-menu-item*
ccl::*my-projects*))
#|
;; the following parameter should be defined to the appropriate value in init.lisp
;;; e.g., a reasonable entry in your init.lisp might be:
(setf ccl::*my-projects*
'(("Sources:Ralph:Projects:" "Newton:")
("Sources:Ralph:Environment:" "Environment:")))
|#
;; @@@ this is a terrible, terrible kludge
(defun my-projects ()
(declare (special ccl::*my-projects*))
(loop
(when (boundp 'ccl::*my-projects*)
(return ccl::*my-projects*))
(cerror "Use new value for ~s."
"The variable ~s must be initialized."
'ccl::*my-projects*)))
(defparameter *lockfile-name* "version.lisp")
(defvar *last-checkout-comment* "")
;;;
;;; Window utility functions
;;;
(defun map-pathname-windows (fn pathname)
(setq pathname (full-pathname pathname))
(map-windows #'(lambda (window &aux (window-filename (window-filename window)))
(and window-filename
(equalp (full-pathname window-filename) pathname)
(funcall fn window)))
:class 'fred-window :include-invisibles t))
(defun pathname-window (path)
(do-pathname-windows (window path) (return-from pathname-window window))
nil)
(defun y-or-n-or-other-dialog (message &key (size #@(318 145))
(position (list :top (+ 2 *menubar-bottom*)))
(yes-text "Yes")
(no-text "No")
(other-text "Other")
(cancel-text "Cancel")
help-spec)
(modal-dialog
(make-instance 'ccl::keystroke-action-dialog
:window-type :double-edge-box
:view-size size
:view-position position
:window-show nil
:help-spec (getf help-spec :dialog)
:view-subviews
`(
,(make-dialog-item 'static-text-dialog-item
#@(20 12) (subtract-points size #@(38 72))
message nil :help-spec (getf help-spec :dialog))
,(make-dialog-item 'default-button-dialog-item
(subtract-points size #@(102 27))
#@(74 18) yes-text
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog :yes))
:help-spec (getf help-spec :yes-text))
,(make-dialog-item 'button-dialog-item
(subtract-points size #@(102 53))
#@(74 18) no-text
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog :no))
:help-spec (getf help-spec :no-text))
,(make-dialog-item 'button-dialog-item
(subtract-points size #@(200 27))
#@(74 18) other-text
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog :other))
:help-spec (getf help-spec :other-text))
,(make-dialog-item 'button-dialog-item
(if cancel-text
;(subtract-points size #@(102 77))
(make-point 25 (- (point-v size) 27))
#@(5000 5000)) ;off screen
#@(74 18) (or cancel-text "")
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog :cancel))
:help-spec (getf help-spec :cancel-text))))))
;(y-or-n-or-other-dialog "message")
(defun file-checkout-or-modro (path)
(case (y-or-n-or-other-dialog
(format nil "~/pp-path/ is not modifiable." path) :yes-text "ModRO"
:no-text "CheckOut" :other-text "ReadOnly")
(:no (file-checkout path) t)
(:yes (file-modro path) t)
(:other nil)))
;;let people know when they try to modify a read-only file
(defun help-on-attempt-to-modify-readonly-buffer (window)
(let ((path (window-filename window)))
(if (pathname-project-p path)
(file-checkout-or-modro path "You are attempting to modify a read-only buffer controlled by Projector. The file should be checked out or set to ModifyReadOnly mode.")
(ed-beep))))
(defun set-path-windows-readonly-state (path state message &key revert)
(do-pathname-windows (window path)
(when revert
(setf (read-only-state window) #.$ckid-readwrite)
(window-revert window t))
(setf (read-only-state window)
(getf '(:read-only #.$ckid-readonly
:modify-read-only #.$ckid-modifyreadonly
:read-write #.$ckid-readwrite) state))
(when message
(set-mini-buffer window message))))
#| ; let fred do this for you
(defmacro with-editor-excursion (window &body body)
(let ((scroll-pos (gensym "SCROLL-POS"))
(selection-start (gensym "SELECTION-START"))
(selection-end (gensym "SELECTION-END")))
`(let ((,scroll-pos (buffer-position (fred-display-start-mark ,window))))
(multiple-value-bind (,selection-start ,selection-end)
(selection-range ,window)
,@body
;; @@@ check that these values are still in range
(set-selection-range ,window ,selection-start ,selection-end) ; this should return to current pos
(set-mark (fred-display-start-mark ,window) ,scroll-pos)))))
|#
;;;
;;; Projects menu
;;;
;; alice added
(defclass project-menu-item (menu-item)
((project :initarg :project :accessor menu-item-project)))
;; alice added
(defmethod menu-item-action ((item project-menu-item))
(set-current-project (menu-item-project item)))
;; alice added
(defun find-projects-menu-item (menu project)
(dolist (item (menu-items menu))
(when (eq project (menu-item-project item))
(return item))))
;;; put check-mark next to the current project
(defun projector-menu-update ()
(let ((current *current-project*))
(dolist (item (menu-items *projects-menu*))
(set-menu-item-check-mark item nil))
(when current
(let ((item (find-projects-menu-item *projects-menu* current)))
(when item ; if its not on menu maybe shouldnt be current either.
(set-menu-item-check-mark item t))))))
;;; add items to the Projector menu that list each mounted project and selecting that item
;;; will set that as the current project.
;;; Now titles of subprojects are indented by depth (alice)
(defun make-projects-menu ()
(menu-install *projects-menu*)
(apply #'remove-menu-items *projects-menu* (menu-items *projects-menu*))
;; @@@ ought to be able to use *projects*
(dolist (project *mounted-projects*)
(unless nil ;(find-menu-item *projects-menu* name)
(add-new-item *projects-menu*
(indented-project-name project)
nil
:class 'project-menu-item
:project project))))
;; alice added
(defun indented-project-name (project)
(let* ((depth (project-depth project))
(name (project-name project)))
(if (eq depth 0)
name
(concatenate 'string (make-string depth :initial-element #\space)
name))))
;;;
;;; Filenames in Projector menu
;;;
(defun find-or-open-pathname (path)
(let ((window (pathname-window path)))
(if window
(window-select window)
(if (eq :TEXT (mac-file-type path))
(make-instance *default-editor-class* :filename path)
(message-dialog (format nil "~/pp-path/ is not a text file" path))))))
(defclass project-file-menu-item (menu-item)
((pathname :accessor menu-item-pathname :initarg :pathname)
(checkout-state :accessor menu-item-checkout-state :initarg :checkout-state)))
(defmethod menu-item-title ((item project-file-menu-item))
(concatenate 'string
(case (menu-item-checkout-state item)
(:modro "* ")
(:checked-out "+ ")
(t " "))
(file-namestring (menu-item-pathname item))))
(defmethod initialize-instance ((item project-file-menu-item) &rest initargs)
(apply #'call-next-method item initargs)
(setf (slot-value item 'ccl::title) (menu-item-title item)))
(defmethod menu-item-action ((item project-file-menu-item))
(find-or-open-pathname (menu-item-pathname item)))
(defun find-project-file-menu-item (path)
(dolist (item (menu-items *projector-menu*) nil)
(when (and (typep item 'project-file-menu-item)
(equalp (menu-item-pathname item) path))
(return item))))
(defun insert-menu-item (menu item position)
(let* ((all-items (menu-items menu))
(after-items (nthcdr position all-items)))
(apply #'remove-menu-items menu after-items)
(apply #'add-menu-items menu item after-items)))
(defun add-filename-to-projector-menu (path checkout-state)
(unless (find-project-file-menu-item path)
(let ((namestring (file-namestring path)))
(insert-menu-item
*projector-menu*
(make-instance 'project-file-menu-item :pathname path :checkout-state checkout-state)
(1+ (position-if #'(lambda (item)
(let ((title (menu-item-title item)))
(or (string-equal "-" title)
(string-greaterp namestring (subseq title 2)))))
(menu-items *projector-menu*) :from-end t))))))
(defun maybe-add-filename-menu (file)
(let ((state (project-file-local-state (pathname-project file) file)))
(when (and (pathname-project-p file)
(member state '(:modro :checked-out)))
(add-filename-to-projector-menu file state))))
(defun remove-filename-from-projector-menu (path)
(remove-menu-items *projector-menu* (find-project-file-menu-item path)))
(defun update-projector-file-state (path &optional (remote-changed t))
(remove-filename-from-projector-menu path)
(maybe-add-filename-menu path)
(close-checkin-categories-dialog)
(let ((window (find-file-info-window path)))
(when window
(invalidate-view window)
(update-file-info-window window remote-changed))))
(defun remove-all-filename-menus (&optional project)
(apply #'remove-menu-items *projector-menu*
(remove-if-not #'(lambda (item)
(and (typep item 'project-file-menu-item)
(or (null project)
(eq (pathname-project (menu-item-pathname item)) project))))
(menu-items *projector-menu*))))
;;;
;;; Dialogs
;;;
#|
;; Same as y-or-n-dialog, except only two buttons and one of them cancels.
(defun okay-or-cancel-dialog (message &key (size #@(250 200))
(position (list :top (+ 2 *menubar-bottom*)))
(okay-text "Okay")
(cancel-text "Cancel")
help-spec)
(modal-dialog
(make-instance 'ccl::keystroke-action-dialog
:window-type :double-edge-box
:view-size size
:view-position position
:window-show nil
:help-spec (getf help-spec :dialog)
:view-subviews
`(
,(make-dialog-item 'static-text-dialog-item
#@(20 12) (subtract-points size #@(38 72))
message nil :help-spec (getf help-spec :dialog))
,(make-dialog-item 'default-button-dialog-item
(make-point 20 (- (point-v size) 30))
#@(74 18) okay-text
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog t))
:help-spec (getf help-spec :okay-text))
,(make-dialog-item 'button-dialog-item
(subtract-points size #@(#.(+ 20 74) 30))
#@(74 18) cancel-text
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog :cancel))
:help-spec (getf help-spec :cancel-text))))))
|#
;;;
;;; Hai made some changes on it because we are all farmiliar with the "OK" button
;;; on the right and the "Cancel" button on the left.
;;;
(defun okay-or-cancel-dialog (message &key (size #@(300 200))
(position (list :top (+ 6 *menubar-bottom*)))
(okay-text "OK")
(cancel-text "Cancel")
help-spec)
(modal-dialog
(make-instance 'ccl::keystroke-action-dialog
:window-type :movable-dialog
:window-title ""
:back-color *tool-back-color*
:view-size size
:view-position position
:window-show nil
:help-spec (getf help-spec :dialog)
:view-subviews
`(
,(make-dialog-item 'static-text-dialog-item
#@(20 12) (subtract-points size #@(38 72))
message nil :help-spec (getf help-spec :dialog))
,(make-dialog-item 'default-button-dialog-item
(subtract-points size #@(#.(+ 20 74) 30))
#@(72 20) okay-text
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog t))
:help-spec (getf help-spec :okay-text))
,(make-dialog-item 'button-dialog-item
(make-point 20 (- (point-v size) 30))
#@(72 20) cancel-text
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog :cancel))
:help-spec (getf help-spec :cancel-text))))))
(defun cancel-checkout-dialog (path)
(modal-dialog
(make-instance 'dialog
:window-type :movable-dialog
:window-title ""
:back-color *tool-back-color*
:window-show nil
:view-position '(:top 100)
:view-size #@(428 150)
:view-subviews
(list (make-dialog-item 'static-text-dialog-item #@(16 7) #@(402 100)
(format nil "Cancel checkout for ~/pp-path/ and:~
~%¥ Keep changes and convert to ModifyReadOnly.~
~%¥ Throw away changes and retrieve latest version."
path))
(make-dialog-item 'button-dialog-item #@(16 120) #@(62 16)
"Cancel"
#'(lambda (item) (declare (ignore item))
(return-from-modal-dialog :cancel)))
(make-dialog-item 'button-dialog-item #@(140 120) #@(110 16)
"Keep Changes"
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog t))
:default-button t)
(make-dialog-item 'button-dialog-item #@(290 120) #@(120 16)
"Throw Away"
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog nil)))))))
;(cancel-checkout-dialog (pathname (front-window)))
#|
(defun center-size-in-screen (size-point)
(let* ((x (truncate (- *screen-width* (point-h size-point)) 2))
(y (max 44 (- (truncate *screen-height* 3) (point-v size-point)))))
(make-point x y)))
|#
#|
;;; Following code opens a dialog to ask user for a comment
(defun comment-dialog (file &optional (initial-comment ""))
(let* ((view-size #@(362 172))
(c-dialog
(make-instance 'color-dialog
:window-type :double-edge-box
:window-title "Projector Comment"
:view-position '(:top 44)
:view-size view-size
:window-show nil
:view-subviews
(list
(make-dialog-item 'static-text-dialog-item
#@(10 10) #@(300 16)
"What are your changes to:")
(make-dialog-item 'static-text-dialog-item
#@(10 26) nil (namestring file)
)
(make-dialog-item 'editable-text-dialog-item
#@(10 50) #@(340 80) initial-comment nil
:view-nick-name 'replace-text-item
:allow-returns t :WRAP-P T)
(make-dialog-item 'button-dialog-item
#@(90 145) #@(70 20) "OK"
#'(lambda (item)
(let ((my-dialog (view-container item)))
(return-from-modal-dialog
(dialog-item-text (view-named 'replace-text-item my-dialog)))))
;; should not default if <CR> doesn't actuate
:default-button t
)
(make-dialog-item 'button-dialog-item
#@(180 145) #@(70 20) "Cancel"
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog :cancel)))))))
(modal-dialog c-dialog)))
|#
(defvar *global-comment* nil)
;;;
;;; For the same reason, we put the "OK" button on the right.
;;; Hai Wang. 7/7/93
;;;
;;; Also added a field for the user to change the initials if modification is done somewhere
;;; else on another persons machine. The change is optional.
;;; Hai Wang. 7/7/93
;;;
(defun comment-dialog (file &optional (initial-comment ""))
(let* ((view-size #@(400 205))
(result)
(c-dialog
(make-instance 'color-dialog
;:window-type :double-edge-box
:window-title "Projector Comment"
:back-color *tool-back-color*
:view-position '(:top 44)
:view-size view-size
:window-show nil
:close-box-p nil
:view-subviews
(list
(make-dialog-item 'static-text-dialog-item
#@(10 10) #@(300 16)
"What are your changes to:")
(make-dialog-item 'static-text-dialog-item
#@(10 26) nil (namestring (back-translate-pathname file))
)
(make-instance 'scrolling-fred-view
:view-position #@(10 50)
:view-size #@(360 70)
:dialog-item-text initial-comment
:view-nick-name 'replace-text-item
:allow-returns t :WRAP-P T)
(make-dialog-item 'static-text-dialog-item
#@(10 143) #@(90 16)
"Your initials:")
(make-dialog-item 'editable-text-dialog-item
#@(105 143) #@(245 16) *user-initials*
#'(lambda (item)
(setf *user-initials* (dialog-item-text item)))
:view-nick-name 'initials
:allow-returns nil :WRAP-P nil)
(make-dialog-item 'button-dialog-item
#@(280 172) #@(70 20) "OK"
#'(lambda (item)
(let* ((my-dialog (view-container item))
(text (dialog-item-text (view-named 'replace-text-item my-dialog))))
(window-close my-dialog)
(setq result text)))
:default-button t)
(make-dialog-item 'button-dialog-item
#@(200 172) #@(70 20) "Cancel"
#'(lambda (item)
(let ((w (view-window item)))
(window-close w)
; <<<this is probably wrong - fix it later
(setq result :cancel))))
(make-dialog-item 'button-dialog-item
#@(90 172) #@(90 20) "No Comment"
#'(lambda (item)
(let ((w (view-window item)))
(window-close w)
; <<<this is probably wrong - fix it later
(setq result :no-comment))))
(make-dialog-item 'button-dialog-item
#@(10 172) #@(70 20) "Global"
#'(lambda (item)
(let* ((my-dialog (view-container item))
(text (dialog-item-text (view-named 'replace-text-item my-dialog))))
(window-close my-dialog)
(setq *global-comment* text)
(setq result text))))))))
(window-show c-dialog)
(with-event-processing-enabled ;let-globally ((*processing-events* nil))
(loop
(event-dispatch t)
(when result
(return result))))))
(defclass secret-editable-text (editable-text-dialog-item)
((secret-string :accessor secret-string
:initform (make-array '(0) :element-type 'base-character :fill-pointer t :adjustable t))))
(defmethod view-key-event-handler ((item secret-editable-text) char)
(call-next-method item #\¥)
(let ((string (secret-string item)))
(if (eq char #\backspace)
(setf (fill-pointer string) (max 0 (1- (fill-pointer string))))
(vector-push-extend char string))))
(defun volume-server-alist ()
(declare (special ccl::*volume-server-alist*))
(and (boundp 'ccl::*volume-server-alist*)
ccl::*volume-server-alist*))
#|
;;; Useful code from Guillame Cartir
(defconstant $zoneNameOffset 24)
(defconstant $serverNameOffset 57)
(defconstant $volNameOffset 89)
(defconstant $userNameOffset 117)
(defconstant $userPassWordOffset 147)
(defconstant $volPassWordOffset 158)
(defun remote-mount (zone server user password volume
&optional (volpass ""))
(rlet ((afp :AFPVolMountInfo
:length 167
:media :|afpm|
:flags 0
:nbpInterval 5
:nbpCount 10
:uamType 6
:zoneNameOffset $zoneNameOffset
:serverNameOffset $serverNameOffset
:volNameOffset $volNameOffset
:userNameOffset $userNameOffset
:userPassWordOffset $userPassWordOffset
:volPassWordOffset $volPassWordOffset))
(%put-string afp zone $zoneNameOffset)
(%put-string afp server $serverNameOffset)
(%put-string afp volume $volNameOffset)
(%put-string afp user $userNameOffset)
(%put-string afp password $userPassWordOffset)
(%put-string afp volpass $volPassWordOffset)
(rlet ((pb :ParamBlockRec
:ioCompletion (%null-ptr)
:ioBuffer afp))
(#_PBVolumeMount pb))))
|#
(defun user-mount-volume (volume &key zone server)
(declare (special ccl::*user-initials*))
(let* ((guestp nil)
(user-name (or (ccl::chooser-name)
(and (boundp 'ccl::*user-initials*) ccl::*user-initials*)
""))
(password "")
(password-item
(make-dialog-item 'secret-editable-text #@(104 205) #@(65 17) ""
#'(lambda (item) (setq password (secret-string item)))))
(disappearing-items
(list
(make-dialog-item 'static-text-dialog-item #@(26 179) #@(71 16) "Name:")
(make-dialog-item 'static-text-dialog-item #@(26 206) #@(73 16) "Password:" nil)
(make-dialog-item 'editable-text-dialog-item #@(104 178) #@(263 17) user-name
#'(lambda (item) (setq user-name (dialog-item-text item))))
password-item)))
(let ((ass (assoc volume (volume-server-alist) :test #'string-equal)))
(setq zone (or zone (cadr ass) "")
server (or server (caddr ass) "")))
(let ((dialog
(make-instance 'dialog
:window-type :movable-dialog
:window-title ""
:back-color *tool-back-color*
:content-color *tool-back-color*
:view-position '(:top 150)
:view-size #@(377 283)
:close-box-p nil
:view-font '("Chicago" 12 :srcor :plain)
:window-show nil
:view-subviews
(append
(list (make-dialog-item
'static-text-dialog-item #@(5 5) #@(255 16) "Connect to shared disk in:")
(make-dialog-item 'static-text-dialog-item #@(23 33) #@(48 16) "Zone:")
(make-dialog-item 'editable-text-dialog-item #@(81 33) #@(186 17) zone
#'(lambda (item) (setq zone (dialog-item-text item))))
(make-dialog-item 'static-text-dialog-item #@(23 61) #@(51 16) "Server:")
(make-dialog-item 'editable-text-dialog-item #@(81 61) #@(186 17) server
#'(lambda (item) (setq server (dialog-item-text item))))
(make-dialog-item 'static-text-dialog-item #@(23 88) #@(56 16) "Volume:")
(make-dialog-item 'editable-text-dialog-item #@(81 87) #@(186 17) volume
#'(lambda (item) (setq volume (dialog-item-text item))))
(make-dialog-item 'radio-button-dialog-item #@(23 125) #@(72 16) "Guest"
#'(lambda (item)
(setq guestp t)
(apply #'remove-subviews (view-container item) disappearing-items)))
(make-dialog-item 'radio-button-dialog-item #@(23 143) #@(167 16) "Registered User"
#'(lambda (item)
(setq guestp nil)
(apply #'add-subviews (view-container item) disappearing-items))
:radio-button-pushed-p t)
(make-dialog-item 'button-dialog-item #@(295 253) #@(62 16) "OK"
#'(lambda (item) (declare (ignore item)) (return-from-modal-dialog t)) :default-button T)
(make-dialog-item 'button-dialog-item #@(23 253) #@(62 16) "Cancel"
#'(lambda (item) (declare (ignore item)) (return-from-modal-dialog :cancel))))
disappearing-items))))
(set-current-key-handler dialog password-item)
(modal-dialog dialog))
(let ((place (concatenate 'string zone (if (or (eq 0 (length zone))(find #\: zone)) "" ":")
server (if (or (eq 0 (length server))(find #\: server)) "" ":")
volume)))
; this doesnt work for sourceserver - maybe sourceserver is broken
(if guestp
(mpw-mount-volume place)
(mpw-mount-volume place :user user-name :password password))))
(let ((time (get-universal-time)))
(loop
(if (probe-file volume) (return))
(event-dispatch t)
(if (> 10 (- (get-universal-time) time))
(error "Timeout mounting volume: ~s" volume)))))
;;;
;;; This dialog is for the report of a project
;;; Hai Wang 7/7/93
;;;
(defun report-dialog ()
(let* ((start-date "")
(end-date "")
(start-exclusive nil)
(end-exclusive nil)
(dialog
(make-instance 'color-dialog
:window-type :movable-dialog
:window-title ""
:back-color *tool-back-color*
:content-color *tool-back-color*
:view-position '(:top 60)
:view-size #@(300 150)
:close-box-p nil
:view-font '("Chicago" 12 :srcor :plain)
:view-subviews
(list (make-dialog-item
'static-text-dialog-item
#@(13 46)
#@(40 16)
"From:"
'nil)
(make-dialog-item
'editable-text-dialog-item
#@(57 46)
#@(129 16)
""
#'(lambda (item)
(setf start-date (dialog-item-text item)))
:allow-returns
nil)
(make-dialog-item
'check-box-dialog-item
#@(203 46)
#@(83 16)
"Exclusive"
#'(lambda (item)
(setf start-exclusive (check-box-checked-p item))))
(make-dialog-item
'static-text-dialog-item
#@(14 84)
#@(23 16)
"To:"
'nil)
(make-dialog-item
'editable-text-dialog-item
#@(57 84)
#@(128 16)
""
#'(lambda (item)
(setf end-date (dialog-item-text item)))
:allow-returns
nil)
(make-dialog-item
'check-box-dialog-item
#@(204 84)
#@(80 16)
"Exclusive"
#'(lambda (item)
(setf end-exclusive (check-box-checked-p item))))
(make-dialog-item
'button-dialog-item
#@(130 120)
#@(70 20)
"Cancel"
#'(lambda (item)
(declare (ignore item))
(return-from-modal-dialog :cancel))
:default-button
nil)
(make-dialog-item
'button-dialog-item
#@(219 120)
#@(70 20)
"OK"
#'(lambda (item)
(declare (ignore item))
;(format t "~&start: ~s end: ~s start-ex: ~s end-ex: ~s~%" start-date end-date start-exclusive end-exclusive)
(return-from-modal-dialog (values start-date end-date start-exclusive end-exclusive)))
:default-button
t)
(make-dialog-item
'static-text-dialog-item
#@(12 10)
#@(263 16)
"Please specify dates:"
'nil)))))
(modal-dialog dialog)
))
(defun make-report ()
(let ((project *current-project*)
(args nil))
(if project
(progn
(multiple-value-bind (start-date end-date start-exclusive end-exclusive)
(report-dialog)
(cond
((and (string= start-date "") (string= end-date ""))
(setf args (append args (list :comments t))))
((string= end-date "")
(setf args (append args (list :revision-dates
(concatenate 'string
(if start-exclusive ">" "³")
start-date)
:comments t))))
((string= start-date "")
(setf args (append args (list :revision-dates
(concatenate 'string
(if end-exclusive "<" "²")
end-date)
:comments t))))
(t
(setf args (append args (list :revision-dates
(concatenate 'string
start-date "-" end-date)
:comments t))))))
(setf args (cons project args))
;(format t "~&~s" args)
(format t "~a" (apply #'project-info-text args)))
(format t "~&No project to report."))
))
;;;
;;; Attempt to filter out other things than the comments. But failed. Hai Wang.
;;;
(defun filter-for-comments (string)
(let ((search-string "Comment:")
(start 0)
(end 0)
(end-of-comments
(concatenate
'string
"\""
(make-sequence 'string 1 :initial-element #\newline)
" "))
(temp string)
(result-string ""))
(loop
(setf start (search search-string temp))
(unless start (return result-string))
(setf temp (subseq temp start))
(setf end (search end-of-comments temp))
(if end
(progn
(setf result-string
(concatenate 'string
result-string " "
(subseq temp 0 end)))
(setf temp (subseq temp end)))
(return result-string)))))
(defun comment-report (date-string)
(dolist (project *mounted-projects*)
(format t "~a" (project-info-text project :comments t :revision-dates date-string))))
;;;
;;; Project commands
;;;
(defun report-project-error (error)
(when *break-on-projector-errors*
(error error))
(message-dialog (princ-to-string error))
(cancel))
;; The syntax of handler-bind with the syntax of handler-case.
;; Mainly so that I can have a nice syntax for handlers that
;; have access to restarts, which handler-case doesn't do.
;; @@@ ought to declare the clauses dynamic-extent, I suppose
(defmacro with-handlers (form &body clauses)
`(handler-bind
,(mapcar #'(lambda (clause)
(destructuring-bind (case arglist &rest body) clause
`(,case #'(lambda ,arglist ,@body))))
clauses)
,form))
;; @@@ should add a clause here to automount the project
(defmacro project-handler-case (form &body clauses)
`(handler-bind
((project-error #'report-project-error))
(with-handlers ,form ,@clauses)))
#|
(defun user-mount-project (&optional project)
(unless (and project (project-mounted-p project))
(if *mounted-projects*
(if (y-or-n-dialog (format nil "Project ~a not mounted - mount it now?" project)
:yes-text "Mount"
:no-text "Cancel"
:cancel-text nil)
(mount-some-projects)
(cancel))
(if (y-or-n-dialog "No projects are mounted - mount all now?"
:yes-text "All"
:no-text "Select"
:cancel-text "Cancel")
(Mount-All-Projects)
(mount-some-projects))))
(if project (project-mounted-p project)))
|#
;;;
;;; Checking out and in all
;;;
(defvar *close-checkin-categories-dialog* t)
(defclass file-list-dialog-item (sequence-dialog-item)
())
(defmethod cell-contents-string ((item file-list-dialog-item) cell)
(ccl::pathname-to-window-title (cell-contents item cell)))
(defclass filelist-pane (view) ())
(defmethod set-view-size ((view filelist-pane) h &optional v)
(call-next-method view h v)
(let* ((size (view-size view))
(margin 2)
(label-height 20)
(width (- (point-h size) (* 2 margin)))
(height (point-v size))
(views (view-subviews view))
(label (elt views 0))
(list (elt views 1)))
(set-view-size label width label-height)
(set-view-size list width (- height (* 3 margin) label-height))))
(defclass checkin-categories-dialog (dialog)
()
(:default-initargs :grow-icon-p t :view-size #@(400 270)))
(defmethod initialize-instance ((dialog checkin-categories-dialog) &rest rest
&key (window-show t))
(declare (dynamic-extent rest))
(apply #'call-next-method dialog :window-show nil rest)
(resize-subviews dialog)
(when window-show
(window-show dialog)))
(defmethod set-view-size ((dialog checkin-categories-dialog) h &optional v)
(call-next-method dialog h v)
(with-focused-view dialog
(rlet ((rect :rect :topLeft 0 :bottomRight 0))
(with-clip-rect rect
(resize-subviews dialog)))
(invalidate-view dialog t)))
(defun resize-subviews (dialog)
(let* ((size (view-size dialog))
(width (point-h size))
(height (point-v size))
(label-height 40)
(button-height 20)
(margin 4)
(lower-pane-height (+ margin label-height margin button-height margin)))
(labels ((empty-filelist (view)
(zerop (length (table-sequence (elt (view-subviews view) 1))))))
(let* ((views (remove-if-not #'(lambda (type) (eq type 'filelist-pane)) (view-subviews dialog)
:key #'type-of))
(filled (remove-if #'empty-filelist views))
(count (length filled)))
(map nil #'(lambda (view)
(when (empty-filelist view)
(set-view-position view -10000 0)))
views)
(unless (zerop count)
(let ((subwidth (truncate (- (point-h size) (* margin (1+ count))) count))
(left 0))
(map nil #'(lambda (view &aux (top (point-v (view-position view))))
(set-view-position view (incf left margin) top)
(set-view-size view subwidth (- height top lower-pane-height))
(incf left subwidth))
filled)))))
(let* ((message (view-named 'message dialog))
(button1 (view-named 'button1 dialog))
(button2 (view-named 'button2 dialog))
(button-width 60)
(button-top (- height margin button-height)))
(set-view-position message 2 (- height lower-pane-height (- margin)))
(set-view-size message (- width margin margin) label-height)
(set-view-position button1 0 button-top)
(set-view-position button2 0 button-top)