[dev] I wrote a pager

From: Greg Reagle <greg.reagle_AT_umbc.edu>
Date: Fri, 16 Sep 2016 11:43:37 -0400

On Fri, Sep 16, 2016, at 10:01 AM, Greg Reagle wrote:
> Greetings. I am running stali in qemu and and it seems to lack a pager.
> Is it a goal of the suckless project to write a suckless pager for
> sbase? I see that plan9port already has a pager called "p". What about
> importing that into 9base?

Since I know that code is king around here, I wrote a pager program. I
am not an expert C programmer, so I might have done some things wrong.
But I think it does a good job of being minimalist.

What do you think? Would you like to put it into sbase or stali? If yes
then I can clone the sbase repo and submit a proper git patch.

#include <errno.h>
#include <stdio.h>

int main()
{
        const int page_size = 22;
        int count = 0;
        int ch;
        FILE *tty;

        if ((tty = fopen("/dev/tty", "a+")) == NULL)
                return(errno);

        ch = getchar();
        while (ch != EOF) {
                putchar(ch);
                if (ch == '\n') {
                        ++count;
                        if (count >= page_size) {
                                fgetc(tty);
                                count = 0;
                        }
                }
                ch = getchar();
        }
        fclose(tty);
}
Received on Fri Sep 16 2016 - 17:43:37 CEST

This archive was generated by hypermail 2.3.0 : Fri Sep 16 2016 - 17:48:11 CEST