Unnamed Fossil Project

Check-in [2c644b7544]
Login

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

Overview
Comment:+ CONTEXT - stub for drawing methods + simple test of NCURSES library + initialization/termination NCURSES + starting/finishing drawing + changing cursor position + overriding 'display' for printing to a current position + some SCREEN constants (such as WIDTH, HEIGHT, RECT)
Timelines: family | ancestors | descendants | both | tui
Files: files | file ages | folders
SHA1:2c644b7544131b44e899f27bee1618c24ed3359d
User & Date: vasalvit 2011-11-07 07:21:06
Context
2011-11-08
04:50
+ POINT is wrapper aroung internal structure _POINT_ + using ASSERT for checking input parameters * make-point function can work with two parameters (X Y) and fourth (x: X y: Y) check-in: cfa2ad8a2f user: vasalvit tags: tui
2011-11-07
07:21
+ CONTEXT - stub for drawing methods + simple test of NCURSES library + initialization/termination NCURSES + starting/finishing drawing + changing cursor position + overriding 'display' for printing to a current position + some SCREEN constants (such as WIDTH, HEIGHT, RECT) check-in: 2c644b7544 user: vasalvit tags: tui
2011-11-03
19:50
+ POINT structure and tests + SIZE structure and tests + RECT structure and tests check-in: f16685f30e user: vasalvit tags: tui
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added sources/libraries/tui/context.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
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
;       SCREEN-RECT
;               Width and Height of the screen (r/o).
(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)]))

Added sources/libraries/tui/tests/context-tests.scm.



































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
;
;       CONTEXT-TESTS
;               Test for CONTEXT module.
;       CREATOR         vasalvit, 05.11.2011
(require-extension srfi-78)
(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)
)