aboutsummaryrefslogtreecommitdiff
path: root/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scroll.c
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@secunet.com>2011-07-07 15:41:53 +0200
committerStefan Reinauer <stefan.reinauer@coreboot.org>2011-08-04 08:10:41 +0200
commit3b77b723ca209199c8a224702812441e2196d452 (patch)
treecbf3be2c724139ec80a33dbf8e002b7871ef9307 /payloads/libpayload/curses/PDCurses-3.4/pdcurses/scroll.c
parent1ac19e28eed4f6c53a4f295eb55500c65fc80f8d (diff)
libpayload: Add PDCurses and ncurses' libform/libmenu
PDCurses provides an alternative implementation of the curses library standard in addition to tinycurses. Where tinycurses is really tiny, PDCurses is more complete and provides virtually unlimited windows and the full API. The PDCurses code is brought in "vanilla", with all local changes residing in curses/pdcurses-backend/ In addition to a curses library, this change also provides libpanel (as part of the PDCurses code), and libform and libmenu which were derived from ncurses-5.9. As they rely on ncurses internals (and PDCurses is not ncurses), more changes were required for these libraries to work. The build system is extended to install the right set of header files depending on the selected curses implementation. Change-Id: I9e5b920f94b6510da01da2f656196a993170d1c5 Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Reviewed-on: http://review.coreboot.org/106 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones <marcj303@gmail.com>
Diffstat (limited to 'payloads/libpayload/curses/PDCurses-3.4/pdcurses/scroll.c')
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/scroll.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scroll.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scroll.c
new file mode 100644
index 0000000000..c53e295468
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scroll.c
@@ -0,0 +1,98 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: scroll.c,v 1.36 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: scroll
+
+ Synopsis:
+ int scroll(WINDOW *win);
+ int scrl(int n);
+ int wscrl(WINDOW *win, int n);
+
+ Description:
+ scroll() causes the window to scroll up one line. This involves
+ moving the lines in the window data strcture.
+
+ With a positive n, scrl() and wscrl() scroll the window up n
+ lines (line i + n becomes i); otherwise they scroll the window
+ down n lines.
+
+ For these functions to work, scrolling must be enabled via
+ scrollok(). Note also that scrolling is not allowed if the
+ supplied window is a pad.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ scroll Y Y Y
+ scrl Y - 4.0
+ wscrl Y - 4.0
+
+**man-end****************************************************************/
+
+int wscrl(WINDOW *win, int n)
+{
+ int i, l, dir, start, end;
+ chtype blank, *temp;
+
+ /* Check if window scrolls. Valid for window AND pad */
+
+ if (!win || !win->_scroll || !n)
+ return ERR;
+
+ blank = win->_bkgd;
+
+ if (n > 0)
+ {
+ start = win->_tmarg;
+ end = win->_bmarg;
+ dir = 1;
+ }
+ else
+ {
+ start = win->_bmarg;
+ end = win->_tmarg;
+ dir = -1;
+ }
+
+ for (l = 0; l < (n * dir); l++)
+ {
+ temp = win->_y[start];
+
+ /* re-arrange line pointers */
+
+ for (i = start; i != end; i += dir)
+ win->_y[i] = win->_y[i + dir];
+
+ win->_y[end] = temp;
+
+ /* make a blank line */
+
+ for (i = 0; i < win->_maxx; i++)
+ *temp++ = blank;
+ }
+
+ touchline(win, win->_tmarg, win->_bmarg - win->_tmarg + 1);
+
+ PDC_sync(win);
+ return OK;
+}
+
+int scrl(int n)
+{
+ PDC_LOG(("scrl() - called\n"));
+
+ return wscrl(stdscr, n);
+}
+
+int scroll(WINDOW *win)
+{
+ PDC_LOG(("scroll() - called\n"));
+
+ return wscrl(win, 1);
+}