1 /*-----------------------------------------------------------------------------------*/
\r
2 /* Francois VOGEL sciprint_full function */
\r
3 /*-----------------------------------------------------------------------------------*/
\r
4 /* sciprint geared towards long strings (>MAXPRINTF) */
\r
5 /* the long string is splitted in elements of length equal to the number of columns */
\r
7 /*-----------------------------------------------------------------------------------*/
\r
11 #include "sciprint_full.h"
\r
12 #include "sciprint.h"
\r
14 #include "localization.h"
\r
15 #include "../../shell/includes/scilines.h"
\r
16 /*-----------------------------------------------------------------------------------*/
\r
18 #define vsnprintf _vsnprintf
\r
20 /*-----------------------------------------------------------------------------------*/
\r
21 /* MAXCHARSSCIPRINT_FULL is for sciprint_full - more than this gets truncated */
\r
22 #define MAXCHARSSCIPRINT_FULL 5000
\r
23 /*-----------------------------------------------------------------------------------*/
\r
24 void sciprint_full(char *fmt,...)
\r
29 char *split_s_buf=NULL;
\r
32 static integer colwidth;
\r
35 s_buf=MALLOC(sizeof(char)*(MAXCHARSSCIPRINT_FULL+1));
\r
36 if (s_buf == (char *) 0)
\r
38 sciprint(_("sciprint_full : No more memory.\n"));
\r
42 /* number of columns as set by command lines() */
\r
43 colwidth = getLinesSize();
\r
44 /* clamp to a minimum: value is arbitrary */
\r
45 if (colwidth < 20) {colwidth=20;}
\r
46 /* clamp to a maximum: value is selected so that each line fits in a single console line */
\r
47 /* this is needed because computation of the lines() value in ON_WND_TEXT_WM_SIZE is not */
\r
48 /* consistent with the limit before a carriage return occurs in TextPutStr - this latter */
\r
49 /* limit uses lptw->ScreenSize, which is set to x=120,y=80 at init and apparently never */
\r
50 /* changed on window resizing */
\r
51 if (colwidth > 109) {colwidth=109;}
\r
53 split_s_buf=MALLOC(sizeof(char)*(colwidth+1));
\r
54 if (split_s_buf == (char *) 0)
\r
56 sciprint(_("sciprint_full : No more memory.\n"));
\r
62 #if defined(linux) || defined(_MSC_VER)
\r
63 count = vsnprintf (s_buf,MAXCHARSSCIPRINT_FULL-1, fmt, ap );
\r
66 s_buf[MAXCHARSSCIPRINT_FULL-1]='\0';
\r
69 (void )vsprintf(s_buf, fmt, ap );
\r
74 lstr=(integer)strlen(s_buf);
\r
78 sciprint("%s",s_buf);
\r
82 strncpy(split_s_buf,s_buf+p_s,colwidth-1);
\r
83 split_s_buf[colwidth]='\0';
\r
85 sciprint("%s",split_s_buf);
\r
87 while (p_s+colwidth-1<(int)lstr)
\r
89 strncpy(split_s_buf,s_buf+p_s,colwidth-1);
\r
90 split_s_buf[colwidth]='\0';
\r
92 MSG=_(" (cont'd) %s");
\r
95 sciprint(MSG,split_s_buf);
\r
98 if (MSG) {FREE(MSG);MSG=NULL;}
\r
100 strncpy(split_s_buf,s_buf+p_s,lstr-p_s);
\r
101 split_s_buf[lstr-p_s]='\0';
\r
102 MSG=_(" (end) %s");
\r
105 sciprint(MSG,split_s_buf);
\r
108 if (MSG) {FREE(MSG);MSG=NULL;}
\r
111 if (s_buf){FREE(s_buf);s_buf=NULL;}
\r
112 if (split_s_buf){FREE(split_s_buf);split_s_buf=NULL;}
\r
115 /*-----------------------------------------------------------------------------------*/
\r