FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
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
{
8
fb_hConsoleGetHandle
(
FALSE
);
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
{
17
HANDLE
hnd =
fb_hConsoleCreateBuffer
( );
18
if
( hnd ==
NULL
)
19
return
fb_ErrorSetNum
(
FB_RTERROR_ILLEGALFUNCTIONCALL
);
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
{
34
HANDLE
hnd =
fb_hConsoleCreateBuffer
( );
35
if
( hnd ==
NULL
)
36
return
fb_ErrorSetNum
(
FB_RTERROR_ILLEGALFUNCTIONCALL
);
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
}
rtlib
win32
io_pcopy.c
Generated on Thu Jan 23 2014 19:40:09 for FreeBASIC by
1.8.4