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
|
;;======================================================================
;; (declare (uses common))
;; (declare (uses megatest-version))
(declare (uses mtargs))
(declare (uses treemod))
(use srfi-1 posix regex regex-case srfi-69 typed-records sparse-vectors)
(use format
(prefix iup iup:)
canvas-draw)
(import canvas-draw-iup)
;; (debug:setup)
(module ndboard
*
(import scheme
chicken
data-structures
format
(prefix iup iup:)
canvas-draw
canvas-draw-iup
matchable
srfi-1 posix regex regex-case
srfi-69 typed-records sparse-vectors ;; defstruct
|
>
|
|
>
>
<
>
|
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
|
;;======================================================================
;; (declare (uses common))
;; (declare (uses megatest-version))
(declare (uses mtargs))
(declare (uses treemod))
(use srfi-1
posix regex regex-case srfi-69 typed-records sparse-vectors
format
extras
(prefix iup iup:)
canvas-draw)
(import canvas-draw-iup)
(module ndboard
*
(import scheme
chicken
data-structures
extras
format
(prefix iup iup:)
canvas-draw
canvas-draw-iup
matchable
srfi-1 posix regex regex-case
srfi-69 typed-records sparse-vectors ;; defstruct
|
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
|
;; areas
;;
(define *areas* (make-hash-table))
(defstruct area
path
)
(define (get-areas-file)
(conc (get-environment-variable "HOME")"/.ndboard/areas.scm"))
(define (get-areas)
(let* ((areas-file (get-areas-file)))
(if (file-exists? areas-file)
(with-input-from-file areas-file read))))
(define (register-area areadat)
(hash-table-set! *areas* (car areadat)
(make-area (cdr areadat))))
(define (get-area-info area-name)
(hash-table-ref/default *areas* area-name #f))
;; gui utils
;;
(define (message-window msg)
(iup:show
(iup:dialog
(iup:vbox
(iup:label msg #:margin "40x40")))))
(define (iuplistbox-fill-list lb items . default)
|
>
>
>
|
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
;; areas
;;
(define *areas* (make-hash-table))
(defstruct area
path
keys
targets
targets-update-time
)
(define (area-get-path area-name)
(let* ((adat (hash-table-ref/default *areas* area-name #f)))
(if adat
(area-path adat)
#f)))
(define (get-areas-file)
(conc (get-environment-variable "HOME")"/.ndboard/areas.scm"))
(define (get-areas)
(let* ((areas-file (get-areas-file)))
(if (file-exists? areas-file)
(with-input-from-file areas-file read))))
(define (register-area areadat)
(hash-table-set! *areas* (car areadat)
(make-area path: (cdr areadat))))
(define (get-area-info area-name)
(hash-table-ref/default *areas* area-name #f))
;; megatest calls, run in "area"
;;
;; TODO store the last time the query was run
;; and clear cache based on timestamp on main.db
;;
(define (megatest-get-targets area-name)
(let* ((ainfo (get-area-info area-name))
(targets (area-targets ainfo)))
(if targets
targets
(let* ((path (area-get-path area-name))
(raw-targs (with-input-from-pipe
(conc "megatest -list-targets -start-dir "path)
read-lines))
(clean-targs (filter (lambda (x)
(not (equal? x "default")))
raw-targs)))
(area-targets-set! ainfo clean-targs)
(area-targets-update-time-set! ainfo (current-seconds))
clean-targs))))
(define (megatest-get-keys area-name)
(let* ((ainfo (get-area-info area-name))
(keys (area-keys ainfo)))
(if keys
keys
(let* ((path (area-path ainfo))
(keysstrs (with-input-from-pipe
(conc "megatest -show-keys -start-dir "path)
read-lines)))
(if (null? keysstrs)
(print "Unknown error getting keys for area "area-name", path: "path)
(let* ((keystr (car keysstrs))
(keys (string-split keystr)))
(area-keys-set! ainfo keys)
keys))))))
;; gui utils
;;
(define (message-window msg)
(iup:show
(iup:dialog
(iup:vbox
(iup:label msg #:margin "40x40")))))
(define (iuplistbox-fill-list lb items . default)
|
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
#:expand "YES"
#:addexpanded "YES"
#:size "10x"
#:selection-cb
(lambda (obj id state)
(let* ((path (tree:node->path obj id)))
(match path
((treename)(print "nothing to do here"))
((treename area)
#f ;; read the megatest area targets and fill out the tree
))
(print "obj: "obj", id: "id", state: "state", path: "path)))))
(define (runs window-id)
(iup:hbox
(add-widget "main-tree" (main-tree))
;;
))
|
|
|
|
>
>
>
|
|
|
>
>
>
>
>
>
>
>
|
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
|
#:expand "YES"
#:addexpanded "YES"
#:size "10x"
#:selection-cb
(lambda (obj id state)
(let* ((path (tree:node->path obj id)))
(match path
((treename) #f) ;;(print "nothing to do here"))
((treename area)
(let ((tb (get-widget "main-tree")))
(refresh-targets tb area)))
((treename area . target)
(print "area: "area", target: "target))
(else
(print "path: "path))
)
#;(print "obj: "obj", id: "id", state: "state", path: "path)))))
(define (refresh-targets tb area)
(let* ((targets (megatest-get-targets area)))
(for-each
(lambda (target)
(let* ((t-path (string-split target "/")))
(tree:add-node tb "Areas" (cons area t-path))))
targets)))
(define (runs window-id)
(iup:hbox
(add-widget "main-tree" (main-tree))
;;
))
|