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
|
#include <ncurses.h>
#define ROWS 20
#define scroll_window wscrl
main()
{
int i;
WINDOW * w;
initscr();
cbreak();
noecho();
w = newwin (ROWS, 35, 2, 25);
scrollok(w, TRUE);
wsetscrreg(w, 0, ROWS-1);
#ifdef LELE
mvaddstr (0, 0, "With my function");
#else
mvaddstr (0, 0, "With the original wscrl");
#endif
refresh();
for (i=0; i<ROWS-1; i++)
{
mvwprintw (w, i, 0, "Line number %d", i);
}
mvwaddstr (w, ROWS-1, 0, "Moving one line at a time");
wrefresh(w);
for (i = 0; i < 4; i++) {
getch();
scroll_window (w, 1);
wrefresh(w);
}
for (i = 0; i < 4; i++) {
getch();
scroll_window (w, -1);
wrefresh(w);
}
getch();
wclear (w);
for (i=0; i<ROWS-1; i++)
{
mvwprintw (w, i, 0, "Line number %d", i);
}
mvwaddstr (w, ROWS-1, 0, "Moving two line at a time");
#ifndef LELE
mvaddstr (0, 30, "** THIS FAILS ON MY MACHINE WITH A BUS ERROR
**");
#endif
wrefresh(w);
for (i = 0; i < 4; i++) {
getch();
scroll_window (w, 2);
wrefresh(w);
}
for (i = 0; i < 4; i++) {
getch();
scroll_window (w, -2);
wrefresh(w);
}
getch();
wclear (w);
for (i=0; i<ROWS-1; i++)
{
mvwprintw (w, i, 0, "Line number %d", i);
}
mvwaddstr (w, ROWS-1, 0, "Moving three line at a time");
wrefresh(w);
for (i = 0; i < 4; i++) {
getch();
scroll_window (w, 3);
wrefresh(w);
}
for (i = 0; i < 4; i++) {
getch();
scroll_window (w, -3);
wrefresh(w);
}
getch();
endwin();
}
|