FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
io_spc.c
Go to the documentation of this file.
1
/* spc and tab functions */
2
3
#include "
fb.h
"
4
5
FBCALL
void
fb_PrintTab
(
int
fnum,
int
newcol )
6
{
7
FB_FILE
*
handle
;
8
int
col, row, cols, rows;
9
10
fb_DevScrnInit_NoOpen
( );
11
12
FB_LOCK
();
13
14
handle =
FB_FILE_TO_HANDLE
(fnum);
15
16
if
(
FB_HANDLE_IS_SCREEN
(handle) || handle->
type
==
FB_FILE_TYPE_CONSOLE
)
17
{
18
if
( handle->
type
==
FB_FILE_TYPE_CONSOLE
) {
19
if
( handle->
hooks
&& handle->
hooks
->
pfnFlush
)
20
handle->
hooks
->
pfnFlush
( handle );
21
}
22
23
/* Ensure that we get the "real" cursor position - this quirk is
24
* required for cursor positions at the right bottom of the screen */
25
fb_PrintBufferEx
(
NULL
, 0,
FB_PRINT_FORCE_ADJUST
);
26
fb_GetXY
( &col, &row );
27
fb_GetSize
( &cols, &rows );
28
29
if
( newcol > cols )
30
newcol %= cols;
31
32
if
( col > newcol ) {
33
fb_PrintVoidEx
( handle,
FB_PRINT_NEWLINE
);
34
fb_Locate
( 0, newcol, -1, 0, 0 );
35
36
}
else
if
( newcol < 1 )
37
fb_Locate
( 0, 1, -1, 0, 0 );
38
39
else
40
fb_Locate
( 0, newcol, -1, 0, 0 );
41
42
}
else
{
43
44
if
( handle->
type
==
FB_FILE_TYPE_PIPE
) {
45
46
fb_PrintPadEx
( handle, 0 );
47
48
}
else
{
49
50
if
( newcol > handle->
line_length
) {
51
fb_PrintStringEx
( handle,
52
fb_StrFill1
( newcol - handle->
line_length
- 1,
' '
),
53
0 );
54
}
else
{
55
56
if
( handle->
mode
==
FB_FILE_MODE_BINARY
) {
57
fb_PrintStringEx
( handle,
58
fb_StrAllocTempDescF
(
FB_BINARY_NEWLINE
,
sizeof
(
FB_BINARY_NEWLINE
) ),
59
0 );
60
}
else
{
61
fb_PrintStringEx
( handle,
62
fb_StrAllocTempDescF
(
FB_NEWLINE
,
sizeof
(
FB_NEWLINE
) ),
63
0 );
64
}
65
66
if
( newcol > 0 ) {
67
fb_PrintStringEx
( handle,
68
fb_StrFill1
( newcol - 1,
' '
),
69
0 );
70
}
71
72
}
73
74
}
75
76
}
77
78
FB_UNLOCK
();
79
}
80
81
FBCALL
void
fb_PrintSPC
(
int
fnum, ssize_t n )
82
{
83
FB_FILE
*
handle
;
84
int
col, row, cols, rows, newcol;
85
86
if
( n==0 )
87
return
;
88
89
fb_DevScrnInit_NoOpen
( );
90
91
FB_LOCK
();
92
93
handle =
FB_FILE_TO_HANDLE
(fnum);
94
95
if
(
FB_HANDLE_IS_SCREEN
(handle) || handle->
type
==
FB_FILE_TYPE_CONSOLE
)
96
{
97
if
( n == 0 )
98
return
;
99
100
if
( handle->
type
==
FB_FILE_TYPE_CONSOLE
) {
101
if
( handle->
hooks
&& handle->
hooks
->
pfnFlush
)
102
handle->
hooks
->
pfnFlush
( handle );
103
}
104
105
/* Ensure that we get the "real" cursor position - this quirk is
106
* required for cursor positions at the right bottom of the screen */
107
fb_PrintBufferEx
(
NULL
, 0,
FB_PRINT_FORCE_ADJUST
);
108
fb_GetXY
( &col, &row );
109
fb_GetSize
( &cols, &rows );
110
111
newcol = col + n;
112
if
( newcol > cols ) {
113
fb_PrintVoidEx
( handle,
FB_PRINT_NEWLINE
);
114
newcol %= cols;
115
}
116
117
fb_Locate
( 0, newcol, -1, 0, 0 );
118
119
}
else
{
120
121
fb_PrintStringEx
( handle,
fb_StrFill1
( n,
' '
), 0 );
122
123
}
124
125
FB_UNLOCK
();
126
}
rtlib
io_spc.c
Generated on Thu Jan 23 2014 19:40:12 for FreeBASIC by
1.8.4