-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpresentation.lisp
108 lines (93 loc) · 4.73 KB
/
presentation.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
(in-package :clim-gopher)
;;; Presentation Code
(defclass main-table-view (textual-view) ())
(defun display-type (line stream)
(let ((icon (icon-for (cl-gopher:line-type line))))
(if icon
(with-room-for-graphics (stream :first-quadrant nil)
(draw-design stream icon))
(format stream "~a" (string-downcase (cl-gopher:line-type line))))))
(define-presentation-type gopher-line () :inherit-from '((string)
:description "gopher line"))
(define-presentation-method present (gopher-line (type gopher-line) stream
(view textual-view)
&key acceptably)
(declare (ignore acceptably))
(format stream "~a[~a]"
(cl-gopher:display-string gopher-line)
(cl-gopher:uri-for-gopher-line gopher-line)))
(define-presentation-type clickable-gopher-line () :inherit-from '((gopher-line)
:description "gopher line"))
(define-presentation-type viewable-gopher-line () :inherit-from '((clickable-gopher-line)
:description "viewable gopher line"))
(define-presentation-method present (viewable-gopher-line (type viewable-gopher-line) stream
(view main-table-view)
&key acceptably)
(declare (ignore acceptably))
(formatting-cell (stream :align-x :left)
(display-type viewable-gopher-line stream))
(formatting-cell (stream :align-x :left)
(format stream "~a" (cl-gopher:display-string viewable-gopher-line)))
(with-application-frame (frame)
(when (show-uri frame)
(formatting-cell (stream :align-x :left)
(format stream "~a" (cl-gopher:uri-for-gopher-line viewable-gopher-line))))))
(define-presentation-type search () :inherit-from '((clickable-gopher-line)
:description "search"))
(define-presentation-method present (search (type search) stream
(view main-table-view)
&key acceptably)
(declare (ignore acceptably))
(formatting-cell (stream :align-x :left)
(display-type search stream))
(formatting-cell (stream :align-x :left)
(format stream "~a" (cl-gopher:display-string search)))
(with-application-frame (frame)
(when (show-uri frame)
(formatting-cell (stream :align-x :left)
(format stream "~a~c~a"
(cl-gopher:uri-for-gopher-line search)
#\Tab
(cl-gopher:terms search))))))
(define-presentation-type info () :inherit-from '((gopher-line)
:description "info"))
(define-presentation-method present (info (type info) stream
(view main-table-view)
&key acceptably)
(declare (ignore acceptably))
(formatting-cell (stream :align-x :left)
(format stream ""))
(formatting-cell (stream :align-x :left)
(format stream "~a" (cl-gopher:display-string info)))
(with-application-frame (frame)
(when (show-uri frame)
(formatting-cell (stream :align-x :left)
(format stream "")))))
(define-presentation-type html-file () :inherit-from '((clickable-gopher-line)
:description "html-file"))
(define-presentation-method present (html-file (type html-file) stream
(view main-table-view)
&key acceptably)
(declare (ignore acceptably))
(formatting-cell (stream :align-x :left)
(display-type html-file stream))
(formatting-cell (stream :align-x :left)
(format stream "~a" (cl-gopher:display-string html-file)))
(with-application-frame (frame)
(when (show-uri frame)
(formatting-cell (stream :align-x :left)
(format stream "~a" (cl-gopher:selector html-file))))))
(define-presentation-type unknown () :inherit-from '((gopher-line)
:description "unknown"))
(define-presentation-method present (unknown (type unknown) stream
(view main-table-view)
&key acceptably)
(declare (ignore acceptably))
(formatting-cell (stream :align-x :left)
(display-type unknown stream))
(formatting-cell (stream :align-x :left)
(format stream "~a" (cl-gopher:display-string unknown)))
(with-application-frame (frame)
(when (show-uri frame)
(formatting-cell (stream :align-x :left)
(format stream "")))))