FreeBASIC  0.91.0
io_printpad_wstr.c
Go to the documentation of this file.
1 /* print functions */
2 
3 #include "fb.h"
4 
5 #define FB_PRINT_BUFFER_SIZE 2048
6 
7 static void fb_hPrintPadWstrEx
8  (
10  int mask,
11  int current_x,
12  int new_x
13  )
14 {
15 #ifdef FB_NATIVE_TAB
16  FB_PRINTWSTR_EX( handle, _LC("\t"), 1, mask );
17 
18 #else
19  FB_WCHAR tab_char_buffer[FB_TAB_WIDTH+1];
20 
21  if (new_x <= current_x)
22  {
23  FB_PRINTWSTR_EX( handle,
25  sizeof( FB_NEWLINE_WSTR ) / sizeof( FB_WCHAR ) - 1,
26  mask );
27  }
28  else
29  {
30  size_t i, count = new_x - current_x;
31 
32  for( i = 0; i < count; i++ )
33  tab_char_buffer[i] = _LC(' ');
34 
35  /* the terminating NUL shouldn't be required but it makes
36  * debugging easier */
37  tab_char_buffer[count] = 0;
38 
39  FB_PRINTWSTR_EX( handle, tab_char_buffer, count, mask );
40  }
41 #endif
42 }
43 
44 /*:::::*/
46  (
47  FB_FILE *handle,
48  int mask
49  )
50 {
51 #ifdef FB_NATIVE_TAB
52  FB_PRINTWSTR_EX( handle, _LC("\t"), 1, mask );
53 
54 #else
55  FB_FILE *tmp_handle;
56  int old_x;
57  int new_x;
58 
60 
61  tmp_handle = FB_HANDLE_DEREF(handle);
62 
63  old_x = tmp_handle->line_length + 1;
64  new_x = old_x + FB_TAB_WIDTH - 1;
65  new_x /= FB_TAB_WIDTH;
66  new_x *= FB_TAB_WIDTH;
67  new_x += 1;
68  if (tmp_handle->width!=0)
69  {
70  unsigned dev_width = tmp_handle->width;
71  if (new_x > (dev_width - FB_TAB_WIDTH))
72  {
73  new_x = 1;
74  }
75  }
76  fb_hPrintPadWstrEx( handle, mask, old_x, new_x );
77 #endif
78 }
79 
80 /*:::::*/
82  (
83  int fnum,
84  int mask
85  )
86 {
87  fb_PrintPadWstrEx( FB_FILE_TO_HANDLE(fnum), mask );
88 }