aboutsummaryrefslogtreecommitdiff
path: root/scripts/kconfig/libcurses/scroll.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/libcurses/scroll.c')
-rw-r--r--scripts/kconfig/libcurses/scroll.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/scripts/kconfig/libcurses/scroll.c b/scripts/kconfig/libcurses/scroll.c
new file mode 100644
index 000000000..d2f3d1704
--- /dev/null
+++ b/scripts/kconfig/libcurses/scroll.c
@@ -0,0 +1,101 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7scroll
8------
9
10### Synopsis
11
12 int scroll(WINDOW *win);
13 int scrl(int n);
14 int wscrl(WINDOW *win, int n);
15
16### Description
17
18 scroll() causes the window to scroll up one line. This involves
19 moving the lines in the window data strcture.
20
21 With a positive n, scrl() and wscrl() scroll the window up n lines
22 (line i + n becomes i); otherwise they scroll the window down n
23 lines.
24
25 For these functions to work, scrolling must be enabled via
26 scrollok(). Note also that scrolling is not allowed if the supplied
27 window is a pad.
28
29### Return Value
30
31 All functions return OK on success and ERR on error.
32
33### Portability
34 X/Open ncurses NetBSD
35 scroll Y Y Y
36 scrl Y Y Y
37 wscrl Y Y Y
38
39**man-end****************************************************************/
40
41int wscrl(WINDOW *win, int n)
42{
43 int i, l, dir, start, end;
44 chtype blank, *temp;
45
46 /* Check if window scrolls. Valid for window AND pad */
47
48 if (!win || !win->_scroll || !n)
49 return ERR;
50
51 blank = win->_bkgd;
52
53 if (n > 0)
54 {
55 start = win->_tmarg;
56 end = win->_bmarg;
57 dir = 1;
58 }
59 else
60 {
61 start = win->_bmarg;
62 end = win->_tmarg;
63 dir = -1;
64 }
65
66 for (l = 0; l < (n * dir); l++)
67 {
68 temp = win->_y[start];
69
70 /* re-arrange line pointers */
71
72 for (i = start; i != end; i += dir)
73 win->_y[i] = win->_y[i + dir];
74
75 win->_y[end] = temp;
76
77 /* make a blank line */
78
79 for (i = 0; i < win->_maxx; i++)
80 *temp++ = blank;
81 }
82
83 touchline(win, win->_tmarg, win->_bmarg - win->_tmarg + 1);
84
85 PDC_sync(win);
86 return OK;
87}
88
89int scrl(int n)
90{
91 PDC_LOG(("scrl() - called\n"));
92
93 return wscrl(stdscr, n);
94}
95
96int scroll(WINDOW *win)
97{
98 PDC_LOG(("scroll() - called\n"));
99
100 return wscrl(win, 1);
101}