cfad47cfa3/t3compiler/tads3/test/data/banner_api.t

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
#include <tads.h>
2
3
main(args)
4
{
5
    local win;
6
    local stat;
7
    local lineNum;
8
    
9
    "Left-banner test.  The idea here is to see how flashy the left banner
10
    is as we resize it repeatedly.\b";
11
12
    stat = bannerCreate(nil, BannerLast, nil, BannerTypeText,
13
                        BannerAlignTop, nil, nil, 0);
14
    bannerSay(stat, '<body bgcolor=teal text=white>');
15
    bannerSay(stat, 'Current line number = 0');
16
    bannerSizeToContents(stat);
17
18
    win = bannerCreate(nil, BannerLast, nil, BannerTypeText,
19
                       BannerAlignLeft, nil, nil, 0);
20
    bannerSay(win, '<body bgcolor=silver text=black>');
21
    bannerSay(win, 'one two three four five six seven eight nine ten\n');
22
    bannerSizeToContents(win);
23
24
    for (lineNum = 1 ;; ++lineNum)
25
    {
26
        local txt;
27
        
28
        "Enter some text to write to the banner; start the line with '+'
29
        to add it to the existing contents of the banner.  Start the
30
        line with '@' to switch to a right-side banner.  Type CLS to
31
        simply clear the main text window.  Enter an empty
32
        line to quit.\n&gt; ";
33
34
        "<font face='tads-input'>";
35
        txt = inputLine();
36
        "</font>";
37
38
        if (txt == nil || txt == '')
39
            break;
40
41
        if (txt.toLower() == 'cls')
42
        {
43
            clearScreen();
44
        }
45
        else if (txt.substr(1, 1) == '+')
46
        {
47
            bannerSay(win, txt.substr(2));
48
        }
49
        else if (txt.substr(1, 1) == '@')
50
        {
51
            bannerDelete(win);
52
            win = bannerCreate(nil, BannerLast, nil, BannerTypeText,
53
                               BannerAlignRight, nil, nil, 0);
54
            bannerSay(win, '<body bgcolor=olive text=white>');
55
            bannerSay(win, txt.substr(2));
56
        }
57
        else
58
        {
59
            bannerDelete(win);
60
            win = bannerCreate(nil, BannerLast, nil, BannerTypeText,
61
                               BannerAlignLeft, nil, nil, 0);
62
            bannerSay(win, '<body bgcolor=silver text=black>');
63
            bannerSay(win, txt);
64
        }
65
        bannerSay(win, '\n');
66
        bannerSizeToContents(win);
67
68
        bannerClear(stat);
69
        bannerSay(stat, '<body bgcolor=teal text=white>');
70
        bannerSay(stat, 'Current line number = ' + lineNum);
71
    }
72
}