FreeBASIC  0.91.0
io_locate.c
Go to the documentation of this file.
1 /* console LOCATE statement */
2 
3 #include "../fb.h"
4 #include "fb_private_console.h"
5 
6 int fb_ConsoleLocate( int row, int col, int cursor )
7 {
8  int ret_val;
9  CONSOLE_CURSOR_INFO info;
10 
11  if( col < 1 )
12  col = fb_ConsoleGetX();
13  if( row < 1 )
14  row = fb_ConsoleGetY();
15 
16  GetConsoleCursorInfo( __fb_out_handle, &info );
17  ret_val =
18  (col & 0xFF) | ((row & 0xFF) << 8) | (info.bVisible ? 0x10000 : 0);
19 
20  fb_hConvertToConsole( &col, &row, NULL, NULL );
21 
22  fb_ConsoleLocateRawEx( __fb_out_handle, row, col, cursor );
23 
24  return ret_val;
25 }
26 
27 void fb_ConsoleLocateRawEx( HANDLE hConsole, int row, int col, int cursor )
28 {
29  COORD c;
30 
31  if( col < 0 )
32  col = fb_ConsoleGetRawXEx( hConsole );
33  if( row < 0 )
34  row = fb_ConsoleGetRawYEx( hConsole );
35 
36  c.X = (SHORT) col;
37  c.Y = (SHORT) row;
38 
39  if( cursor >= 0 ) {
40  CONSOLE_CURSOR_INFO info;
41  GetConsoleCursorInfo( __fb_out_handle, &info );
42  info.bVisible = ( cursor ? TRUE : FALSE );
43  SetConsoleCursorInfo( hConsole, &info );
44  }
45 
47  SetConsoleCursorPosition( hConsole, c );
48 }
49 
50 FBCALL void fb_ConsoleLocateRaw( int row, int col, int cursor )
51 {
52  fb_ConsoleLocateRawEx( __fb_out_handle, row, col, cursor );
53 }