FreeBASIC  0.91.0
io_cls.c
Go to the documentation of this file.
1 /* console CLS statement */
2 
3 #include "../fb.h"
4 #include "fb_private_console.h"
5 
6 void fb_ConsoleClear( int mode )
7 {
8  int start, end, i;
9 
10  if (!__fb_con.inited || mode==1)
11  return;
12 
13  BG_LOCK( );
15  BG_UNLOCK( );
16 
17  fb_ConsoleGetView(&start, &end);
18  if ((mode != 2) && (mode != 0xFFFF0000)) {
19  start = 1;
20  end = fb_ConsoleGetMaxRow();
21  }
22  if (start > __fb_con.h)
23  start = __fb_con.h;
24  if (end > __fb_con.h)
25  end = __fb_con.h;
26  for (i = start; i <= end; i++) {
27  memset(__fb_con.char_buffer + ((i - 1) * __fb_con.w), ' ', __fb_con.w);
28  memset(__fb_con.attr_buffer + ((i - 1) * __fb_con.w), __fb_con.fg_color | (__fb_con.bg_color << 4), __fb_con.w);
29  fb_hTermOut(SEQ_LOCATE, 0, i-1);
30  fb_hTermOut(SEQ_CLEOL, 0, 0);
31  }
32  fb_hTermOut(SEQ_LOCATE, 0, start-1);
33  __fb_con.cur_y = start;
34  __fb_con.cur_x = 1;
35 }