soc/intel/xeon_sp/util: Enhance lock_pam0123
[coreboot2.git] / payloads / libpayload / curses / PDCurses / pdcurses / scroll.c
blobbc6c082e37724af630b15277400c80d01cbfe6bf
1 /* Public Domain Curses */
3 #include <curspriv.h>
5 RCSID("$Id: scroll.c,v 1.36 2008/07/13 16:08:18 wmcbrine Exp $")
7 /*man-start**************************************************************
9 Name: scroll
11 Synopsis:
12 int scroll(WINDOW *win);
13 int scrl(int n);
14 int wscrl(WINDOW *win, int n);
16 Description:
17 scroll() causes the window to scroll up one line. This involves
18 moving the lines in the window data strcture.
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.
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.
28 Return Value:
29 All functions return OK on success and ERR on error.
31 Portability X/Open BSD SYS V
32 scroll Y Y Y
33 scrl Y - 4.0
34 wscrl Y - 4.0
36 **man-end****************************************************************/
38 int wscrl(WINDOW *win, int n)
40 int i, l, dir, start, end;
41 chtype blank, *temp;
43 /* Check if window scrolls. Valid for window AND pad */
45 if (!win || !win->_scroll || !n)
46 return ERR;
48 blank = win->_bkgd;
50 if (n > 0)
52 start = win->_tmarg;
53 end = win->_bmarg;
54 dir = 1;
56 else
58 start = win->_bmarg;
59 end = win->_tmarg;
60 dir = -1;
63 for (l = 0; l < (n * dir); l++)
65 temp = win->_y[start];
67 /* re-arrange line pointers */
69 for (i = start; i != end; i += dir)
70 win->_y[i] = win->_y[i + dir];
72 win->_y[end] = temp;
74 /* make a blank line */
76 for (i = 0; i < win->_maxx; i++)
77 *temp++ = blank;
80 touchline(win, win->_tmarg, win->_bmarg - win->_tmarg + 1);
82 PDC_sync(win);
83 return OK;
86 int scrl(int n)
88 PDC_LOG(("scrl() - called\n"));
90 return wscrl(stdscr, n);
93 int scroll(WINDOW *win)
95 PDC_LOG(("scroll() - called\n"));
97 return wscrl(win, 1);