pdcurses/scroll.c

changeset 97
2d43f05b284c
equal deleted inserted replaced
96:5314ebdcb38d 97:2d43f05b284c
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: scroll.c,v 1.36 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: scroll
10
11 Synopsis:
12 int scroll(WINDOW *win);
13 int scrl(int n);
14 int wscrl(WINDOW *win, int n);
15
16 Description:
17 scroll() causes the window to scroll up one line. This involves
18 moving the lines in the window data strcture.
19
20 With a positive n, scrl() and wscrl() scroll the window up n
21 lines (line i + n becomes i); otherwise they scroll the window
22 down n lines.
23
24 For these functions to work, scrolling must be enabled via
25 scrollok(). Note also that scrolling is not allowed if the
26 supplied window is a pad.
27
28 Return Value:
29 All functions return OK on success and ERR on error.
30
31 Portability X/Open BSD SYS V
32 scroll Y Y Y
33 scrl Y - 4.0
34 wscrl Y - 4.0
35
36 **man-end****************************************************************/
37
38 int wscrl(WINDOW *win, int n)
39 {
40 int i, l, dir, start, end;
41 chtype blank, *temp;
42
43 /* Check if window scrolls. Valid for window AND pad */
44
45 if (!win || !win->_scroll || !n)
46 return ERR;
47
48 blank = win->_bkgd;
49
50 if (n > 0)
51 {
52 start = win->_tmarg;
53 end = win->_bmarg;
54 dir = 1;
55 }
56 else
57 {
58 start = win->_bmarg;
59 end = win->_tmarg;
60 dir = -1;
61 }
62
63 for (l = 0; l < (n * dir); l++)
64 {
65 temp = win->_y[start];
66
67 /* re-arrange line pointers */
68
69 for (i = start; i != end; i += dir)
70 win->_y[i] = win->_y[i + dir];
71
72 win->_y[end] = temp;
73
74 /* make a blank line */
75
76 for (i = 0; i < win->_maxx; i++)
77 *temp++ = blank;
78 }
79
80 touchline(win, win->_tmarg, win->_bmarg - win->_tmarg + 1);
81
82 PDC_sync(win);
83 return OK;
84 }
85
86 int scrl(int n)
87 {
88 PDC_LOG(("scrl() - called\n"));
89
90 return wscrl(stdscr, n);
91 }
92
93 int scroll(WINDOW *win)
94 {
95 PDC_LOG(("scroll() - called\n"));
96
97 return wscrl(win, 1);
98 }

mercurial