xaizek / vifm-pdcurses (License: mostly public domain) (since 2019-03-20)
PDCurses 3.4 with vifm-specific patches applied (a couple were upstreamed)
<root> / pdcurses / scroll.c (c53e295468a18ec7f9905e86b307205eb5576f8c) (2,333B) (mode 100644) [raw]
/* 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);
}
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm-pdcurses

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm-pdcurses

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master