Unnamed Fossil Project

Check-in [61487324aa]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:$ bug fixing + SCREEN-READY function (for verifiing initialization) + ASSERTs within SCREEN and CONTEXT functions * GOTOXY renamed to CURSOR-MOVE
Timelines: family | ancestors | descendants | both | tui
Files: files | file ages | folders
SHA1:61487324aa55406439eb6ea1bba87183b1697d1d
User & Date: vasalvit 2011-11-08 18:27:30
Context
2011-11-11
02:54
+ new module THREADS for working with threads + THREAD-INIT and THREAD-DONE for initializing/terminating library + MAIN-SEND and MAIN-LOOP for sending/receiving messages + EXECUTE-ON-MAIN for executing method on MAIN thread + EXECUTE-IN-BACKGROUND for executing method in a new BACKGROUND thread Leaf check-in: 91b76b986d user: vasalvit tags: tui
2011-11-08
18:27
$ bug fixing + SCREEN-READY function (for verifiing initialization) + ASSERTs within SCREEN and CONTEXT functions * GOTOXY renamed to CURSOR-MOVE check-in: 61487324aa user: vasalvit tags: tui
15:56
* RECT is wrapper around internal structure _RECT_ + using ASSERT for checking input parameters at *RECT* methods * make-rect function can receives two (ORIGIN SIZE) and fourth (origin: ORIGIN size: SIZE) parameters check-in: 9c8d6683b7 user: vasalvit tags: tui
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to sources/libraries/tui/context.scm.

1
2
3
4






5
6
7
8
9
10
11
..
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
;
;       CONTEXT
;               Contains methods for drawing information on a screen.
;       CREATOR         vasavit, 05.11.2011






(require-extension defstruct)
(require-extension ncurses)
(require-extension ports)
(load "primitives.scm")

;       SCREEN-WIDTH
;       SCREEN-HEIGHT
................................................................................
(define _screen-width_ #f)
(define _screen-height_ #f)
(define _screen-rect_ #f)
(define (screen-width) _screen-width_)
(define (screen-height) _screen-height_)
(define (screen-rect) _screen-rect_)








;       SCREEN-INIT
;       SCREEN-TERM
;               Initialization and termination the screen.
(define _screen_ #f)
(define (screen-init)

        (initscr)
        (cbreak)
        (nonl)
        (noecho)
        (set! _screen_ (stdscr))
        (set! _screen-width_ (COLS))
        (set! _screen-height_ (LINES))
................................................................................
        (set! _screen-rect_
                (make-rect
                        origin: (make-point 0 0)
                        size:   (make-size (screen-width) (screen-height))))
        (graph-begin)
        (graph-finish))
(define (screen-term)

        (nl)
        (nocbreak)
        (endwin)
        (set! _screen_ #f)
        (set! _screen-width_ #f)
        (set! _screen-height_ #f)
        (set! _screen-rect_ empty-rect))

;       GRAPH-BEGIN
;       GRAPH-FINISH
;               Start/stop drawing process.
(define (graph-begin)

        (wclear _screen_))
(define (graph-finish)

        (wrefresh _screen_))

;       GOTOXY
;               Move cursor to specified position.
(define (gotoxy pos)

        (wmove _screen_ (point-y pos) (point-x pos)))

;       DISPLAY
;               Overrided function for printing value to a display.
(define _display_ display)
(define display
        (case-lambda
                [(value)
                        (cond
                                [(not _screen_)
                                        (_display_ value)]
                                [else
                                        (wprintw _screen_
                                                (call-with-output-string
                                                        (lambda (port) (_display_ value port))))]
                )]
                [(value port)
                        (_display_ value port)]))




|
>
>
>
>
>
>







 







>
>
>
>
>
>
>





>







 







>












>


>


|

|
>









|









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
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
;
;       CONTEXT
;               Contains methods for drawing information on a screen.
;       HISTORY
;               05.11.2011              vasalvit
;                       First version.
;               08.11.2011              vasalvit
;                       Added method SCREEN-READY for checking initialization.
;                       Using ASSERTs for verifying parameters.
;                       GOTOXY renamed to CURSOR-MOVE.
(require-extension defstruct)
(require-extension ncurses)
(require-extension ports)
(load "primitives.scm")

;       SCREEN-WIDTH
;       SCREEN-HEIGHT
................................................................................
(define _screen-width_ #f)
(define _screen-height_ #f)
(define _screen-rect_ #f)
(define (screen-width) _screen-width_)
(define (screen-height) _screen-height_)
(define (screen-rect) _screen-rect_)

;       SCREEN-READY
;               Returns TRUE if library initialized.
(define (screen-ready)
        (not (eq? _screen_ #f)))
(define (screen-verify)
        (assert (screen-ready) "Library not initialized"))

;       SCREEN-INIT
;       SCREEN-TERM
;               Initialization and termination the screen.
(define _screen_ #f)
(define (screen-init)
        (assert (not (screen-ready)) "Screen already initialized")
        (initscr)
        (cbreak)
        (nonl)
        (noecho)
        (set! _screen_ (stdscr))
        (set! _screen-width_ (COLS))
        (set! _screen-height_ (LINES))
................................................................................
        (set! _screen-rect_
                (make-rect
                        origin: (make-point 0 0)
                        size:   (make-size (screen-width) (screen-height))))
        (graph-begin)
        (graph-finish))
(define (screen-term)
        (screen-verify)
        (nl)
        (nocbreak)
        (endwin)
        (set! _screen_ #f)
        (set! _screen-width_ #f)
        (set! _screen-height_ #f)
        (set! _screen-rect_ empty-rect))

;       GRAPH-BEGIN
;       GRAPH-FINISH
;               Start/stop drawing process.
(define (graph-begin)
        (screen-verify)
        (wclear _screen_))
(define (graph-finish)
        (screen-verify)
        (wrefresh _screen_))

;       CURSOR-MOVE
;               Move cursor to specified position.
(define (cursor-move pos)
        (screen-verify)
        (wmove _screen_ (point-y pos) (point-x pos)))

;       DISPLAY
;               Overrided function for printing value to a display.
(define _display_ display)
(define display
        (case-lambda
                [(value)
                        (cond
                                [(not (screen-ready))
                                        (_display_ value)]
                                [else
                                        (wprintw _screen_
                                                (call-with-output-string
                                                        (lambda (port) (_display_ value port))))]
                )]
                [(value port)
                        (_display_ value port)]))

Changes to sources/libraries/tui/primitives.scm.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(define (mkpoint x y)
        (assert (number? x))
        (assert (number? y))
        (make-_point_ x: x y: y))
(define point
        (case-lambda
                [(x y)
                        (mkpoint x: x y: y)]
                [(a b c d)
                        (assert (or
                                (and (eq? a 'x:) (eq? c 'y:))
                                (and (eq? a 'y:) (eq? c 'x:))))
                        (cond
                                [(eq? a 'x:) (mkpoint b d)]
                                [else        (mkpoint d b)])]))







|







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(define (mkpoint x y)
        (assert (number? x))
        (assert (number? y))
        (make-_point_ x: x y: y))
(define point
        (case-lambda
                [(x y)
                        (mkpoint x y)]
                [(a b c d)
                        (assert (or
                                (and (eq? a 'x:) (eq? c 'y:))
                                (and (eq? a 'y:) (eq? c 'x:))))
                        (cond
                                [(eq? a 'x:) (mkpoint b d)]
                                [else        (mkpoint d b)])]))

Changes to sources/libraries/tui/tests/context-tests.scm.

6
7
8
9
10
11
12
13
14
15
16
17
(load "context.scm")

; Testing screen initialization
(let* ()
                (display "SCREEN") (newline)
                (screen-init)
                (graph-begin)
                (gotoxy (make-point x: 8 y: 2)) (display "width=")  (display (screen-width))
                (gotoxy (make-point x: 8 y: 3)) (display "height=") (display (screen-height))
                (graph-finish)
                (screen-term)
)







|
|



6
7
8
9
10
11
12
13
14
15
16
17
(load "context.scm")

; Testing screen initialization
(let* ()
                (display "SCREEN") (newline)
                (screen-init)
                (graph-begin)
                (cursor-move (make-point x: 8 y: 2)) (display "width=")  (display (screen-width))
                (cursor-move (make-point x: 8 y: 3)) (display "height=") (display (screen-height))
                (graph-finish)
                (screen-term)
)