FreeBASIC  0.91.0
io_pcopy.c
Go to the documentation of this file.
1 /* console pcopy function */
2 
3 #include "../fb.h"
4 #include "fb_private_console.h"
5 
6 int fb_ConsolePageCopy( int src, int dst )
7 {
9 
10  /* use current? */
11  if( src < 0 )
12  src = __fb_con.active;
13 
14  /* not allocated yet? */
15  if( __fb_con.pgHandleTb[src] == NULL )
16  {
18  if( hnd == NULL )
20  else
21  __fb_con.pgHandleTb[src] = hnd;
22  }
23 
24  /* use current? */
25  if( dst < 0 )
26  dst = __fb_con.visible;
27 
28  if( src == dst )
29  return fb_ErrorSetNum( FB_RTERROR_OK );
30 
31  /* not allocated yet? */
32  if( __fb_con.pgHandleTb[dst] == NULL )
33  {
35  if( hnd == NULL )
37  else
38  __fb_con.pgHandleTb[dst] = hnd;
39  }
40 
41  /* do the copy */
42  static COORD pos = { 0, 0 };
43 
44  CONSOLE_SCREEN_BUFFER_INFO csbi;
45  GetConsoleScreenBufferInfo( __fb_con.pgHandleTb[src], &csbi );
46  PCHAR_INFO buff = alloca( csbi.dwSize.X * csbi.dwSize.Y * sizeof( CHAR_INFO ) );
47 
48  ReadConsoleOutput( __fb_con.pgHandleTb[src], buff, csbi.dwSize, pos, &csbi.srWindow );
49 
50  GetConsoleScreenBufferInfo( __fb_con.pgHandleTb[dst], &csbi );
51  WriteConsoleOutput( __fb_con.pgHandleTb[dst], buff, csbi.dwSize, pos, &csbi.srWindow );
52 
53  return fb_ErrorSetNum( FB_RTERROR_OK );
54 }