FreeBASIC  0.91.0
io_scroll.c
Go to the documentation of this file.
1 /* console scrolling for when VIEW is used */
2 
3 #include "../fb.h"
4 #include "fb_private_console.h"
5 
6 static void fb_ConsoleScrollRawEx( HANDLE hConsole, int x1, int y1, int x2, int y2, int nrows )
7 {
8  int height = y2 - y1 + 1;
9 
10  if( nrows <= 0 )
11  return;
12 
13  if( nrows >= height ) {
14  /* clear view */
15  fb_ConsoleClearViewRawEx( hConsole, x1, y1, x2, y2 );
16 
17  } else {
18  /* scroll view */
19  SMALL_RECT srec;
20  COORD dcoord;
21  CHAR_INFO cinf;
22 
23  srec.Left = (SHORT) x1;
24  srec.Right = (SHORT) x2;
25  srec.Top = (SHORT) (y1 + nrows);
26  srec.Bottom = (SHORT) y2;
27 
28  dcoord.X = (SHORT) x1;
29  dcoord.Y = (SHORT) y1;
30 
31  cinf.Char.AsciiChar = ' ';
32  cinf.Attributes = fb_ConsoleGetColorAttEx( hConsole );
33 
34  ScrollConsoleScreenBuffer( hConsole, &srec, NULL, dcoord, &cinf );
35 #if 0
36  fb_ConsoleLocateRawEx( hConsole, y2 - nrows, -1, -1 );
37 #endif
38  }
39 }
40 
41 void fb_ConsoleScroll( int nrows )
42 {
43  int left, right;
44  int toprow, botrow;
45 
46  if( nrows <= 0 )
47  return;
48 
49  left = 1;
50  fb_ConsoleGetSize( &right, NULL );
51  fb_ConsoleGetView( &toprow, &botrow );
52  fb_hConvertToConsole( &left, &toprow, &right, &botrow );
53 
54  fb_ConsoleScrollRawEx( __fb_out_handle, left, toprow, right, botrow, nrows );
55 }