[comp.os.msdos.programmer] Scrolling lines in C

storm@cs.mcgill.ca (Marc WANDSCHNEIDER) (06/21/91)

Is there a way to scroll through lines on a screen while keeping a few lines
on the screen intact...?

Ie, If I have a  25 line screen, and want to keep 2 lines intact on the bottom
while scrolling three lines up above those two lines (somewhat akin to a text
editor)

By the same token is there a way to scroll three lines at the top of the screen
and have the rest scroll down the screen while keeping those two lines at the
bottom intact...?

I seem to recall something about a BIOS routine about this, but I was wondering
if I could do this in MS C, or Turbo C, or perhaps in a non-system specific
version of C (ANSI C).

./*-
storm@bart.cs.mcgill.ca
storm@sizone.UUCP
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
storm@cs.mcgill.ca         McGill University           It's 11pm, do YOU
Marc Wandschneider         Montreal, CANADA            know what time it is?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

sorrow@oak.circa.ufl.edu (06/22/91)

In article <1991Jun21.032331.11458@cs.mcgill.ca>, storm@cs.mcgill.ca (Marc WANDSCHNEIDER) writes:
|>Is there a way to scroll through lines on a screen while keeping a few lines
|>on the screen intact...?
|>
|>Ie, If I have a  25 line screen, and want to keep 2 lines intact on the bottom
|>while scrolling three lines up above those two lines (somewhat akin to a text
|>editor)
|>
|>By the same token is there a way to scroll three lines at the top of the screen
|>and have the rest scroll down the screen while keeping those two lines at the
|>bottom intact...?
|>
|>I seem to recall something about a BIOS routine about this, but I was wondering
|>if I could do this in MS C, or Turbo C, or perhaps in a non-system specific
|>version of C (ANSI C).

Well, an ANSI supported method?  NO.  If you are using the Borland language 
products, the only way to do it would be to use the window() command, move
the cursor to the bottom of the window, then cputs("\n");  That would handle
the scrolling for you.

Those routines are defined in CONIO.H.

In ASM or using C (int86 call), you could easily do it.  As a matter of fact,
here are two code fragments to just do that:

/* Note that the filler attribute uses a standard attribute byte that you */
/* will have to determine.  The byte is formatted as : */
/* bit 7 = intensity/blinking bit
   bit 4-6 = background color
   bit 0-3 = foreground color
*/

#include <dos.h>
#include <bios.h>

void ScrollWindowUp ( int lx, int ly, int rx, int ry )
{
union REGS regs;

   regs.h.ah=0x06;      /* Scroll window up function; AH=0x07 for down */
   regs.h.al=0x01;      /* Number of lines to scroll */
   regs.h.bh=[Insert Value] /* This is the filler attribute for the blanks */
   regs.h.ch=(unsigned char)ly; /* You can pass the coordinates as chars */
   regs.h.cl=(unsigned char)lx;
   regs.h.dh=(unsigned char)ry;
   regs.h.dl=(unsigned char)rx;
   int86(0x10,&regs,&regs);     /* 0x10 == video interrupt */
}

You could use inline ASM also, and you could also use the pseudo registers
and geninterrupt().

Hope this helps,

Brian

/*
Brian Hook -- MS-DOS Programmer for Contract
-----------------------------------------------------------------
"Seamus, that's my dog...I saw her today at the reception...sorry, sixTEEN
inches....better save the women and children first...but this one goes to 11!
..anymore of that plutonium nyborg?....there can be only ONE!....like a 
finger pointing to the moon....ease the seat back...one day closer to death
*/