home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
C-ASM_VI.ARJ
/
PROGC.ZIP
/
PROGC055.C
< prev
next >
Wrap
Text File
|
1988-04-10
|
2KB
|
46 lines
/************************************************************************/
/* Scroll smoothly in 100 column text screen using cursor keys */
/* Quit on Escape key. */
/************************************************************************/
smooth_text_scroll()
{
#define KEY_ESC 0x011B
#define KEY_UP 0x4800
#define KEY_DOWN 0x5000
#define KEY_LEFT 0x4B00
#define KEY_RIGHT 0x4D00
#define KEY_ENTER 0x1C0D
int x = 0, y = 0, i, key;
set_more_columns(100); /* Select 100 text column mode */
set_cursor_position(0,0);
for (i = 0; i < 100;i++)/* Fill newly organized text buffer */
write_string(i, 0,
"This is text line in the new 100 column text buffer");
while((key = get_key()) != KEY_ENTER)
switch (key)
{
case KEY_RIGHT: /* Scroll right */
x = (x < 799) ? ++x : 799;
smooth_scroll(x,y);
break;
case KEY_LEFT: /* Scroll left */
x = ( x > 0) ? --x : 0;
smooth_scroll(x, y);
break;
case KEY_UP: /* Scroll up */
y = (y > 0) ? --y : 0;
smooth_scroll(x, y);
break;
case KEY_DOWN: /* Scroll down */
y = (y < 1399) ? ++y : 1399;
smooth_scroll(x, y);
break;
default:
break;
}
smooth_scroll(0,0);
}