shithub: nc

ref: cf16e9489a1a90e3a4b17bb03021969d4ea5faed
dir: /viewercmd.c/

View raw version
#include "a.h"

static void
cmdquit(void)
{
	if(mode == Mview){
		free(text->title);
		free(text->data);
	}
	setmode(Mdir);
}

static void
cmdup(void)
{
	textscroll(text, -1);
}

static void
cmddown(void)
{
	textscroll(text, 1);
}

static void
cmdhome(void)
{
	textscroll(text, -text->nlines);
}

static void
cmdend(void)
{
	textscroll(text, text->nlines);
}

static void
cmdpageup(void)
{
	textscroll(text, -text->vlines);
}

static void
cmdpagedown(void)
{
	textscroll(text, text->vlines);
}

Binding	viewerbindings[] = {
	{ KF|10,	cmdquit },
	{ Kup,		cmdup },
	{ Kdown,	cmddown },
	{ Khome,	cmdhome },
	{ Kend,		cmdend },
	{ Kpgup,	cmdpageup },
	{ Kpgdown,	cmdpagedown },
	nil
};

void
setupviewerbindings(void)
{
	bindings = viewerbindings;
	actionbarclear(abar);
	actionbarset(abar, 10, "Quit", cmdquit);
}