File: t.c

package info (click to toggle)
xconq 7.2.2-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 8,296 kB
  • ctags: 9,199
  • sloc: ansic: 107,849; sh: 2,108; perl: 2,057; makefile: 1,177; sed: 161; csh: 50; awk: 49; lisp: 39
file content (264 lines) | stat: -rw-r--r-- 5,984 bytes parent folder | download | duplicates (3)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
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
258
259
260
261
262
263
264
#include "curses.h"

char	rule[] = "----.----";

#ifdef __AUX__
#define wechochar(w, c) (waddch((w),(c)),wrefresh((w)))
#endif

#define	ABORT(s)	{ fputs(s,stderr); abort(); }

static char *pad_init1 = "xxxxxxxxxxYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY********************";
static char *pad_init2 = "xxxxxxxxxxZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ********************";
static char *pad_init3 = "****************************************************************************************************";

main()
{
    int i, j;
    WINDOW *win1 = NULL;
    WINDOW *win2 = NULL;
    WINDOW *pad = NULL;

    /*
     * Test isendwin(), initscr(), and refresh():
     */

/* #ifndef __AUX__ (* isendwin doesn't seem to be false b4 initialization on sun *)
 *    if (!isendwin())
 *	ABORT("isendwin() is false (s/b true)\n");
 *#endif
*/
    initscr();
    refresh();
    noecho();
    crmode();

#ifndef __AUX__
    if (isendwin()) 
	ABORT("isendwin() is true (s/b false)\n");
#endif

    /*
     * Test printw():
     */

    for (i = 0, j = 2 * COLS / 10; i < j; i++)
		printw("%s%d", rule, i%10);

	refresh();
    getch();		/* getch() does an implicit refresh() */

    /*
     * Create a window and test wrefresh()
     */

    win1 = newwin(10,10,10,10);

    mvaddstr(4,0,"This should not be printed");
    wprintw(win1, "1234567890nextline");
    wrefresh(win1);	/* only refresh win1 */
    wgetch(win1);

    mvaddstr(4,0,"The 123456... message should disappear");
    clearok(stdscr, TRUE);
    refresh();			/* overlay stdscr over window */
    getch();

	pad = newpad(LINES + LINES/3, 100);
	for (i = 0; i < LINES/3; i++)
		mvwaddstr(pad, i, 0, pad_init1);

	for (i = LINES/3; i < LINES; i++)
		mvwaddstr(pad, i, 0, pad_init2);

	for (i = LINES; i < LINES + LINES/3; i++)
		mvwaddstr(pad, i, 0, pad_init3);

	wmove(pad, 0, 0);
	prefresh(pad, 0, 0, 0, 0, LINES, COLS);
	wgetch(pad);

	prefresh(pad, LINES/8, 10, 0, 0, LINES, COLS);
	wgetch(pad);

    /*
     * Test line drawing characters:
     */

#if !defined(THINK_C) && !defined(__AUX__)
    wclear(win1);
    wmove(win1,0,0);
    mvwaddch(win1,0,0,ACS_ULCORNER);
    waddch(win1,ACS_HLINE);
    waddch(win1,ACS_TTEE);
    waddch(win1,ACS_HLINE);
    waddch(win1,ACS_URCORNER);
    mvwaddch(win1,1,0,ACS_VLINE);
    waddch(win1,' ');
    waddch(win1,ACS_VLINE);
    waddch(win1,' ');
    waddch(win1,ACS_VLINE);
    mvwaddch(win1,2,0,ACS_LTEE);
    waddch(win1,ACS_HLINE);
    waddch(win1,ACS_PLUS);
    waddch(win1,ACS_HLINE);
    waddch(win1,ACS_RTEE);
    mvwaddch(win1,3,0,ACS_VLINE);
    waddch(win1,' ');
    waddch(win1,ACS_VLINE);
    waddch(win1,' ');
    waddch(win1,ACS_VLINE);
    mvwaddch(win1,4,0,ACS_LLCORNER);
    waddch(win1,ACS_HLINE);
    waddch(win1,ACS_BTEE);
    waddch(win1,ACS_HLINE);
    waddch(win1,ACS_LRCORNER);
    wrefresh(win1);
    wgetch(win1);
#endif

    /*
     * Make 2 boxed windows and display both at the same time:
     */

    wclear(win1);
    box(win1,0,0);
    wnoutrefresh(win1);		/* Update internal but not screen */
    sleep(1);			/* Make the delay noticeable */

    win2 = newwin(10,10,10,40);
    box(win2,'|','-');		/* Cheap box */
    wnoutrefresh(win2);		/* Update second window */
    sleep(1);

    doupdate();			/* Now update both at once */
    getch();

    mvwin(win2,10,30);		/* Move window 2	*/
    touchwin(win1);		/* Reshow window 1	*/
    touchwin(stdscr);		/* Reshow window 1	*/
    wnoutrefresh(stdscr);	/* Update stdscr	*/
    wnoutrefresh(win1);		/* Update window 1	*/
    wnoutrefresh(win2);		/* Update window 2	*/
    doupdate();			/* And display new screen	*/
    getch();

    wmove(win2,3,3);
    wechochar(win2,'*');
    getch();

#ifdef __AUX__
	overwrite(pad, win1);
#else
	copywin(pad, win1, LINES/6, 5, 1, 1, 9, 9, FALSE);
#endif /* __AUX__ */
	wrefresh(win1);
	getch();

    endwin();
#ifndef __AUX__
    if (!isendwin())
	ABORT("isendwin() is true (s/b false)\n");
#endif

    clear();
    delwin(win2);
    win2 = newwin(8,8,11,11);		/* win2 is now inside win1 */
    touchwin(win1);
    move(0,0);
    standout();
    addstr("STANDOUT ");
    standend();
    addstr("STANDEND ");
    attrset(A_UNDERLINE);
    addstr("UNDERLINE ");
    attrset(A_REVERSE);
    addstr("REVERSE ");
    attrset(A_BLINK);
    addstr("BLINK ");
    attrset(A_BOLD);
    addstr("BOLD ");
    attrset(A_DIM);
    addstr("DIM ");
    attrset(A_NORMAL);
    addch('\n');

    attron(A_REVERSE);
    addstr("REVERSE ");
    attron(A_BOLD);
    addstr("BOLD ");
    attron(A_DIM);
    addstr("DIM ");
    attron(A_UNDERLINE);
    addstr("UNDERLINE ");
    attron(A_BLINK);
    addstr("BLINK ");
    attron(A_NORMAL);
    addch('\n');

    attroff(A_REVERSE);
    addstr("REVERSE ");
    attroff(A_BOLD);
    addstr("BOLD ");
    attroff(A_DIM);
    addstr("DIM ");
    attroff(A_UNDERLINE);
    addstr("UNDERLINE ");
    attroff(A_BLINK);
    addstr("BLINK ");
    attroff(A_NORMAL);
    addch('\n');
    beep();
    refresh();
    getch();

    clear();
    for (i = 0; i < LINES; i++) {
		move(i,0);
		printw("The quick brown fox jumps over the lazy dog %d times", i);
    }
    attrset(A_BOLD);
    mvaddstr(4,5,"clrtoeol():");
    clrtoeol();
    mvaddstr(6,5,"delch():");
    delch();
    mvaddstr(8,5,"deleteln() below:");
    move(9,5);
    deleteln();
    mvaddstr(12,6,"insch():");
    insch('X');
    mvaddstr(20,5,"clrtobot():");
    clrtobot();
    refresh();
    getch();

    mvaddstr(14,5,"insertln():");
    insertln();
    refresh();
    getch();

    attrset(A_NORMAL);
    clear();
    scrollok(stdscr, TRUE);
    for (i = 0; i < LINES; i++) {
		move(i,0);
		printw("The quick brown fox jumps over the lazy dog %d times", i);
    }
    refresh();
    getch();
    scroll(stdscr);
    refresh();
    getch();
    scroll(stdscr);
    refresh();
    getch();

    endwin();
#ifndef __AUX__
    if (!isendwin())
	ABORT("isendwin() returned false, should be true!\n");
#endif

    exit(0);
}