diff options
Diffstat (limited to 'scripts/kconfig/libcurses/scroll.c')
| -rw-r--r-- | scripts/kconfig/libcurses/scroll.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/scripts/kconfig/libcurses/scroll.c b/scripts/kconfig/libcurses/scroll.c new file mode 100644 index 000000000..a53d71bad --- /dev/null +++ b/scripts/kconfig/libcurses/scroll.c | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | /* PDCurses */ | ||
| 2 | |||
| 3 | #include "curspriv.h" | ||
| 4 | |||
| 5 | /*man-start************************************************************** | ||
| 6 | |||
| 7 | scroll | ||
| 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 | |||
| 35 | Function | X/Open | ncurses | NetBSD | ||
| 36 | :---------------------|:------:|:-------:|:------: | ||
| 37 | scroll | Y | Y | Y | ||
| 38 | scrl | Y | Y | Y | ||
| 39 | wscrl | Y | Y | Y | ||
| 40 | |||
| 41 | **man-end****************************************************************/ | ||
| 42 | |||
| 43 | int wscrl(WINDOW *win, int n) | ||
| 44 | { | ||
| 45 | int i, l, dir, start, end; | ||
| 46 | chtype blank, *temp; | ||
| 47 | |||
| 48 | /* Check if window scrolls. Valid for window AND pad */ | ||
| 49 | |||
| 50 | if (!win || !win->_scroll || !n) | ||
| 51 | return ERR; | ||
| 52 | |||
| 53 | blank = win->_bkgd; | ||
| 54 | |||
| 55 | if (n > 0) | ||
| 56 | { | ||
| 57 | start = win->_tmarg; | ||
| 58 | end = win->_bmarg; | ||
| 59 | dir = 1; | ||
| 60 | } | ||
| 61 | else | ||
| 62 | { | ||
| 63 | start = win->_bmarg; | ||
| 64 | end = win->_tmarg; | ||
| 65 | dir = -1; | ||
| 66 | } | ||
| 67 | |||
| 68 | for (l = 0; l < (n * dir); l++) | ||
| 69 | { | ||
| 70 | temp = win->_y[start]; | ||
| 71 | |||
| 72 | /* re-arrange line pointers */ | ||
| 73 | |||
| 74 | for (i = start; i != end; i += dir) | ||
| 75 | win->_y[i] = win->_y[i + dir]; | ||
| 76 | |||
| 77 | win->_y[end] = temp; | ||
| 78 | |||
| 79 | /* make a blank line */ | ||
| 80 | |||
| 81 | for (i = 0; i < win->_maxx; i++) | ||
| 82 | *temp++ = blank; | ||
| 83 | } | ||
| 84 | |||
| 85 | touchline(win, win->_tmarg, win->_bmarg - win->_tmarg + 1); | ||
| 86 | |||
| 87 | PDC_sync(win); | ||
| 88 | return OK; | ||
| 89 | } | ||
| 90 | |||
| 91 | int scrl(int n) | ||
| 92 | { | ||
| 93 | PDC_LOG(("scrl() - called\n")); | ||
| 94 | |||
| 95 | return wscrl(stdscr, n); | ||
| 96 | } | ||
| 97 | |||
| 98 | int scroll(WINDOW *win) | ||
| 99 | { | ||
| 100 | PDC_LOG(("scroll() - called\n")); | ||
| 101 | |||
| 102 | return wscrl(win, 1); | ||
| 103 | } | ||
