-
Notifications
You must be signed in to change notification settings - Fork 1
/
schemep3-frame-console.scm
56 lines (42 loc) · 1.42 KB
/
schemep3-frame-console.scm
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
#lang scheme/gui
;;;(provide console-frame)
(provide console:printf)
(require "schemep3-helpers.scm")
(require "schemep3-main-menu.scm")
(define console%
(class frame%
(super-new
(parent #f)
(width 720)
(height 300)
(label "Console"))
(define _canvas
(new editor-canvas%
(parent this)
(editor (new text%))))
(define _menu-items (list))
(let ([console-menu-item
(make-main-menu-checkable-item
"Console"
(lambda (show?)
(send this show show?))
#f
(lambda (menu-item)
(push! _menu-items menu-item)))])
(main-menu:add main-menu:group:view console-menu-item))
(define/augment (on-close)
(inner (void) on-close)
(for ((m _menu-items))
(send m check #f)))
(define insert-semaphore (make-semaphore 1))
;;;(current-output-port (open-output-text-editor _text-editor))
(define/public (thread-safe-insert . p)
(call-with-semaphore
insert-semaphore
(lambda () (send (send _canvas get-editor) insert . p))))
(define/public (print string)
(thread-safe-insert string))))
(define-singleton console-frame console%)
(define (console:printf . p)
(let ([string (apply format p)])
(send (console-frame) print string)))