8000 minix/commands/yap/commands.c at R3.1.2 · fyy3/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
executable file
·
706 lines (616 loc) · 14.5 KB

commands.c

File metadata and controls

executable file
·
706 lines (616 loc) · 14.5 KB
do_lcomm(cnt) long cnt; { /* Repeat last command */
if (!lastcomm) {
error("No previous command");
return;
}
do_comm(lastcomm, lastcount);
}
/*
* Execute a command, with optional count "count".
*/
VOID
do_comm(comm, count) register int comm; register long count; {
register struct commands *pcomm;
register int temp;
register int flags;
pcomm = &commands[comm];
flags = pcomm->c_flags;
/*
* Check the command.
* If the last line of the file is displayed and the command goes
* forwards and does'nt have the ability to go to the next file, it
* is an error.
* If the first line of the file is displayed and the command goes
* backwards and does'nt have the ability to go to the previous file,
* it is an error.
* Also check wether we need the next or previous file. If so, get it.
*/
if ((status & EOFILE) && (flags & AHEAD)) {
if (qflag || !(flags & TONEXTFILE)) return;
if (nextfile(1)) quit();
}
if ((status & START) && (flags & BACK)) {
if (qflag || !(flags & TOPREVFILE)) return;
if (nextfile(-1)) quit();
}
/*
* Does the command stick around for LASTCOMM?
*/
if (flags & STICKY) {
lastcomm = comm;
lastcount = count;
}
if (!count) {
if (flags & NEEDS_COUNT) count = 1;
}
else {
/*
* Does the command adapt the screensize?
*/
if (flags & SCREENSIZE_ADAPT) {
temp = maxpagesize;
if ((unsigned) count < temp) {
temp = count;
}
if (temp < MINPAGESIZE) {
temp = MINPAGESIZE;
}
count = 0;
pagesize = temp;
}
/*
* Does the command adapt the scrollsize?
*/
if (flags & SCROLLSIZE_ADAPT) {
temp = maxpagesize - 1;
if ((unsigned) count < temp) {
temp = (int) count;
}
scrollsize = temp;
count = 0;
}
}
/*
* Now execute the command.
*/
(*(pcomm->c_func))(count);
}
0